summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-06 11:19:48 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-06 11:19:48 +0200
commitd9ffb094793f8bfff2c4231e5bde65900f6224cd (patch)
tree04fd42ca136956c25ec159ee97c334f0c0b55afd /build
parent0385a62363bbfe6d07f554ecd5d5d6e5c3be35f4 (diff)
parentb0babfc847e6bf232e31caf64182c5c571732954 (diff)
downloadnextcloud-server-d9ffb094793f8bfff2c4231e5bde65900f6224cd.tar.gz
nextcloud-server-d9ffb094793f8bfff2c4231e5bde65900f6224cd.zip
Merge pull request #19452 from owncloud/ocs_provisioning_api_more_tests
OCS provisioning API more tests
Diffstat (limited to 'build')
-rw-r--r--build/integration/features/bootstrap/FeatureContext.php75
-rw-r--r--build/integration/features/provisioning-v1.feature66
-rw-r--r--build/integration/features/provisioning-v2.feature2
3 files changed, 130 insertions, 13 deletions
diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php
index b7a04e1ca76..9676fc8ca40 100644
--- a/build/integration/features/bootstrap/FeatureContext.php
+++ b/build/integration/features/bootstrap/FeatureContext.php
@@ -43,16 +43,32 @@ class FeatureContext extends BehatContext {
}
/**
- * @When /^sending "([^"]*)" to "([^"]*)"$/
- */
+ * @When /^sending "([^"]*)" to "([^"]*)"$/
+ */
public function sendingTo($verb, $url) {
$this->sendingToWith($verb, $url, null);
}
+
+ /**
+ * Parses the xml answer to get ocs response which doesn't match with
+ * http one in v1 of the api.
+ */
+ public function getOCSResponse($response){
+ return $response->xml()->meta[0]->statuscode;
+ }
+
+ /**
+ * @Then /^the OCS status code should be "([^"]*)"$/
+ */
+ public function theOCSStatusCodeShouldBe($statusCode) {
+ PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response));
+ }
+
/**
- * @Then /^the status code should be "([^"]*)"$/
+ * @Then /^the HTTP status code should be "([^"]*)"$/
*/
- public function theStatusCodeShouldBe($statusCode) {
+ public function theHTTPStatusCodeShouldBe($statusCode) {
PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
}
@@ -91,7 +107,9 @@ class FeatureContext extends BehatContext {
public function userDoesNotExist($user) {
try {
$this->userExists($user);
+ PHPUnit_Framework_Assert::fail('The user "' . $user . '" exists');
} catch (\GuzzleHttp\Exception\ClientException $ex) {
+ $this->response = $ex->getResponse();
PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
}
}
@@ -100,7 +118,7 @@ class FeatureContext extends BehatContext {
* @When /^creating the user "([^"]*)r"$/
*/
public function creatingTheUser($user) {
- $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
+ $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user" ;
$client = new Client();
$options = [];
if ($this->currentUser === 'admin') {
@@ -113,10 +131,56 @@ class FeatureContext extends BehatContext {
'password' => '123456'
]
]);
+
+ }
+
+ /**
+ * @When /^creating the group "([^"]*)r"$/
+ */
+ public function creatingTheGroup($group) {
+ $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
+ ]
+ ]);
+ }
+
+ /**
+ * @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);
+ PHPUnit_Framework_Assert::fail('The group "' . $group . '" exists');
+ } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ $this->response = $ex->getResponse();
+ PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
+ }
+ }
+
+ /**
* @When /^sending "([^"]*)" to "([^"]*)" with$/
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
@@ -138,5 +202,4 @@ class FeatureContext extends BehatContext {
$this->response = $ex->getResponse();
}
}
-
}
diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature
index 9e3d2df50bb..823fd823c5e 100644
--- a/build/integration/features/provisioning-v1.feature
+++ b/build/integration/features/provisioning-v1.feature
@@ -5,12 +5,14 @@ Feature: provisioning
Scenario: Getting an not existing user
Given As an "admin"
When sending "GET" to "/cloud/users/test"
- Then the status code should be "200"
+ Then the OCS status code should be "998"
+ And the HTTP status code should be "200"
Scenario: Listing all users
Given As an "admin"
When sending "GET" to "/cloud/users"
- Then the status code should be "200"
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
Scenario: Create a user
Given As an "admin"
@@ -18,15 +20,67 @@ Feature: provisioning
When sending "POST" to "/cloud/users" with
| userid | brand-new-user |
| password | 123456 |
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
+ And user "brand-new-user" exists
- Then the status code should be "200"
+ Scenario: Create an existing user
+ Given As an "admin"
+ And user "brand-new-user" exists
+ When sending "POST" to "/cloud/users" with
+ | userid | brand-new-user |
+ | password | 123456 |
+ Then the OCS status code should be "102"
+ And the HTTP status code should be "200"
+
+ Scenario: Get an existing user
+ Given As an "admin"
+ When sending "GET" to "/cloud/users/brand-new-user"
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
+
+
+ Scenario: Edit a user
+ Given As an "admin"
+ And user "brand-new-user" exists
+ When sending "PUT" to "/cloud/users/brand-new-user" with
+ | key | quota |
+ | value | 12MB |
+ | key | email |
+ | value | brand-new-user@gmail.com |
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
And user "brand-new-user" exists
Scenario: Delete a user
Given As an "admin"
And user "brand-new-user" exists
- When sending "POST" to "/cloud/users" with
- | userid | brand-new-user |
- Then the status code should be "200"
+ When sending "DELETE" to "/cloud/users/brand-new-user"
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
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 OCS status code should be "100"
+ And the HTTP status code should be "200"
+ And group "new-group" exists
+
+
+ Scenario: Delete a group
+ Given As an "admin"
+ And group "new-group" exists
+ When sending "DELETE" to "/cloud/groups/new-group"
+ Then the OCS status code should be "100"
+ And the HTTP status code should be "200"
+ And group "new-group" does not exist
+
+
+
diff --git a/build/integration/features/provisioning-v2.feature b/build/integration/features/provisioning-v2.feature
index 72ceed5d6a5..6140128684d 100644
--- a/build/integration/features/provisioning-v2.feature
+++ b/build/integration/features/provisioning-v2.feature
@@ -5,5 +5,5 @@ Feature: provisioning
Scenario: Getting an not existing user
Given As an "admin"
When sending "GET" to "/cloud/users/test"
- Then the status code should be "404"
+ Then the HTTP status code should be "404"