Being explicit between http and ocs return codes

This commit is contained in:
Sergio Bertolin 2015-10-02 07:40:25 +00:00 committed by Roeland Jago Douma
parent ac478b1910
commit fd709b4b49
3 changed files with 36 additions and 19 deletions

View File

@ -49,28 +49,36 @@ class FeatureContext extends BehatContext {
$this->sendingToWith($verb, $url, null); $this->sendingToWith($verb, $url, null);
} }
// /**
// * @Then /^the status code should be "([^"]*)"$/
// */
// public function theStatusCodeShouldBe($statusCode) {
// PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
// }
/**
* Parses the xml answer to get ocs response which doesn't match with
* http one in v1 of the api.
*/
public function getOCSResponse($response){ public function getOCSResponse($response){
return $response->xml()->meta[0]->statuscode; return $response->xml()->meta[0]->statuscode;
} }
/** /**
* @Then /^the status code should be "([^"]*)"$/ * @Then /^the OCS status code should be "([^"]*)"$/
*/ */
public function theStatusCodeShouldBe($statusCode) { public function theOCSStatusCodeShouldBe($statusCode) {
PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response)); PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response));
} }
/**
* @Then /^the HTTP status code should be "([^"]*)"$/
*/
public function theHTTPStatusCodeShouldBe($statusCode) {
PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
}
/** /**
* @Given /^As an "([^"]*)"$/ * @Given /^As an "([^"]*)"$/
*/ */
@ -89,7 +97,7 @@ class FeatureContext extends BehatContext {
* @Given /^user "([^"]*)" exists$/ * @Given /^user "([^"]*)" exists$/
*/ */
public function userExists($user) { public function userExists($user) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
$client = new Client(); $client = new Client();
$options = []; $options = [];
if ($this->currentUser === 'admin') { if ($this->currentUser === 'admin') {
@ -97,6 +105,7 @@ class FeatureContext extends BehatContext {
} }
$this->response = $client->get($fullUrl, $options); $this->response = $client->get($fullUrl, $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
} }
/** /**
@ -155,7 +164,7 @@ class FeatureContext extends BehatContext {
* @Given /^group "([^"]*)" exists$/ * @Given /^group "([^"]*)" exists$/
*/ */
public function groupExists($group) { public function groupExists($group) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group"; $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group";
$client = new Client(); $client = new Client();
$options = []; $options = [];
if ($this->currentUser === 'admin') { if ($this->currentUser === 'admin') {
@ -163,6 +172,7 @@ class FeatureContext extends BehatContext {
} }
$this->response = $client->get($fullUrl, $options); $this->response = $client->get($fullUrl, $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
} }
/** /**

View File

@ -5,12 +5,14 @@ Feature: provisioning
Scenario: Getting an not existing user Scenario: Getting an not existing user
Given As an "admin" Given As an "admin"
When sending "GET" to "/cloud/users/test" When sending "GET" to "/cloud/users/test"
Then the status code should be "998" Then the OCS status code should be "998"
And the HTTP status code should be "200"
Scenario: Listing all users Scenario: Listing all users
Given As an "admin" Given As an "admin"
When sending "GET" to "/cloud/users" When sending "GET" to "/cloud/users"
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
Scenario: Create a user Scenario: Create a user
Given As an "admin" Given As an "admin"
@ -18,7 +20,8 @@ Feature: provisioning
When sending "POST" to "/cloud/users" with When sending "POST" to "/cloud/users" with
| userid | brand-new-user | | userid | brand-new-user |
| password | 123456 | | password | 123456 |
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" exists And user "brand-new-user" exists
@ -30,7 +33,8 @@ Feature: provisioning
| value | 12MB | | value | 12MB |
| key | email | | key | email |
| value | brand-new-user@gmail.com | | value | brand-new-user@gmail.com |
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" exists And user "brand-new-user" exists
@ -38,7 +42,8 @@ Feature: provisioning
Given As an "admin" Given As an "admin"
And user "brand-new-user" exists And user "brand-new-user" exists
When sending "DELETE" to "/cloud/users/brand-new-user" When sending "DELETE" to "/cloud/users/brand-new-user"
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" does not exist And user "brand-new-user" does not exist
@ -49,7 +54,8 @@ Feature: provisioning
| groupid | new-group | | groupid | new-group |
| password | 123456 | | password | 123456 |
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
And group "new-group" exists And group "new-group" exists
@ -57,7 +63,8 @@ Feature: provisioning
Given As an "admin" Given As an "admin"
And group "new-group" exists And group "new-group" exists
When sending "DELETE" to "/cloud/groups/new-group" When sending "DELETE" to "/cloud/groups/new-group"
Then the status code should be "100" Then the OCS status code should be "100"
And the HTTP status code should be "200"
And group "new-group" does not exist And group "new-group" does not exist

View File

@ -5,5 +5,5 @@ Feature: provisioning
Scenario: Getting an not existing user Scenario: Getting an not existing user
Given As an "admin" Given As an "admin"
When sending "GET" to "/cloud/users/test" When sending "GET" to "/cloud/users/test"
Then the status code should be "404" Then the HTTP status code should be "404"