Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
Added accessors for the shell_access, vcs_access, and blacklist in the
Browse files Browse the repository at this point in the history
SshKey class.  Also added access to the log data in the Task class.
Added appropriate unit tests.
  • Loading branch information
Paul Lovvik committed Mar 10, 2015
1 parent f6baad4 commit 9129fe6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/Acquia/Cloud/Api/Response/SshKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,37 @@ public function nickname()
{
return $this['nickname'];
}

/**
* Indicates whether this key has access to the shell.
*
* @return bool
* TRUE if this key can access the shell; FALSE otherwise.
*/
public function shellAccess()
{
return $this['shell_access'];
}

/**
* Indicates whether this key has access to the VCS repository.
*
* @return bool
* TRUE if this key can access the VCS repository; FALSE otherwise.
*/
public function vcsAccess()
{
return $this['vcs_access'];
}

/**
* Indicates the names of the environments this key does not have access to.
*
* @return string[]
* An array of environment names this key cannot access.
*/
public function blacklist()
{
return $this['blacklist'];
}
}
10 changes: 10 additions & 0 deletions src/Acquia/Cloud/Api/Response/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,14 @@ public function percentage()
{
return $this['percentage'];
}

/**
* Gets the task log data.
*
* @return string
* The log data.
*/
public function logs() {
return $this['logs'];
}
}
5 changes: 5 additions & 0 deletions test/Acquia/Test/Cloud/Api/CloudApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ public function testCallSshKey()
$this->assertEquals('12345', $response->id());
$this->assertEquals('ssh-rsa AAAA== [email protected]', $response->publicKey());
$this->assertEquals('[email protected]', $response->nickname());
$this->assertEquals(TRUE, $response->shellAccess());
$this->assertEquals(TRUE, $response->vcsAccess());
$this->assertEquals(array('test'), $response->blacklist());
}

public function testCallAddSshKey()
Expand Down Expand Up @@ -733,6 +736,7 @@ public function testCallTask()

$this->assertEquals('https://cloudapi.example.com/v1/sites/stage-one%3Amysite/tasks/12345.json', $this->requestListener->getUrl());
$this->assertInstanceOf('\Acquia\Cloud\Api\Response\Task', $response);
$this->assertEquals('started', $response->logs());

// NOTE: Task methods are already well-tested so we don't have to do
// anything else here.
Expand All @@ -746,6 +750,7 @@ public function testCallTaskInfo()

$this->assertEquals('https://cloudapi.example.com/v1/sites/stage-one%3Amysite/tasks/12345.json', $this->requestListener->getUrl());
$this->assertInstanceOf('\Acquia\Cloud\Api\Response\Task', $response);
$this->assertEquals('started', $response->logs());
}

public function testCallDomains()
Expand Down
2 changes: 1 addition & 1 deletion test/Acquia/Test/Cloud/Api/json/ssh_key.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"12345","ssh_pub_key":"ssh-rsa AAAA== [email protected]","nickname":"[email protected]"}
{"id":"12345","ssh_pub_key":"ssh-rsa AAAA== [email protected]","nickname":"[email protected]","shell_access":"1","vcs_access":"1","blacklist":["test"]}
2 changes: 1 addition & 1 deletion test/Acquia/Test/Cloud/Api/json/task.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"recipient":"backup-123.stage-one.hosting.acquia.com","queue":"delete-db-backup","result":null,"completed":null,"started":null,"description":"Delete backup 12345 of database mysite in prod environment.","state":"received","id":"12345","sender":"cloud_api","percentage":null,"created":"1390535078","body":"[\"12345\"]","cookie":null,"hidden":"0"}
{"recipient":"backup-123.stage-one.hosting.acquia.com","queue":"delete-db-backup","result":null,"completed":null,"started":null,"description":"Delete backup 12345 of database mysite in prod environment.","state":"received","id":"12345","sender":"cloud_api","percentage":null,"created":"1390535078","body":"[\"12345\"]","cookie":null,"hidden":"0","logs":"started"}

0 comments on commit 9129fe6

Please sign in to comment.