Skip to content

Commit d7b4043

Browse files
committed
Add tests for addGroup and addToGroup
1 parent 6bf42d8 commit d7b4043

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

tests/acceptance/features/bootstrap/OccContext.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,34 @@ public function resetUserPasswordUsingTheOccCommand($username, $password) {
145145
);
146146
}
147147

148+
/**
149+
* @When the administrator sends a group creation request for group :group using the occ command
150+
*
151+
* @param string $group
152+
*
153+
* @return void
154+
*/
155+
public function theAdministratorSendsAGroupCreationRequestForGroupUsingTheOccCommand($group) {
156+
$this->featureContext->invokingTheCommand(
157+
"group:add $group"
158+
);
159+
$this->featureContext->addGroupToCreatedGroupsList($group);
160+
}
161+
162+
/**
163+
* @When the administrator adds the user :username to the group :group using the occ command
164+
*
165+
* @param string $username
166+
* @param string $group
167+
*
168+
* @return void
169+
*/
170+
public function theAdministratorAddsTheUserToTheGroupUsingTheOccCommand($username, $group) {
171+
$this->featureContext->invokingTheCommand(
172+
"group:add-member -m $username $group"
173+
);
174+
}
175+
148176
/**
149177
* This will run before EVERY scenario.
150178
* It will set the properties for this object.

tests/acceptance/features/bootstrap/Provisioning.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,22 @@ public function userShouldNotBelongToGroup($user, $group) {
10951095
);
10961096
}
10971097

1098+
/**
1099+
* @Then group :group should not contain user :username
1100+
*
1101+
* @param string $group
1102+
* @param string $username
1103+
*
1104+
* @return void
1105+
*/
1106+
public function groupShouldNotContainUser($group, $username) {
1107+
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/groups/$group";
1108+
$this->response = HttpRequestHelper::get(
1109+
$fullUrl, $this->getAdminUsername(), $this->getAdminPassword()
1110+
);
1111+
$this->theUsersReturnedByTheApiShouldNotInclude($username);
1112+
}
1113+
10981114
/**
10991115
* @param string $user
11001116
* @param string $group
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@cli @skipOnLDAP
2+
Feature: add group
3+
As an admin
4+
I want to be able to add groups
5+
So that I can more easily manage access to resources by groups rather than individual users
6+
7+
Scenario Outline: admin creates a group
8+
When the administrator sends a group creation request for group "<group_id>" using the occ command
9+
Then the command should have been successful
10+
And the command output should contain the text 'Created group "<group_id>"'
11+
And group "<group_id>" should exist
12+
Examples:
13+
| group_id | comment |
14+
| simplegroup | nothing special here |
15+
| España | special European characters |
16+
| नेपाली | Unicode group name |
17+
18+
Scenario: admin tries to create a group that already exists
19+
Given group "new-group" has been created
20+
When the administrator sends a group creation request for group "new-group" using the occ command
21+
Then the command should have failed with exit code 1
22+
And the command output should contain the text 'The group "new-group" already exists'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@cli @skipOnLDAP
2+
Feature: add users to group
3+
As a admin
4+
I want to be able to add users to a group
5+
So that I can give a user access to the resources of the group
6+
7+
@smokeTest
8+
Scenario Outline: adding a user to a group
9+
Given user "brand-new-user" has been created
10+
And group "<group_id>" has been created
11+
When the administrator adds the user "brand-new-user" to the group "<group_id>" using the occ command
12+
Then the command should have been successful
13+
And the command output should contain the text 'User "brand-new-user" added to group "<group_id>"'
14+
And user "brand-new-user" should belong to group "<group_id>"
15+
Examples:
16+
| group_id | comment |
17+
| simplegroup | nothing special here |
18+
| España | special European characters |
19+
| नेपाली | Unicode group name |
20+
21+
Scenario: admin tries to add user to a group which does not exist
22+
Given user "brand-new-user" has been created
23+
And group "not-group" has been deleted
24+
When the administrator adds the user "brand-new-user" to the group "not-group" using the occ command
25+
Then the command should have failed with exit code 1
26+
And the command output should contain the text 'Group "not-group" does not exist'
27+
And user "brand-new-user" should not belong to group "not-group"
28+
29+
Scenario: admin tries to add a user which does not exist to a group
30+
Given user "not-user" has been deleted
31+
And group "new-group" has been created
32+
When the administrator adds the user "not-user" to the group "new-group" using the occ command
33+
Then the command should have failed with exit code 1
34+
And the command output should contain the text 'User "not-user" could not be found - not added to group "new-group"'
35+
And group "new-group" should not contain user "not-user"

0 commit comments

Comments
 (0)