public function testUpdateUser()
 {
     $user = new User();
     $user->setTitle(Utils::randomString());
     $user->setName(Utils::randomString());
     $resp = Utils::getBuddy()->getApiProfile()->editAuthenticatedUser($user);
     $this->assertInstanceOf('Buddy\\Objects\\User', $resp);
     $this->assertEquals($user->getName(), $resp->getName());
     $this->assertEquals($user->getTitle(), $resp->getTitle());
 }
 public function testEditGroupOnlyName()
 {
     $group = Utils::addGroup();
     $newGroup = new Group();
     $newGroup->setName(Utils::randomString());
     $resp = Utils::getBuddy()->getApiGroups()->editGroup($newGroup, Utils::getWorkspaceDomain(), $group->getId());
     $this->assertInstanceOf('Buddy\\Objects\\Group', $resp);
     $this->assertEquals($group->getId(), $resp->getId());
     $this->assertEquals($newGroup->getName(), $resp->getName());
     $this->assertEquals($group->getDescription(), $resp->getDescription());
 }
 public function testDeleteBranch()
 {
     $project = Utils::addProject();
     $file = Utils::addFile($project);
     $branch = new Branch();
     $branch->setName(Utils::randomString());
     $branch->setCommit($file->getCommit());
     $branch = Utils::getBuddy()->getApiBranches()->addBranch($branch, Utils::getWorkspaceDomain(), $project->getName());
     $resp = Utils::getBuddy()->getApiBranches()->deleteBranch(Utils::getWorkspaceDomain(), $project->getName(), $branch->getName());
     $this->assertEquals(true, $resp);
 }
 public function testEditPermisisonOnlyName()
 {
     $perm = Utils::addPermission();
     $newPerm = new PermissionSet();
     $newPerm->setName(Utils::randomString());
     $resp = Utils::getBuddy()->getApiPermissions()->editWorkspacePermission($newPerm, Utils::getWorkspaceDomain(), $perm->getId());
     $this->assertInstanceOf('Buddy\\Objects\\PermissionSet', $resp);
     $this->assertEquals($perm->getHtmlUrl(), $resp->getHtmlUrl());
     $this->assertEquals($perm->getId(), $resp->getId());
     $this->assertEquals($perm->getUrl(), $resp->getUrl());
     $this->assertEquals($perm->getDescription(), $resp->getDescription());
     $this->assertEquals($newPerm->getName(), $resp->getName());
     $this->assertEquals($perm->getReleaseScenarioAccessLevel(), $resp->getReleaseScenarioAccessLevel());
     $this->assertEquals($perm->getRepositoryAccessLevel(), $resp->getRepositoryAccessLevel());
     $this->assertEquals($perm->getType(), $resp->getType());
 }
 public function testEditWebhook()
 {
     $wh = Utils::addWebhook();
     $project = Utils::addProject();
     $wh->setProjectFilter($project);
     $wh->setEvents([Webhook::EVENT_RELEASE_SUCCESSFUL]);
     $wh->setSecretKey(Utils::randomString());
     $wh->setTargetUrl('http://wp.pl');
     $resp = Utils::getBuddy()->getApiWebhooks()->editWebhook($wh, Utils::getWorkspaceDomain(), $wh->getId());
     $this->assertInstanceOf('Buddy\\Objects\\Webhook', $resp);
     $this->assertEquals($wh->getTargetUrl(), $resp->getTargetUrl());
     $this->assertEquals($wh->getSecretKey(), $resp->getSecretKey());
     $this->assertEquals($wh->getProjectFilter()->getName(), $resp->getProjectFilter()->getName());
     $events = $resp->getEvents();
     $this->assertInternalType('array', $events);
     $this->assertEquals(1, count($events));
     $this->assertEquals(Webhook::EVENT_RELEASE_SUCCESSFUL, $events[0]);
 }
예제 #6
0
 /**
  * @param Project $project
  * @return \Buddy\Objects\Scenario
  */
 public static function addScenario(Project $project)
 {
     Utils::addFile($project);
     $scenario = new Scenario();
     $scenario->setName(Utils::randomString());
     $scenario->setAutomatic(true);
     $scenario->setBranch('master');
     return Utils::getBuddy()->getApiScenarios()->addScenario($scenario, Utils::getWorkspaceDomain(), $project->getName());
 }
 public function testEditProjectWithoutDisplayName()
 {
     $project = Utils::addProject();
     $editProject = new Project();
     $editProject->setName(Utils::randomString());
     $savedProject = Utils::getBuddy()->getApiProjects()->editProject($editProject, Utils::getWorkspaceDomain(), $project->getName());
     $this->assertEquals($editProject->getName(), $savedProject->getName());
     $this->assertEquals($project->getDisplayName(), $savedProject->getDisplayName());
 }
 public function testActionModel()
 {
     $name = Utils::randomString();
     $accessKey = Utils::randomString();
     $activeMode = true;
     $authMode = ScenarioAction::AUTH_MODE_PASS;
     $bucketName = Utils::randomString();
     $cloudfrontId = Utils::randomString();
     $commands = ['ls'];
     $host = 'http://google.pl';
     $localPath = '/test';
     $passphrase = Utils::randomString();
     $password = Utils::randomString();
     $login = Utils::randomString();
     $port = Utils::randomInteger();
     $publicAccess = true;
     $reducedRedundacy = true;
     $remotePath = '/var';
     $secretKey = Utils::randomString();
     $serverKey = Utils::randomString();
     $type = ScenarioAction::TYPE_SFTP;
     $workingDir = '/home';
     $action = new ScenarioAction();
     $action->setName($name);
     $action->setAccessKey($accessKey);
     $action->setActiveMode($activeMode);
     $action->setAuthenticationMode($authMode);
     $action->setBucketName($bucketName);
     $action->setCloudfrontId($cloudfrontId);
     $action->setCommands($commands);
     $action->setHost($host);
     $action->setLocalPath($localPath);
     $action->setLogin($login);
     $action->setPassphrase($passphrase);
     $action->setPassword($password);
     $action->setPort($port);
     $action->setPublicAccess($publicAccess);
     $action->setReducedRedundancy($reducedRedundacy);
     $action->setRemotePath($remotePath);
     $action->setSecretKey($secretKey);
     $action->setServerKey($serverKey);
     $action->setType($type);
     $action->setWorkingDirectory($workingDir);
     $this->assertEquals($name, $action->getName());
     $this->assertEquals($accessKey, $action->getAccessKey());
     $this->assertEquals($activeMode, $action->getActiveMode());
     $this->assertEquals($authMode, $action->getAuthenticationMode());
     $this->assertEquals($bucketName, $action->getBucketName());
     $this->assertEquals($cloudfrontId, $action->getCloudfrontId());
     $this->assertEquals($commands, $action->getCommands());
     $this->assertEquals($host, $action->getHost());
     $this->assertEquals($localPath, $action->getLocalPath());
     $this->assertEquals($login, $action->getLogin());
     $this->assertEquals($passphrase, $action->getPassphrase());
     $this->assertEquals($password, $action->getPassword());
     $this->assertEquals($port, $action->getPort());
     $this->assertEquals($publicAccess, $action->getPublicAccess());
     $this->assertEquals($reducedRedundacy, $action->getReducedRedundancy());
     $this->assertEquals($remotePath, $action->getRemotePath());
     $this->assertEquals($secretKey, $action->getSecretKey());
     $this->assertEquals($serverKey, $action->getServerKey());
     $this->assertEquals($type, $action->getType());
     $this->assertEquals($workingDir, $action->getWorkingDirectory());
     $this->assertEmpty($action->getId());
     $this->assertEmpty($action->getRevision());
     $this->assertEmpty($action->getStatus());
 }