diff --git a/tests/acceptance/features/apiProvisioning-v1/createSubAdmin.feature b/tests/acceptance/features/apiProvisioning-v1/createSubAdmin.feature index f8a3e7462f15..3b518e3d9111 100644 --- a/tests/acceptance/features/apiProvisioning-v1/createSubAdmin.feature +++ b/tests/acceptance/features/apiProvisioning-v1/createSubAdmin.feature @@ -1,4 +1,4 @@ -@api @provisioning_api-app-required @skipOnLDAP +@api @provisioning_api-app-required @skipOnLDAP @toImplementOnOCIS Feature: create a subadmin As an admin I want to be able to make a user the subadmin of a group @@ -7,7 +7,7 @@ Feature: create a subadmin Background: Given using OCS API version "1" - @smokeTest @notToImplementOnOCIS + @smokeTest Scenario: admin creates a subadmin Given user "brand-new-user" has been created with default attributes and skeleton files And group "brand-new-group" has been created @@ -16,7 +16,6 @@ Feature: create a subadmin And the HTTP status code should be "200" And user "brand-new-user" should be a subadmin of group "brand-new-group" - @notToImplementOnOCIS Scenario: admin tries to create a subadmin using a user which does not exist Given user "nonexistentuser" has been deleted And group "brand-new-group" has been created @@ -33,7 +32,6 @@ Feature: create a subadmin And the HTTP status code should be "200" And the API should not return any data - @notToImplementOnOCIS Scenario: subadmin of a group tries to make another user subadmin of their group Given these users have been created with default attributes and skeleton files: | username | diff --git a/tests/acceptance/features/apiProvisioning-v2/createSubAdmin.feature b/tests/acceptance/features/apiProvisioning-v2/createSubAdmin.feature index 8cacc47c212b..da60e28c4e64 100644 --- a/tests/acceptance/features/apiProvisioning-v2/createSubAdmin.feature +++ b/tests/acceptance/features/apiProvisioning-v2/createSubAdmin.feature @@ -1,4 +1,4 @@ -@api @provisioning_api-app-required @skipOnLDAP +@api @provisioning_api-app-required @skipOnLDAP @toImplementOnOCIS Feature: create a subadmin As an admin I want to be able to make a user the subadmin of a group @@ -7,7 +7,7 @@ Feature: create a subadmin Background: Given using OCS API version "2" - @smokeTest @notToImplementOnOCIS + @smokeTest Scenario: admin creates a subadmin Given user "brand-new-user" has been created with default attributes and skeleton files And group "brand-new-group" has been created @@ -16,7 +16,6 @@ Feature: create a subadmin And the HTTP status code should be "200" And user "brand-new-user" should be a subadmin of group "brand-new-group" - @notToImplementOnOCIS Scenario: admin tries to create a subadmin using a user which does not exist Given user "nonexistentuser" has been deleted And group "brand-new-group" has been created @@ -32,7 +31,7 @@ Feature: create a subadmin Then the OCS status code should be "400" And the HTTP status code should be "400" - @issue-31276 @notToImplementOnOCIS + @issue-31276 Scenario: subadmin of a group tries to make another user subadmin of their group Given these users have been created with default attributes and skeleton files: | username | diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 1650c3c307b4..64f82c701379 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -814,6 +814,60 @@ public function resetOldLdapConfig() { } } + /** + * Manually add skeleton files for a single user on OCIS and reva systems + * + * @param string $user + * @param string $password + * + * @return void + * @throws Exception + */ + public function manuallyAddSkeletonFilesForUser($user, $password) { + $settings = []; + $setting["userid"] = $user; + $setting["password"] = $password; + \array_push($settings, $setting); + $this->manuallyAddSkeletonFiles($settings); + } + + /** + * Manually add skeleton files on OCIS and reva systems + * + * @param array $usersAttributes + * + * @return void + * @throws Exception + */ + public function manuallyAddSkeletonFiles($usersAttributes) { + $skeletonDir = \getenv("SKELETON_DIR"); + $revaRoot = \getenv("OCIS_REVA_DATA_ROOT"); + if (!$skeletonDir) { + throw new Exception('Missing SKELETON_DIR environment variable, cannot copy skeleton files for OCIS'); + } + if (!$revaRoot && OcisHelper::getDeleteUserDataCommand() !== false) { + foreach ($usersAttributes as $userAttributes) { + OcisHelper::recurseUpload( + $this->getBaseUrl(), + $skeletonDir, + $userAttributes['userid'], + $userAttributes['password'] + ); + } + } elseif (!$revaRoot) { + throw new Exception('Missing OCIS_REVA_DATA_ROOT environment variable, cannot copy skeleton files for OCIS'); + } else { + foreach ($usersAttributes as $userAttributes) { + $user = $userAttributes['userid']; + $dataDir = $revaRoot . "data/$user/files"; + if (!\file_exists($dataDir)) { + \mkdir($dataDir, 0777, true); + } + OcisHelper::recurseCopy($skeletonDir, $dataDir); + } + } + } + /** * This function will allow us to send user creation requests in parallel. * This will be faster in comparison to waiting for each request to complete before sending another request. @@ -921,32 +975,7 @@ public function usersHaveBeenCreated( // When testing on ownCloud 10 the user is already getting whatever // skeleton dir is defined in the server-under-test. if ($skeleton && OcisHelper::isTestingOnOcis()) { - $skeletonDir = \getenv("SKELETON_DIR"); - $revaRoot = \getenv("OCIS_REVA_DATA_ROOT"); - if (!$skeletonDir) { - throw new Exception('Missing SKELETON_DIR environment variable, cannot copy skeleton files for OCIS'); - } - if (!$revaRoot && OcisHelper::getDeleteUserDataCommand() !== false) { - foreach ($usersAttributes as $userAttributes) { - OcisHelper::recurseUpload( - $this->getBaseUrl(), - $skeletonDir, - $userAttributes['userid'], - $userAttributes['password'] - ); - } - } elseif (!$revaRoot) { - throw new Exception('Missing OCIS_REVA_DATA_ROOT environment variable, cannot copy skeleton files for OCIS'); - } else { - foreach ($usersAttributes as $userAttributes) { - $user = $userAttributes['userid']; - $dataDir = $revaRoot . "data/$user/files"; - if (!\file_exists($dataDir)) { - \mkdir($dataDir, 0777, true); - } - OcisHelper::recurseCopy($skeletonDir, $dataDir); - } - } + $this->manuallyAddSkeletonFiles($usersAttributes); } if ($initialize) { @@ -1155,6 +1184,15 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv "displayname" => $displayname, "email" => $email ]; + + if (OcisHelper::isTestingOnOcis()) { + if ($email === null) { + $email = $username . '@owncloud.org'; + } + $userAttributes["username"] = $username; + $userAttributes["email"] = $email; + } + $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), "POST", @@ -1164,6 +1202,9 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv $this->addUserToCreatedUsersList( $username, $password, $displayname, $email ); + if (OcisHelper::isTestingOnOcis()) { + $this->manuallyAddSkeletonFilesForUser($username, $password); + } } /** @@ -1173,18 +1214,28 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv * @param string $password * * @return void + * @throws Exception */ public function adminSendsUserCreationRequestUsingTheProvisioningApi($user, $password) { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); - $bodyTable = new TableNode([['userid', $user], ['password', $password]]); + if (OcisHelper::isTestingOnOcis()) { + $email = $user . '@owncloud.org'; + $bodyTable = new TableNode([['userid', $user], ['password', $password], ['username', $user], ['email', $email]]); + } else { + $email = null; + $bodyTable = new TableNode([['userid', $user], ['password', $password]]); + } $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), "POST", "/cloud/users", $bodyTable ); - $this->addUserToCreatedUsersList($user, $password); + $this->addUserToCreatedUsersList($user, $password, null, $email); + if (OcisHelper::isTestingOnOcis()) { + $this->manuallyAddSkeletonFilesForUser($user, $password); + } } /** @@ -1195,22 +1246,32 @@ public function adminSendsUserCreationRequestUsingTheProvisioningApi($user, $pas * @param string $group * * @return void + * @throws Exception */ public function theAdministratorCreatesUserPasswordGroupUsingTheProvisioningApi( $user, $password, $group ) { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); - $bodyTable = new TableNode( - [['userid', $user], ['password', $password], ['groups[]', $group]] - ); + if (OcisHelper::isTestingOnOcis()) { + $email = $user . '@owncloud.org'; + $bodyTable = new TableNode([['userid', $user], ['password', $password], ['username', $user], ['email', $email], ['groups[]', $group]]); + } else { + $email = null; + $bodyTable = new TableNode( + [['userid', $user], ['password', $password], ['groups[]', $group]] + ); + } $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), "POST", "/cloud/users", $bodyTable ); - $this->addUserToCreatedUsersList($user, $password); + $this->addUserToCreatedUsersList($user, $password, null, $email); + if (OcisHelper::isTestingOnOcis()) { + $this->manuallyAddSkeletonFilesForUser($user, $password); + } } /**