Skip to content

Commit

Permalink
API test for addUser
Browse files Browse the repository at this point in the history
  • Loading branch information
paurakhsharma committed May 2, 2018
1 parent cd2ee83 commit 322e7eb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tests/acceptance/features/apiProvisioning-v1/addUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ So that I can give people controlled individual access to resources on the ownCl
When the administrator sends a user creation request for user "brand-new-user" password "456newpwd" using the API
Then the OCS status code should be "102"
And the HTTP status code should be "200"

Scenario: Create an existing disabled user
Given user "brand-new-user" has been created
And user "brand-new-user" has been disabled
When the administrator sends a user creation request for user "brand-new-user" password "456newpwd" using the API
Then the OCS status code should be "102"
And the HTTP status code should be "200"

Scenario: Admin creates a new user and adds him directly to a group
Given group "newgroup" has been created
When the administrator sends a user creation request for user "newuser" password "456firstpwd" group "newgroup" using the API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "newuser" should belong to group "newgroup"
14 changes: 14 additions & 0 deletions tests/acceptance/features/apiProvisioning-v2/addUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ So that I can give people controlled individual access to resources on the ownCl
When the administrator sends a user creation request for user "brand-new-user" password "456newpwd" using the API
Then the OCS status code should be "400"
And the HTTP status code should be "400"

Scenario: Create an existing disabled user
Given user "brand-new-user" has been created
And user "brand-new-user" has been disabled
When the administrator sends a user creation request for user "brand-new-user" password "456newpwd" using the API
Then the OCS status code should be "400"
And the HTTP status code should be "400"

Scenario: Admin creates a new user and adds him directly to a group
Given group "newgroup" has been created
When the administrator sends a user creation request for user "newuser" password "456firstpwd" group "newgroup" using the API
Then the OCS status code should be "200"
And the HTTP status code should be "200"
And user "newuser" should belong to group "newgroup"
1 change: 0 additions & 1 deletion tests/acceptance/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ public function userSendsHTTPMethodToAPIEndpointWithBody(
$this->getBaseUrl(),
$user, $password, $verb, $url, $bodyArray, $this->apiVersion
);

}

/**
Expand Down
24 changes: 24 additions & 0 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,30 @@ public function adminSendsUserCreationRequestUsingTheAPI($user, $password) {
$this->addUserToCreatedUsersList($user, $password);
}

/**
* @When /^the administrator sends a user creation request for user "([^"]*)" password "([^"]*)" group "([^"]*)" using the API$/
*
* @param string $user
* @param string $password
* @param string $group
*
* @return void
*/
public function theAdministratorCreatesUserPasswordGroupUsingTheApi(
$user, $password, $group
) {
$bodyTable = new TableNode(
[['userid', $user], ['password', $password], ['groups[]', $group]]
);
$this->userSendsHTTPMethodToAPIEndpointWithBody(
$this->getAdminUsername(),
"POST",
"/cloud/users",
$bodyTable
);
$this->addUserToCreatedUsersList($user, $password);
}

/**
* @Then /^user "([^"]*)" should exist$/
*
Expand Down

0 comments on commit 322e7eb

Please sign in to comment.