public function testGetMemberProjects()
 {
     $user = Utils::addUser();
     $resp = Utils::getBuddy()->getApiMembers()->getWorkspaceMemberProjects(Utils::getWorkspaceDomain(), $user->getId());
     $this->assertInstanceOf('Buddy\\Objects\\Projects', $resp);
     $this->assertNotEmpty($resp->getUrl());
     $this->assertEquals(0, count($resp->getProjects()));
 }
 public function testAddAndDeleteEmail()
 {
     $email = new Email();
     $email->setEmail(Utils::randomEmail());
     $resp = Utils::getBuddy()->getApiEmails()->addAuthenticatedUserEmail($email);
     $this->assertInstanceOf('Buddy\\Objects\\Email', $resp);
     $resp = Utils::getBuddy()->getApiEmails()->deleteAuthenticatedUserEmail($email->getEmail());
     $this->assertEquals(true, $resp);
 }
 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 testDeleteFile()
 {
     $project = Utils::addProject();
     $content = Utils::addFile($project);
     $delFile = new SourceContent();
     $delFile->setMessage('AAA');
     $delFile->setBranch($content->getContent()->getBranch());
     $resp = Utils::getBuddy()->getApiSource()->deleteFile($delFile, Utils::getWorkspaceDomain(), $project->getName(), $content->getContent()->getPath());
     $this->assertInstanceOf('Buddy\\Objects\\Commit', $resp);
 }
 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 testCompare()
 {
     $project = Utils::addProject();
     $oldFile = Utils::addFile($project);
     $file = Utils::addFile($project);
     $resp = Utils::getBuddy()->getApiCommits()->getCompare(Utils::getWorkspaceDomain(), $project->getName(), $oldFile->getCommit()->getRevision(), $file->getCommit()->getRevision());
     $this->assertInstanceOf('Buddy\\Objects\\CompareCommits', $resp);
     $this->assertInstanceOf('Buddy\\Objects\\Commit', $resp->getBaseCommit());
     $this->assertInternalType('array', $resp->getCommits());
     $this->assertEquals(0, $resp->getAhead());
     $this->assertEquals(1, $resp->getBehind());
 }
 public function testAddGetDeleteKey()
 {
     $key = new SshKey();
     $key->setContent('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCG0Ug3U8DoJ6+z36D2h2+oc4UoQRihLNGcAO9SHglFXp+dn1aGJrqeoOrmo4bj5AcydjY33Ylm7ixZEe85vD5INCeldMd8JGmZTj57mwzqpKXFrag+/v9F9qmSEPxKZ1cQj7Q/nRi/hJIoJbsxymrxWhdJZnDNeqwdusR78Xkftw== scot@scot-Macmini');
     $key->setTitle('Test');
     $resp = Utils::getBuddy()->getApiSshKeys()->addAuthenticatedUserKey($key);
     $this->assertInstanceOf('Buddy\\Objects\\SshKey', $resp);
     $this->assertEquals($key->getContent(), $resp->getContent());
     $this->assertEquals($key->getTitle(), $resp->getTitle());
     $this->assertGreaterThan(0, $resp->getId());
     $resp2 = Utils::getBuddy()->getApiSshKeys()->getAuthenticatedUserKey($resp->getId());
     $this->assertEquals($key->getContent(), $resp2->getContent());
     $this->assertEquals($key->getTitle(), $resp2->getTitle());
     $this->assertEquals($resp->getId(), $resp2->getId());
     $resp3 = Utils::getBuddy()->getApiSshKeys()->deleteAuthenticatedUserKey($resp2->getId());
     $this->assertEquals(true, $resp3);
 }
 /**
  * @return Webhook
  */
 public static function addWebhook()
 {
     $webhook = new Webhook();
     $webhook->setTargetUrl('http://onet.pl');
     $webhook->setEvents([Webhook::EVENT_RELEASE_FAILED]);
     return Utils::getBuddy()->getApiWebhooks()->addWebhook($webhook, Utils::getWorkspaceDomain());
 }
 public function testDeleteGroupMember()
 {
     $group = Utils::addGroup();
     $user = Utils::addUser();
     Utils::addUser2Group($group, $user);
     $resp = Utils::getBuddy()->getApiGroups()->deleteGroupMember(Utils::getWorkspaceDomain(), $group->getId(), $user->getId());
     $this->assertEquals(true, $resp);
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddyResponseException
  */
 public function testRetryRelease()
 {
     Utils::getBuddy()->getApiReleases()->retryRelease(Utils::getWorkspaceDomain(), 'test', 1, 1);
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddySDKException
  * @expectedExceptionMessage PermissionSet must be set
  */
 public function testAddProjectMemberWithoutPermission()
 {
     Utils::getBuddy()->getApiProjects()->addProjectMember(new User(), Utils::getWorkspaceDomain(), 'test');
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddyResponseException
  */
 public function testGetTag()
 {
     $project = Utils::addProject();
     Utils::getBuddy()->getApiTags()->getTag(Utils::getWorkspaceDomain(), $project->getName(), 'test');
 }
 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());
 }
 public function testDeletePermission()
 {
     $perm = Utils::addPermission();
     $resp = Utils::getBuddy()->getApiPermissions()->deleteWorkspacePermission(Utils::getWorkspaceDomain(), $perm->getId());
     $this->assertEquals(true, $resp);
 }
 public function testEditWebhookOnlyTargetUrl()
 {
     $wh = Utils::addWebhook();
     $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(), $resp->getProjectFilter());
     $events = $resp->getEvents();
     $this->assertInternalType('array', $events);
     $this->assertEquals(1, count($events));
     $this->assertEquals(Webhook::EVENT_RELEASE_FAILED, $events[0]);
 }