added some group logic

This commit is contained in:
Sergio Bertolin 2015-09-29 14:52:19 +00:00 committed by Roeland Jago Douma
parent da640adf68
commit 583c082acf
2 changed files with 61 additions and 0 deletions

View File

@ -116,6 +116,55 @@ class FeatureContext extends BehatContext {
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
} }
/**
* @When /^creating the group "([^"]*)r"$/
*/
public function creatingTheGroup($group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/addgroup" ;
$client = new Client();
$options = [];
if ($this->currentUser === 'admin') {
$options['auth'] = $this->adminUser;
}
$this->response = $client->post($fullUrl, [
'form_params' => [
'groupid' => $user
]
]);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
/**
* @Given /^group "([^"]*)" exists$/
*/
public function groupExists($group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group";
$client = new Client();
$options = [];
if ($this->currentUser === 'admin') {
$options['auth'] = $this->adminUser;
}
$this->response = $client->get($fullUrl, $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
/**
* @Given /^group "([^"]*)" does not exist$/
*/
public function groupDoesNotExist($group) {
try {
$this->groupExists($group);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
}
}
/** /**
* @When /^sending "([^"]*)" to "([^"]*)" with$/ * @When /^sending "([^"]*)" to "([^"]*)" with$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $formData

View File

@ -30,3 +30,15 @@ Feature: provisioning
| userid | brand-new-user | | userid | brand-new-user |
Then the status code should be "200" Then the status code should be "200"
And user "brand-new-user" does not exist And user "brand-new-user" does not exist
Scenario: Create a group
Given As an "admin"
And group "new-group" does not exist
When sending "POST" to "/cloud/groups" with
| groupid | new-group |
| password | 123456 |
Then the status code should be "200"
And group "new-group" exists