From c71b5d8ec4faf66f434f41dc8e41cabf4eabaa25 Mon Sep 17 00:00:00 2001 From: paurakhsharma Date: Mon, 8 Oct 2018 16:05:14 +0545 Subject: [PATCH] Add tests for addGroup and addToGroup --- .../features/bootstrap/OccContext.php | 27 ++++++++++++++ .../features/bootstrap/Provisioning.php | 16 +++++++++ .../features/cliProvisioning/addGroup.feature | 22 ++++++++++++ .../cliProvisioning/addToGroup.feature | 35 +++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 tests/acceptance/features/cliProvisioning/addGroup.feature create mode 100644 tests/acceptance/features/cliProvisioning/addToGroup.feature diff --git a/tests/acceptance/features/bootstrap/OccContext.php b/tests/acceptance/features/bootstrap/OccContext.php index 33a83a44ae44..1202001c2ec2 100644 --- a/tests/acceptance/features/bootstrap/OccContext.php +++ b/tests/acceptance/features/bootstrap/OccContext.php @@ -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. diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 4f682ebd8a02..8c8914d4c1ec 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -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 diff --git a/tests/acceptance/features/cliProvisioning/addGroup.feature b/tests/acceptance/features/cliProvisioning/addGroup.feature new file mode 100644 index 000000000000..aefc10ba8954 --- /dev/null +++ b/tests/acceptance/features/cliProvisioning/addGroup.feature @@ -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 "" using the occ command + Then the command should have been successful + And the command output should contain the text 'Created group ""' + And group "" 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' \ No newline at end of file diff --git a/tests/acceptance/features/cliProvisioning/addToGroup.feature b/tests/acceptance/features/cliProvisioning/addToGroup.feature new file mode 100644 index 000000000000..77db62245218 --- /dev/null +++ b/tests/acceptance/features/cliProvisioning/addToGroup.feature @@ -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 "" has been created + When the administrator adds the user "brand-new-user" to the group "" 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 ""' + And user "brand-new-user" should belong to group "" + 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" \ No newline at end of file