Skip to content

Commit

Permalink
Add tests for addGroup and addToGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
paurakhsharma committed Oct 8, 2018
1 parent 6bf42d8 commit c71b5d8
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@ public function resetUserPasswordUsingTheOccCommand($username, $password) {
);
}

/**
* @When the administrator sends a group creation request for group :group using the occ command
*
* @param string $group
*
* @return void
*/
public function theAdministratorSendsAGroupCreationRequestForGroupUsingTheOccCommand($group) {
$this->featureContext->invokingTheCommand(
"group:add $group"
);
}

/**
* @When the administrator adds the user :username to the group :group using the occ command
*
* @param string $username
* @param string $group
*
* @return void
*/
public function theAdministratorAddsTheUserToTheGroupUsingTheOccCommand($username, $group) {
$this->featureContext->invokingTheCommand(
"group:add-member -m $username $group"
);
}

/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
16 changes: 16 additions & 0 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,22 @@ public function userShouldNotBelongToGroup($user, $group) {
);
}

/**
* @Then group :group should not contain user :username
*
* @param string $group
* @param string $username
*
* @return void
*/
public function groupShouldNotContainUser($group, $username) {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/groups/$group";
$this->response = HttpRequestHelper::get(
$fullUrl, $this->getAdminUsername(), $this->getAdminPassword()
);
$this->theUsersReturnedByTheApiShouldNotInclude($username);
}

/**
* @param string $user
* @param string $group
Expand Down
22 changes: 22 additions & 0 deletions tests/acceptance/features/cliProvisioning/addGroup.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@cli @skipOnLDAP
Feature: add group
As an admin
I want to be able to add groups
So that I can more easily manage access to resources by groups rather than individual users

Scenario Outline: admin creates a group
When the administrator sends a group creation request for group "<group_id>" using the occ command
Then the command should have been successful
And the command output should contain the text 'Created group "<group_id>"'
And group "<group_id>" should exist
Examples:
| group_id | comment |
| simplegroup | nothing special here |
| España | special European characters |
| नेपाली | Unicode group name |

Scenario: admin tries to create a group that already exists
Given group "new-group" has been created
When the administrator sends a group creation request for group "new-group" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'The group "new-group" already exists'
35 changes: 35 additions & 0 deletions tests/acceptance/features/cliProvisioning/addToGroup.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@cli @skipOnLDAP
Feature: add users to group
As a admin
I want to be able to add users to a group
So that I can give a user access to the resources of the group

@smokeTest
Scenario Outline: adding a user to a group
Given user "brand-new-user" has been created
And group "<group_id>" has been created
When the administrator adds the user "brand-new-user" to the group "<group_id>" using the occ command
Then the command should have been successful
And the command output should contain the text 'User "brand-new-user" added to group "<group_id>"'
And user "brand-new-user" should belong to group "<group_id>"
Examples:
| group_id | comment |
| simplegroup | nothing special here |
| España | special European characters |
| नेपाली | Unicode group name |

Scenario: admin tries to add user to a group which does not exist
Given user "brand-new-user" has been created
And group "not-group" has been deleted
When the administrator adds the user "brand-new-user" to the group "not-group" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'Group "not-group" does not exist'
And user "brand-new-user" should not belong to group "not-group"

Scenario: admin tries to add a user which does not exist to a group
Given user "not-user" has been deleted
And group "new-group" has been created
When the administrator adds the user "not-user" to the group "new-group" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'User "not-user" could not be found - not added to group "new-group"'
And group "new-group" should not contain user "not-user"

0 comments on commit c71b5d8

Please sign in to comment.