From c0a10ca5ce61cc5c210760698766c9990221a331 Mon Sep 17 00:00:00 2001 From: Sabin Date: Fri, 11 Aug 2023 12:27:50 +0545 Subject: [PATCH 01/12] refactored the user creation given statement from provisioning to graph api added getUser steps that covers the steps for user with user light role --- ...ected-failures-localAPI-on-OCIS-storage.md | 2 +- .../assignRole.feature | 4 +- .../features/apiGraph/createUser.feature | 1 - .../features/apiGraph/editUser.feature | 31 +- .../features/apiGraph/getUser.feature | 54 +- .../bootstrap/AppConfigurationContext.php | 4 +- .../features/bootstrap/FeatureContext.php | 1 + .../features/bootstrap/GraphContext.php | 83 ++- .../features/bootstrap/Provisioning.php | 513 ++++-------------- .../acceptance/features/bootstrap/WebDav.php | 2 +- ...reateShareGroupAndUserWithSameName.feature | 8 +- .../createShareToSharesFolder.feature | 30 +- .../acceptShares.feature | 4 +- .../uploadToShare.feature | 42 +- .../coreApiWebdavProperties1/getQuota.feature | 6 +- 15 files changed, 271 insertions(+), 514 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 35217a455a0..eaddb97e877 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -90,7 +90,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/getGroup.feature:382](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L382) - [apiGraph/getGroup.feature:383](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L383) -#### [Changing user with an uppercase name gives 404 error](https://github.com/owncloud/ocis/issues/5763) +#### [Changing user with an uppercase name gives 404 error](https://github.com/owncloud/ocis/issues/7044) - [apiGraph/editUser.feature:67](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editUser.feature#L67) diff --git a/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature b/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature index cdcd2710663..c383dcebcc1 100644 --- a/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature +++ b/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature @@ -1,9 +1,9 @@ Feature: assign role As an admin, I want to assign roles to users - So that I can provide them different authority - + So that I can provide them different authority + Scenario Outline: only admin user can see all existing roles Given user "Alice" has been created with default attributes and without skeleton files And the administrator has given "Alice" the role "" using the settings api diff --git a/tests/acceptance/features/apiGraph/createUser.feature b/tests/acceptance/features/apiGraph/createUser.feature index 5e471eec8b2..3e1cf5126e1 100644 --- a/tests/acceptance/features/apiGraph/createUser.feature +++ b/tests/acceptance/features/apiGraph/createUser.feature @@ -125,7 +125,6 @@ Feature: create user Then the HTTP status code should be "200" And the Graph API response should have no role - @env-config Scenario: create user with setting OCIS assign the default user role Given the config "GRAPH_ASSIGN_DEFAULT_USER_ROLE" has been set to "true" diff --git a/tests/acceptance/features/apiGraph/editUser.feature b/tests/acceptance/features/apiGraph/editUser.feature index 93f8968a0a7..76bc48cd770 100644 --- a/tests/acceptance/features/apiGraph/editUser.feature +++ b/tests/acceptance/features/apiGraph/editUser.feature @@ -42,7 +42,7 @@ Feature: edit user | empty mail | | 400 | brian@example.com | | change to a invalid email | invalidEmail | 400 | brian@example.com | - @issue-5763 + @issue-7044 Scenario Outline: admin user can edit another user's name Given user "Carol" has been created with default attributes and without skeleton files When the user "Alice" changes the user name of user "Carol" to "" using the Graph API @@ -153,7 +153,7 @@ Feature: edit user And the user "Alice" has created a new user using the Graph API with the following settings: | userName | Carol | | displayName | Carol King | - | email | carol@example.com | + | email | carol@example.org | | password | 1234 | And the administrator has assigned the role "" to user "Carol" using the Graph API When the user "Brian" tries to change the email of user "Carol" to "newemail@example.com" using the Graph API @@ -168,7 +168,7 @@ Feature: edit user "properties": { "mail": { "type": "string", - "enum": ["carol@example.com"] + "enum": ["carol@example.org"] } } } @@ -306,18 +306,37 @@ Feature: edit user | userRole | role | | Space Admin | Space Admin | | Space Admin | User | - | Space Admin | User Light | | Space Admin | Admin | | User | Space Admin | | User | User | - | User | User Light | | User | Admin | | User Light | Space Admin | | User Light | User | - | User Light | User Light | | User Light | Admin | + Scenario Outline: normal user should not be able to reset the password of another user light user + Given the administrator has assigned the role "" to user "Brian" using the Graph API + And user "Alice" has uploaded file with content "for guest" to "/forguest.txt" + And the user "Alice" has created a new user using the Graph API with the following settings: + | userName | Carol | + | displayName | Carol King | + | email | carol@example.com | + | password | 1234 | + And the administrator has assigned the role "" to user "Carol" using the Graph API + And user "Alice" has shared file "/forguest.txt" with user "Carol" + And user "Carol" has accepted share "/forguest.txt" offered by user "Alice" + When the user "Brian" resets the password of user "Carol" to "newpassword" using the Graph API + Then the HTTP status code should be "401" + And the content of file "Shares/forguest.txt" for user "Carol" using password "1234" should be "for guest" + But user "Carol" using password "newpassword" should not be able to download file "Shares/forguest.txt" + Examples: + | userRole | role | + | Space Admin | User Light | + | User | User Light | + | User Light | User Light | + + Scenario: admin user disables another user When the user "Alice" disables user "Brian" using the Graph API Then the HTTP status code should be "200" diff --git a/tests/acceptance/features/apiGraph/getUser.feature b/tests/acceptance/features/apiGraph/getUser.feature index 0ef67b5e321..ff93b515008 100644 --- a/tests/acceptance/features/apiGraph/getUser.feature +++ b/tests/acceptance/features/apiGraph/getUser.feature @@ -506,9 +506,61 @@ Feature: get users | userRole | | Space Admin | | User | - | User Light | + Scenario: user with User Light role cannot get his/her own drive information + Given the administrator has assigned the role "User Light" to user "Brian" using the Graph API + When the user "Brian" gets his drive information using Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "displayName", + "id", + "mail", + "onPremisesSamAccountName", + "drive", + "accountEnabled" + ], + "properties": { + "displayName": { + "type": "string", + "enum": ["Brian Murphy"] + }, + "id" : { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "mail": { + "type": "string", + "enum": ["brian@example.org"] + }, + "onPremisesSamAccountName": { + "type": "string", + "enum": ["Brian"] + }, + "accountEnabled": { + "type": "boolean", + "enum": [true] + }, + "drive": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "enum": [""] + } + } + } + } + } + """ + Scenario: admin user gets the group information of a user Given the administrator has assigned the role "Admin" to user "Alice" using the Graph API And group "tea-lover" has been created diff --git a/tests/acceptance/features/bootstrap/AppConfigurationContext.php b/tests/acceptance/features/bootstrap/AppConfigurationContext.php index 6b6d8ddc3ef..3958bc82060 100644 --- a/tests/acceptance/features/bootstrap/AppConfigurationContext.php +++ b/tests/acceptance/features/bootstrap/AppConfigurationContext.php @@ -179,7 +179,7 @@ public function theUserGetsCapabilitiesCheckResponse():void { /** * @return string - * @throws Exception + * @throws Exception|GuzzleException */ public function getAdminUsernameForCapabilitiesCheck():string { if (\TestHelpers\OcisHelper::isTestingOnReva()) { @@ -190,7 +190,7 @@ public function getAdminUsernameForCapabilitiesCheck():string { $adminUsername = "PseudoAdminForRevaTest"; $createdUsers = $this->featureContext->getCreatedUsers(); if (!\array_key_exists($adminUsername, $createdUsers)) { - $this->featureContext->createUser($adminUsername); + $this->featureContext->userHasBeenCreated(["userName" => $adminUsername]); } } else { $adminUsername = $this->featureContext->getAdminUsername(); diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 142fb04d9bd..49ba1d0339f 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1341,6 +1341,7 @@ public function getJSONSchema($schemaString) { $schemaString = $this->substituteInLineCodes($schemaString); $schema = \json_decode($schemaString); Assert::assertNotNull($schema, 'schema is not valid JSON'); + return $schema; } diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index acadf6010e5..c51838ea019 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -725,38 +725,49 @@ public function theAdminHasRetrievedMembersListOfGroupUsingTheGraphApi(string $g } /** - * creates a user with provided data - * actor: the administrator + * @Given user :user has been created with default attributes and without skeleton files * * @param string $user - * @param string $password - * @param string $email - * @param string $displayName * * @return void * @throws Exception|GuzzleException */ - public function theAdminHasCreatedUser( - string $user, - string $password, - string $email, - string $displayName - ): void { - $response = GraphHelper::createUser( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - $user, - $password, - $email, - $displayName + public function userHasBeenCreatedWithDefaultAttributes( + string $user + ):void { + $this->featureContext->userHasBeenCreated(["userName" => $user]); + } + + /** + * @Given these users have been created with default attributes and without skeleton files: + * expects a table of users with the heading + * "|username|" + * + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void { + $this->featureContext->usersHaveBeenCreated($table); + } + + /** + * @Given the administrator has created a new user with the following attributes: + * @Given the user :byUser has created a new user using the Graph API with the following settings: + * + * @param string $byUser + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function theAdministratorHasCreatedANewUserWithFollowingAttributes(string $byUser, TableNode $table): void { + $rows = $table->getRowsHash(); + $this->featureContext->userHasBeenCreated( + $rows, + $byUser ); - if ($response->getStatusCode() !== 200) { - $this->throwHttpException($response, "Could not create user $user"); - } else { - $this->featureContext->setResponse($response); - } } /** @@ -795,28 +806,6 @@ public function theUserCreatesNewUser(string $user, TableNode $table): void { $this->featureContext->setResponse($response); } - /** - * @Given /^the user "([^"]*)" has created a new user using the Graph API with the following settings:$/ - * - * @param string $user - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function theUserHasCreatedANewUserUsingGraphapiWithTheFollowingSettings(string $user, TableNode $table): void { - $this->theUserCreatesNewUser( - $user, - $table - ); - $rows = $table->getRowsHash(); - $response = $this->featureContext->getResponse(); - - if ($response->getStatusCode() !== 200) { - $this->throwHttpException($response, "Could not create user '$rows[userName]'"); - } - } - /** * adds a user to a group * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index bb539b0e865..7e61d5feb5c 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -29,6 +29,7 @@ use TestHelpers\HttpRequestHelper; use TestHelpers\OcisHelper; use TestHelpers\WebDavHelper; +use TestHelpers\GraphHelper; use Laminas\Ldap\Exception\LdapException; use Laminas\Ldap\Ldap; @@ -383,125 +384,6 @@ public function theGroupShouldBeAbleToBeDeleted(string $groupname):bool { ); } - /** - * @When /^the administrator creates user "([^"]*)" using the provisioning API$/ - * - * @param string|null $user - * - * @return void - * @throws Exception - */ - public function adminCreatesUserUsingTheProvisioningApi(?string $user):void { - $this->createUser( - $user, - null, - null, - null, - true, - 'api' - ); - $this->pushToLastStatusCodesArrays(); - } - - /** - * @Given /^user "([^"]*)" has been created with default attributes in the database user backend$/ - * - * @param string|null $user - * - * @return void - * @throws Exception - */ - public function userHasBeenCreatedOnDatabaseBackend(?string $user):void { - $this->adminCreatesUserUsingTheProvisioningApi($user); - $this->userShouldExist($user); - } - - /** - * @Given /^user "([^"]*)" has been created with default attributes and (tiny|small|large)\s?skeleton files$/ - * - * @param string $user - * @param string $skeletonType - * @param boolean $skeleton - * - * @return void - * @throws Exception - */ - public function userHasBeenCreatedWithDefaultAttributes( - string $user, - string $skeletonType = "", - bool $skeleton = true - ):void { - if ($skeletonType === "") { - $skeletonType = $this->getSmallestSkeletonDirName(); - } - - $originalSkeletonPath = $this->setSkeletonDirByType($skeletonType); - - try { - $this->createUser( - $user, - null, - null, - null, - true, - null, - true, - $skeleton - ); - $this->userShouldExist($user); - } finally { - $this->setSkeletonDir($originalSkeletonPath); - } - } - - /** - * @Given /^user "([^"]*)" has been created with default attributes and without skeleton files$/ - * - * @param string $user - * - * @return void - * @throws Exception - */ - public function userHasBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(string $user):void { - $this->userHasBeenCreatedWithDefaultAttributes($user); - } - - /** - * @Given these users have been created with default attributes and without skeleton files: - * expects a table of users with the heading - * "|username|" - * - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void { - $originalSkeletonPath = $this->setSkeletonDirByType($this->getSmallestSkeletonDirName()); - try { - $this->createTheseUsers(true, true, true, $table); - } finally { - // restore skeleton directory even if user creation failed - $this->setSkeletonDir($originalSkeletonPath); - } - } - - /** - * @Given /^these users have been created without skeleton files ?(and not initialized|):$/ - * expects a table of users with the heading - * "|username|password|displayname|email|" - * password, displayname & email are optional - * - * @param TableNode $table - * @param string $doNotInitialize - * - * @return void - * @throws Exception - */ - public function theseUsersHaveBeenCreatedWithoutSkeletonFiles(TableNode $table, string $doNotInitialize):void { - $this->theseUsersHaveBeenCreated("", "", $doNotInitialize, $table); - } - /** * * @param string $path @@ -837,43 +719,34 @@ public function manuallyAddSkeletonFiles(array $usersAttributes):void { } /** + * Creates multiple users + * * 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. * - * @param boolean $initialize - * @param array|null $usersAttributes - * @param string|null $method create the user with "ldap" or "api" - * @param boolean $skeleton + * @param TableNode $table + * @param bool $useDefault * * @return void * @throws Exception * @throws GuzzleException */ public function usersHaveBeenCreated( - bool $initialize, - ?array $usersAttributes, - ?string $method = null, - ?bool $skeleton = true + TableNode $table, + bool $useDefault=true ) { + $this->verifyTableNodeColumns($table, ['username'], ['displayname', 'email', 'password']); + $table = $table->getColumnsHash(); + $users = $this->buildUsersAttributesArray($useDefault, $table); + $requests = []; $client = HttpRequestHelper::createClient( $this->getAdminUsername(), $this->getAdminPassword() ); - $useLdap = false; - $useGraph = false; - if ($method === null) { - $useLdap = $this->isTestingWithLdap(); - $useGraph = OcisHelper::isTestingWithGraphApi(); - } elseif ($method === "ldap") { - $useLdap = true; - } elseif ($method === "graph") { - $useGraph = true; - } - - foreach ($usersAttributes as $userAttributes) { - if ($useLdap) { + foreach ($users as $userAttributes) { + if ($this->isTestingWithLdap()) { $this->createLdapUser($userAttributes); } else { $attributesToCreateUser['userid'] = $userAttributes['userid']; @@ -890,81 +763,54 @@ public function usersHaveBeenCreated( } else { $attributesToCreateUser['email'] = $userAttributes['email']; } - if ($useGraph) { - $body = \TestHelpers\GraphHelper::prepareCreateUserPayload( - $attributesToCreateUser['userid'], - $attributesToCreateUser['password'], - $attributesToCreateUser['email'], - $attributesToCreateUser['displayname'] - ); - $request = \TestHelpers\GraphHelper::createRequest( - $this->getBaseUrl(), - $this->getStepLineRef(), - "POST", - 'users', - $body, - ); - } else { - // Create an OCS request for creating the user. The request is not sent to the server yet. - $request = OcsApiHelper::createOcsRequest( - $this->getBaseUrl(), - 'POST', - "/cloud/users", - $this->stepLineRef, - $attributesToCreateUser - ); - } + $body = GraphHelper::prepareCreateUserPayload( + $attributesToCreateUser['userid'], + $attributesToCreateUser['password'], + $attributesToCreateUser['email'], + $attributesToCreateUser['displayname'] + ); + $request = GraphHelper::createRequest( + $this->getBaseUrl(), + $this->getStepLineRef(), + "POST", + 'users', + $body, + ); // Add the request to the $requests array so that they can be sent in parallel. $requests[] = $request; } } $exceptionToThrow = null; - if (!$useLdap) { + if (!$this->isTestingWithLdap()) { $results = HttpRequestHelper::sendBatchRequest($requests, $client); // Check all requests to inspect failures. foreach ($results as $key => $e) { if ($e instanceof ClientException) { - if ($useGraph) { - $responseBody = $this->getJsonDecodedResponse($e->getResponse()); - $httpStatusCode = $e->getResponse()->getStatusCode(); - $graphStatusCode = $responseBody['error']['code']; - $messageText = $responseBody['error']['message']; - $exceptionToThrow = new Exception( - __METHOD__ . - " Unexpected failure when creating the user '" . - $usersAttributes[$key]['userid'] . "'" . - "\nHTTP status $httpStatusCode " . - "\nGraph status $graphStatusCode " . - "\nError message $messageText" - ); - } else { - $responseXml = $this->getResponseXml($e->getResponse(), __METHOD__); - $messageText = (string) $responseXml->xpath("/ocs/meta/message")[0]; - $ocsStatusCode = (string) $responseXml->xpath("/ocs/meta/statuscode")[0]; - $httpStatusCode = $e->getResponse()->getStatusCode(); - $reasonPhrase = $e->getResponse()->getReasonPhrase(); - $exceptionToThrow = new Exception( - __METHOD__ . " Unexpected failure when creating the user '" . - $usersAttributes[$key]['userid'] . "': HTTP status $httpStatusCode " . - "HTTP reason $reasonPhrase OCS status $ocsStatusCode " . - "OCS message $messageText" - ); - } + $responseBody = $this->getJsonDecodedResponse($e->getResponse()); + $httpStatusCode = $e->getResponse()->getStatusCode(); + $graphStatusCode = $responseBody['error']['code']; + $messageText = $responseBody['error']['message']; + $exceptionToThrow = new Exception( + __METHOD__ . + " Unexpected failure when creating the user '" . + $users[$key]['userid'] . "'" . + "\nHTTP status $httpStatusCode " . + "\nGraph status $graphStatusCode " . + "\nError message $messageText" + ); } } } // Create requests for setting displayname and email for the newly created users. // These values cannot be set while creating the user, so we have to edit the newly created user to set these values. - foreach ($usersAttributes as $userAttributes) { - if ($useGraph) { + foreach ($users as $userAttributes) { + if (!$this->isTestingWithLdap()) { // for graph api, we need to save the user id to be able to add it in some group // can be fetched with the "onPremisesSamAccountName" i.e. userid $this->graphContext->adminHasRetrievedUserUsingTheGraphApi($userAttributes['userid']); $userAttributes['id'] = $this->getJsonDecodedResponse()['id']; - } else { - $userAttributes['id'] = null; } $this->addUserToCreatedUsersList( $userAttributes['userid'], @@ -973,126 +819,17 @@ public function usersHaveBeenCreated( $userAttributes['email'], $userAttributes['id'] ); - - OcisHelper::createEOSStorageHome( - $this->getBaseUrl(), - $userAttributes['userid'], - $userAttributes['password'], - $this->getStepLineRef() - ); } if (isset($exceptionToThrow)) { throw $exceptionToThrow; } - // If the user should have skeleton files, and we are testing on OCIS - // then do some work to "manually" put the skeleton files in place. - // When testing on ownCloud 10 the user is already getting whatever - // skeleton dir is defined in the server-under-test. - if ($skeleton) { - $this->manuallyAddSkeletonFiles($usersAttributes); - } - } - - /** - * @When /^the administrator creates these users with ?(default attributes and|) skeleton files ?(but not initialized|):$/ - * - * expects a table of users with the heading - * "|username|password|displayname|email|" - * password, displayname & email are optional - * - * @param string $setDefaultAttributes - * @param string $doNotInitialize - * @param TableNode $table - * - * @return void - * @throws Exception - * @throws GuzzleException - */ - public function theAdministratorCreatesTheseUsers( - string $setDefaultAttributes, - string $doNotInitialize, - TableNode $table - ): void { - $this->verifyTableNodeColumns($table, ['username'], ['displayname', 'email', 'password']); - $table = $table->getColumnsHash(); - $setDefaultAttributes = $setDefaultAttributes !== ""; - $initialize = $doNotInitialize === ""; - $usersAttributes = $this->buildUsersAttributesArray($setDefaultAttributes, $table); - $this->usersHaveBeenCreated( - $initialize, - $usersAttributes - ); - } - - /** - * expects a table of users with the heading - * "|username|password|displayname|email|" - * password, displayname & email are optional - * - * @param boolean $setDefaultAttributes - * @param boolean $initialize - * @param boolean $skeleton - * @param TableNode $table - * - * @return void - * @throws Exception - * @throws GuzzleException - */ - public function createTheseUsers(bool $setDefaultAttributes, bool $initialize, bool $skeleton, TableNode $table):void { - $this->verifyTableNodeColumns($table, ['username'], ['displayname', 'email', 'password']); - $table = $table->getColumnsHash(); - $usersAttributes = $this->buildUsersAttributesArray($setDefaultAttributes, $table); - $this->usersHaveBeenCreated( - $initialize, - $usersAttributes, - null, - $skeleton - ); - foreach ($usersAttributes as $expectedUser) { - $this->userShouldExist($expectedUser["userid"]); - } - } - - /** - * @Given /^these users have been created with ?(default attributes and|) (tiny|small|large)\s?skeleton files ?(but not initialized|):$/ - * - * expects a table of users with the heading - * "|username|password|displayname|email|" - * password, displayname & email are optional - * - * @param string $defaultAttributesText - * @param string $skeletonType - * @param string $doNotInitialize - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function theseUsersHaveBeenCreated( - string $defaultAttributesText, - string $skeletonType, - string $doNotInitialize, - TableNode $table - ):void { - if ($skeletonType === "") { - $skeletonType = $this->getSmallestSkeletonDirName(); - } - - $originalSkeletonPath = $this->setSkeletonDirByType($skeletonType); - $setDefaultAttributes = $defaultAttributesText !== ""; - $initialize = $doNotInitialize === ""; - try { - $this->createTheseUsers($setDefaultAttributes, $initialize, true, $table); - } finally { - // The effective skeleton directory is the one when the user is initialized - // If we did not initialize the user on creation, then we need to leave - // the skeleton directory in effect so that it applies when some action - // happens later in the scenario that causes the user to be initialized. - if ($initialize) { - $this->setSkeletonDir($originalSkeletonPath); - } + foreach ($users as $user) { + Assert::assertTrue( + $this->userExists($user["userid"]), + "User '" . $user["userid"] . "' should exist but does not exist" + ); } } @@ -2380,7 +2117,6 @@ public function userRetrievesTheInformationOfUserUsingTheProvisioningApi( * @throws JsonException */ public function userShouldExist(string $user):void { - $user = $this->getActualUsername($user); Assert::assertTrue( $this->userExists($user), "User '$user' should exist but does not exist" @@ -2830,41 +2566,35 @@ public function rememberThatUserIsNotExpectedToExist(string $user):void { /** * creates a single user * - * @param string|null $user - * @param string|null $password if null, then select a password - * @param string|null $displayName - * @param string|null $email - * @param bool $initialize initialize the user skeleton files etc - * @param string|null $method how to create the user api|occ, default api - * @param bool $setDefault sets the missing values to some default - * @param bool $skeleton + * @param array $userData + * @param string|null $byUser * * @return void * @throws Exception|GuzzleException */ - public function createUser( - ?string $user, - ?string $password = null, - ?string $displayName = null, - ?string $email = null, - bool $initialize = true, - ?string $method = null, - bool $setDefault = true, - bool $skeleton = true + public function userHasBeenCreated( + array $userData, + string $byUser = null ):void { $userId = null; + + $user = $userData["userName"]; + $displayName = $userData["displayName"] ?? null; + $email = $userData["email"] ?? null; + $password = $userData["password"] ?? null; + if ($password === null) { $password = $this->getPasswordForUser($user); } - if ($displayName === null && $setDefault === true) { + if ($displayName === null) { $displayName = $this->getDisplayNameForUser($user); if ($displayName === null) { $displayName = $this->getDisplayNameForUser('regularuser'); } } - if ($email === null && $setDefault === true) { + if ($email === null) { $email = $this->getEmailAddressForUser($user); if ($email === null) { @@ -2872,61 +2602,50 @@ public function createUser( $email = \str_replace(["@", " "], "", $user) . '@owncloud.com'; } } - $user = $this->getActualUsername($user); - - if ($method === null && $this->isTestingWithLdap()) { - //guess yourself - $method = "ldap"; - } elseif (OcisHelper::isTestingWithGraphApi()) { - $method = "graph"; - } elseif ($method === null) { - $method = "api"; - } $user = \trim($user); - $method = \trim(\strtolower($method)); - switch ($method) { - case "api": - case "ldap": - $settings = []; - $setting["userid"] = $user; - $setting["displayName"] = $displayName; - $setting["password"] = $password; - $setting["email"] = $email; - $settings[] = $setting; - try { - $this->usersHaveBeenCreated( - $initialize, - $settings, - $method, - $skeleton - ); - } catch (LdapException $exception) { - throw new Exception( - __METHOD__ . " cannot create a LDAP user with provided data. Error: $exception" - ); - } - break; - case "graph": - $this->graphContext->theAdminHasCreatedUser( - $user, - $password, - $email, - $displayName, - ); - $newUser = $this->getJsonDecodedResponse(); - $userId = $newUser['id']; - break; - default: - throw new InvalidArgumentException( - __METHOD__ . " Invalid method to create a user" + + if ($this->isTestingWithLdap()) { + $settings = []; + $setting["userid"] = $user; + $setting["displayName"] = $displayName; + $setting["password"] = $password; + $setting["email"] = $email; + $settings[] = $setting; + try { + $this->createLdapUser($settings); + } catch (LdapException $exception) { + throw new Exception( + __METHOD__ . " cannot create a LDAP user with provided data. Error: $exception" ); + } + } else { + $reqUser = $byUser ? $this->getActualUsername($byUser) : $this->getAdminUsername(); + $response = GraphHelper::createUser( + $this->getBaseUrl(), + $this->getStepLineRef(), + $reqUser, + $this->getPasswordForUser($reqUser), + $user, + $password, + $email, + $displayName, + ); + Assert::assertEquals( + 200, + $response->getStatusCode(), + __METHOD__ . " cannot create user '$user' using Graph API.\nResponse:" . + json_encode($this->getJsonDecodedResponse($response)) + ); + $userId = $this->getJsonDecodedResponse($response)['id']; } $this->addUserToCreatedUsersList($user, $password, $displayName, $email, $userId); - if ($initialize) { - $this->initializeUser($user, $password); - } + + Assert::assertTrue( + $this->userExists($user), + "User '$user' should exist but does not exist" + ); } /** @@ -2976,46 +2695,24 @@ public function cleanupGroup(string $group):void { } /** - * @param string|null $user + * @param string $user * * @return bool * @throws JsonException */ - public function userExists(?string $user):bool { - // in OCIS there is no admin user and in oC10 there are issues when - // sending the username in lowercase in the auth but in uppercase in - // the URL see https://github.com/owncloud/core/issues/36822 - $user = $this->getActualUsername($user); - // In OCIS an intermittent issue restricts users to list their own account - // So use admin account to list the user - // https://github.com/owncloud/ocis/issues/820 - // The special code can be reverted once the issue is fixed - if (OcisHelper::isTestingParallelDeployment()) { - $requestingUser = $this->getActualUsername($user); - $requestingPassword = $this->getPasswordForUser($user); - } elseif (OcisHelper::isTestingWithGraphApi()) { - $requestingUser = $this->getAdminUsername(); - $requestingPassword = $this->getAdminPassword(); - } elseif (!OcisHelper::isTestingOnReva()) { - $requestingUser = 'moss'; - $requestingPassword = 'vista'; - } else { - $requestingUser = $this->getActualUsername($user); - $requestingPassword = $this->getPasswordForUser($requestingUser); - } - - $path = (OcisHelper::isTestingWithGraphApi()) + public function userExists(string $user):bool { + $path = (!OcisHelper::isTestingOnReva()) ? "/graph/v1.0" : "/ocs/v2.php/cloud"; $fullUrl = $this->getBaseUrl() . $path . "/users/$user"; - $this->response = HttpRequestHelper::get( + $response = HttpRequestHelper::get( $fullUrl, $this->getStepLineRef(), - $requestingUser, - $requestingPassword + $this->getAdminUsername(), + $this->getAdminPassword() ); - if ($this->response->getStatusCode() >= 400) { + if ($response->getStatusCode() >= 400) { return false; } return true; @@ -5542,7 +5239,7 @@ private function setSkeletonDirByType(string $skeletonType): string { * @return string skeleton folder before the change * @throws Exception */ - private function setSkeletonDir(string $skeletonDir): string { + public function setSkeletonDir(string $skeletonDir): string { $originalSkeletonPath = \getenv("SKELETON_DIR"); if ($skeletonDir !== '') { \putenv("SKELETON_DIR=" . $skeletonDir); diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index bcb511c7db4..08bd2507c7c 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -74,7 +74,7 @@ trait WebDav { /** * response content parsed into a SimpleXMLElement */ - private ?SimpleXMLElement $responseXmlObject; + private ?SimpleXMLElement $responseXmlObject = null; private int $httpRequestTimeout = 0; diff --git a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareGroupAndUserWithSameName.feature b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareGroupAndUserWithSameName.feature index 7a8b3db185e..39b94e112a7 100644 --- a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareGroupAndUserWithSameName.feature +++ b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareGroupAndUserWithSameName.feature @@ -8,7 +8,7 @@ Feature: sharing works when a username and group name are the same Scenario: creating a new share with user and a group having same name - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | Brian | | Carol | @@ -30,7 +30,7 @@ Feature: sharing works when a username and group name are the same Scenario: creating a new share with group and a user having same name - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | Brian | | Carol | @@ -52,7 +52,7 @@ Feature: sharing works when a username and group name are the same Scenario: creating a new share with user and a group having same name but different case - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | Brian | | Carol | @@ -74,7 +74,7 @@ Feature: sharing works when a username and group name are the same Scenario: creating a new share with group and a user having same name but different case - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | Brian | | Carol | diff --git a/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature b/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature index 039dd1ab75e..c2408a0ffaa 100644 --- a/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature +++ b/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature @@ -398,7 +398,7 @@ Feature: sharing Scenario: share with user when username contains capital letters - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | brian | And user "Alice" has uploaded file with content "Random data" to "/randomfile.txt" @@ -415,12 +415,12 @@ Feature: sharing Then the OCS status code should be "100" And the HTTP status code should be "200" And user "brian" should see the following elements - | /Shares/randomfile.txt | + | /Shares/randomfile.txt | And the content of file "Shares/randomfile.txt" for user "brian" should be "Random data" Scenario: creating a new share with user of a group when username contains capital letters - Given these users have been created without skeleton files: + Given these users have been created with default attributes and without skeleton files: | username | | Brian | And group "grp1" has been created @@ -571,7 +571,7 @@ Feature: sharing And user "Carol" has accepted share "/userOneFolder" offered by user "Brian" When user "Carol" shares folder "/Shares/userOneFolder" with user "Brian" using the sharing API Then the HTTP status code should be "200" -# Then the HTTP status code should be "405" + # Then the HTTP status code should be "405" And the sharing API should report to user "Brian" that no shares are in the pending state And as "Brian" folder "/Shares/userOneFolder" should not exist @@ -589,7 +589,7 @@ Feature: sharing And user "Carol" has accepted share "/userOneFolder" offered by user "Brian" When user "Carol" shares folder "/Shares/userOneFolder" with user "Alice" using the sharing API Then the HTTP status code should be "200" -# Then the HTTP status code should be "405" + # Then the HTTP status code should be "405" And the sharing API should report to user "Alice" that no shares are in the pending state And as "Alice" folder "/Shares/userOneFolder" should not exist @@ -610,7 +610,7 @@ Feature: sharing And user "David" has accepted share "/userOneFolder" offered by user "Brian" When user "David" shares folder "/Shares/userOneFolder" with user "Carol" using the sharing API Then the HTTP status code should be "200" -# Then the HTTP status code should be "405" + # Then the HTTP status code should be "405" And the sharing API should report to user "Carol" that no shares are in the pending state And as "Carol" folder "/Shares/userOneFolder" should not exist @@ -624,17 +624,17 @@ Feature: sharing Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" sharing with user "Brian" should include - | share_with | %username% | - | share_with_displayname | %displayname% | + | share_with | %username% | + | share_with_displayname | %displayname% | | file_target | /Shares/renamed.txt | | path | /renamed.txt | - | permissions | share,read,update | - | uid_owner | %username% | - | displayname_owner | %displayname% | - | item_type | file | - | mimetype | text/plain | - | storage_id | ANY_VALUE | - | share_type | user | + | permissions | share,read,update | + | uid_owner | %username% | + | displayname_owner | %displayname% | + | item_type | file | + | mimetype | text/plain | + | storage_id | ANY_VALUE | + | share_type | user | When user "Brian" accepts share "/renamed.txt" offered by user "Alice" using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" diff --git a/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature b/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature index a06e61813f5..c7d0b88ec88 100644 --- a/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature +++ b/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature @@ -230,7 +230,7 @@ Feature: accept/decline shares coming from internal users Then the OCS status code should be "100" And the HTTP status code should be "200" And the sharing API should report to user "Brian" that these shares are in the pending state - | path | + | path | | /Shares/PARENT/ | And the sharing API should report that no shares are shared with user "Alice" @@ -419,7 +419,7 @@ Feature: accept/decline shares coming from internal users Scenario: user shares folder with matching folder name to a user before that user has logged in - Given these users have been created without skeleton files and not initialized: + Given these users have been created with default attributes and without skeleton files: | username | | David | And user "Alice" has uploaded file with content "uploaded content" to "/PARENT/abc.txt" diff --git a/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature b/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature index 8f8e540f3fd..5cf2752ff18 100644 --- a/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature +++ b/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature @@ -57,11 +57,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -85,11 +85,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -109,11 +109,11 @@ Feature: sharing When user "Brian" uploads file "filesForUpload/textfile.txt" to "/Shares/FOLDER/textfile.txt" using the WebDAV API Then the HTTP status code should be "201" And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -135,11 +135,11 @@ Feature: sharing When user "Brian" uploads file "filesForUpload/textfile.txt" to "/Shares/FOLDER/textfile.txt" using the WebDAV API Then the HTTP status code should be "201" And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -158,11 +158,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/myfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -171,7 +171,7 @@ Feature: sharing @skipOnGraph Scenario Outline: uploading to a user shared folder with read/write permission when the sharer has insufficient quota does not work Given using DAV path - And user "Brian" has been created with default attributes and small skeleton files + And user "Brian" has been created with default attributes and without skeleton files And user "Alice" has created folder "FOLDER" And user "Alice" has created a share with settings | path | FOLDER | diff --git a/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature b/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature index fec64b8198c..09505c6291e 100644 --- a/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature +++ b/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature @@ -6,7 +6,7 @@ Feature: get quota Background: Given using OCS API version "1" - And user "Alice" has been created with default attributes and small skeleton files + And user "Alice" has been created with default attributes and without skeleton files Scenario Outline: retrieving folder quota when no quota is set @@ -35,7 +35,7 @@ Feature: get quota Scenario Outline: retrieving folder quota of shared folder with quota when no quota is set for recipient Given using DAV path - And user "Brian" has been created with default attributes and small skeleton files + And user "Brian" has been created with default attributes and without skeleton files And user "Alice" has been given unlimited quota And the quota of user "Brian" has been set to "10 MB" And user "Brian" has created folder "/testquota" @@ -74,7 +74,7 @@ Feature: get quota Scenario Outline: retrieving folder quota when quota is set and a file was received Given using DAV path - And user "Brian" has been created with default attributes and small skeleton files + And user "Brian" has been created with default attributes and without skeleton files And the quota of user "Brian" has been set to "1 KB" And user "Alice" has uploaded file "/Alice.txt" of size 93 bytes And user "Alice" has shared file "Alice.txt" with user "Brian" From 76762945b4262dd61cf27f325b4374a1016cac77 Mon Sep 17 00:00:00 2001 From: Sabin Date: Fri, 18 Aug 2023 11:34:12 +0545 Subject: [PATCH 02/12] added userlight step tests to check drive information and updated expected failure files --- ...ected-failures-localAPI-on-OCIS-storage.md | 24 +++--- .../features/apiGraph/getUser.feature | 80 +++++++++++++++++-- 2 files changed, 86 insertions(+), 18 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index eaddb97e877..cf3cbecca99 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -71,18 +71,18 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/getUser.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L91) - [apiGraph/getUser.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L92) - [apiGraph/getUser.feature:93](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L93) -- [apiGraph/getUser.feature:606](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L606) -- [apiGraph/getUser.feature:607](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L607) -- [apiGraph/getUser.feature:608](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L608) -- [apiGraph/getUser.feature:609](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L609) -- [apiGraph/getUser.feature:610](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L610) -- [apiGraph/getUser.feature:611](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L611) -- [apiGraph/getUser.feature:612](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L612) -- [apiGraph/getUser.feature:613](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L613) -- [apiGraph/getUser.feature:614](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L614) -- [apiGraph/getUser.feature:615](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L615) -- [apiGraph/getUser.feature:616](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L616) -- [apiGraph/getUser.feature:617](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L617) +- [apiGraph/getUser.feature:659](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L659) +- [apiGraph/getUser.feature:660](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L660) +- [apiGraph/getUser.feature:661](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L661) +- [apiGraph/getUser.feature:662](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L662) +- [apiGraph/getUser.feature:663](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L663) +- [apiGraph/getUser.feature:664](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L664) +- [apiGraph/getUser.feature:665](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L665) +- [apiGraph/getUser.feature:666](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L666) +- [apiGraph/getUser.feature:667](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L667) +- [apiGraph/getUser.feature:668](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L668) +- [apiGraph/getUser.feature:669](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L669) +- [apiGraph/getUser.feature:670](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L670) #### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604) diff --git a/tests/acceptance/features/apiGraph/getUser.feature b/tests/acceptance/features/apiGraph/getUser.feature index ff93b515008..6197487f6bb 100644 --- a/tests/acceptance/features/apiGraph/getUser.feature +++ b/tests/acceptance/features/apiGraph/getUser.feature @@ -381,7 +381,7 @@ Feature: get users """ - Scenario Outline: non-admin user gets his/her own drive information + Scenario Outline: user gets his/her own information along with drive information Given the administrator has assigned the role "" to user "Brian" using the Graph API When the user "Brian" gets his drive information using Graph API Then the HTTP status code should be "200" @@ -504,11 +504,12 @@ Feature: get users """ Examples: | userRole | + | Admin | | Space Admin | | User | - Scenario: user with User Light role cannot get his/her own drive information + Scenario: user with User Light role gets his/her own information along with drive information Given the administrator has assigned the role "User Light" to user "Brian" using the Graph API When the user "Brian" gets his drive information using Graph API Then the HTTP status code should be "200" @@ -802,7 +803,6 @@ Feature: get users And the JSON data of the response should not contain the user "Alice Hansen" in the item 'value' - Scenario: admin user gets all users of two groups Given the administrator has assigned the role "Admin" to user "Alice" using the Graph API And user "Carol" has been created with default attributes and without skeleton files @@ -1156,12 +1156,47 @@ Feature: get users | Admin | Admin | | Admin | Space Admin | | Admin | User | - | Admin | User Light | | Space Admin | Admin | | Space Admin | Space Admin | | Space Admin | User | - | Space Admin | User Light | + Scenario Outline: admin user gets the drive information of a user with user light role + Given the administrator has assigned the role "" to user "Alice" using the Graph API + And the administrator has assigned the role "" to user "Brian" using the Graph API + When user "Alice" gets the personal drive information of user "Brian" using Graph API + Then the HTTP status code should be "404" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": ["itemNotFound"] + }, + "message": { + "type": "string", + "enum": ["no drive returned from storage"] + } + } + } + } + } + """ + Examples: + | user-role-1 | user-role-2 | + | Admin | User Light | + | Space Admin | User Light | Scenario Outline: non-admin user tries to get drive information of other user with different user role Given the administrator has assigned the role "" to user "Alice" using the Graph API @@ -1304,4 +1339,37 @@ Feature: get users | Admin | | Space Admin | | User | - | User Light | + + + Scenario: user with User Light role tries to get his/her own drive information + Given the administrator has assigned the role "User Light" to user "Alice" using the Graph API + When user "Alice" gets own personal drive information using Graph API + Then the HTTP status code should be "404" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": ["itemNotFound"] + }, + "message": { + "type": "string", + "enum": ["no drive returned from storage"] + } + } + } + } + } + """ From d445f9e2868c4f29fcc0504cc0c341ca51415932 Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 21 Aug 2023 09:59:52 +0545 Subject: [PATCH 03/12] added usercreation initiation code --- tests/acceptance/features/bootstrap/Provisioning.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 7e61d5feb5c..63cb47b0c9d 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -831,6 +831,9 @@ public function usersHaveBeenCreated( "User '" . $user["userid"] . "' should exist but does not exist" ); } + foreach ($users as $user) { + $this->initializeUser($user['userid'], $user['password']); + } } /** @@ -2646,6 +2649,8 @@ public function userHasBeenCreated( $this->userExists($user), "User '$user' should exist but does not exist" ); + + $this->initializeUser($user, $password); } /** From d71836838c5d83bd591c491ed2293e28a6f49242 Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 21 Aug 2023 14:16:19 +0545 Subject: [PATCH 04/12] deleted seperate tests for user light role --- .../features/apiGraph/getUser.feature | 128 +----------------- 1 file changed, 4 insertions(+), 124 deletions(-) diff --git a/tests/acceptance/features/apiGraph/getUser.feature b/tests/acceptance/features/apiGraph/getUser.feature index 6197487f6bb..e9f2cd0d0a8 100644 --- a/tests/acceptance/features/apiGraph/getUser.feature +++ b/tests/acceptance/features/apiGraph/getUser.feature @@ -507,61 +507,9 @@ Feature: get users | Admin | | Space Admin | | User | + | User Light | - Scenario: user with User Light role gets his/her own information along with drive information - Given the administrator has assigned the role "User Light" to user "Brian" using the Graph API - When the user "Brian" gets his drive information using Graph API - Then the HTTP status code should be "200" - And the JSON data of the response should match - """ - { - "type": "object", - "required": [ - "displayName", - "id", - "mail", - "onPremisesSamAccountName", - "drive", - "accountEnabled" - ], - "properties": { - "displayName": { - "type": "string", - "enum": ["Brian Murphy"] - }, - "id" : { - "type": "string", - "pattern": "^%user_id_pattern%$" - }, - "mail": { - "type": "string", - "enum": ["brian@example.org"] - }, - "onPremisesSamAccountName": { - "type": "string", - "enum": ["Brian"] - }, - "accountEnabled": { - "type": "boolean", - "enum": [true] - }, - "drive": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string", - "enum": [""] - } - } - } - } - } - """ - Scenario: admin user gets the group information of a user Given the administrator has assigned the role "Admin" to user "Alice" using the Graph API And group "tea-lover" has been created @@ -1156,48 +1104,13 @@ Feature: get users | Admin | Admin | | Admin | Space Admin | | Admin | User | + | Admin | User Light | | Space Admin | Admin | | Space Admin | Space Admin | | Space Admin | User | - - Scenario Outline: admin user gets the drive information of a user with user light role - Given the administrator has assigned the role "" to user "Alice" using the Graph API - And the administrator has assigned the role "" to user "Brian" using the Graph API - When user "Alice" gets the personal drive information of user "Brian" using Graph API - Then the HTTP status code should be "404" - And the JSON data of the response should match - """ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "string", - "enum": ["itemNotFound"] - }, - "message": { - "type": "string", - "enum": ["no drive returned from storage"] - } - } - } - } - } - """ - Examples: - | user-role-1 | user-role-2 | - | Admin | User Light | | Space Admin | User Light | + Scenario Outline: non-admin user tries to get drive information of other user with different user role Given the administrator has assigned the role "" to user "Alice" using the Graph API And the administrator has assigned the role "" to user "Brian" using the Graph API @@ -1339,37 +1252,4 @@ Feature: get users | Admin | | Space Admin | | User | - - - Scenario: user with User Light role tries to get his/her own drive information - Given the administrator has assigned the role "User Light" to user "Alice" using the Graph API - When user "Alice" gets own personal drive information using Graph API - Then the HTTP status code should be "404" - And the JSON data of the response should match - """ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "object", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "string", - "enum": ["itemNotFound"] - }, - "message": { - "type": "string", - "enum": ["no drive returned from storage"] - } - } - } - } - } - """ + | User Light | From f2080ea0c8fc94d37f621d24cc9bb5587e2a6fcc Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 21 Aug 2023 14:47:14 +0545 Subject: [PATCH 05/12] remove unnecesary changes --- ...ected-failures-localAPI-on-OCIS-storage.md | 24 +++++------ .../assignRole.feature | 4 +- .../features/apiGraph/createUser.feature | 1 + .../features/apiGraph/editUser.feature | 29 +++---------- .../features/bootstrap/FeatureContext.php | 1 - .../uploadToShare.feature | 42 +++++++++---------- 6 files changed, 41 insertions(+), 60 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index cf3cbecca99..eaddb97e877 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -71,18 +71,18 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/getUser.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L91) - [apiGraph/getUser.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L92) - [apiGraph/getUser.feature:93](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L93) -- [apiGraph/getUser.feature:659](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L659) -- [apiGraph/getUser.feature:660](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L660) -- [apiGraph/getUser.feature:661](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L661) -- [apiGraph/getUser.feature:662](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L662) -- [apiGraph/getUser.feature:663](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L663) -- [apiGraph/getUser.feature:664](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L664) -- [apiGraph/getUser.feature:665](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L665) -- [apiGraph/getUser.feature:666](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L666) -- [apiGraph/getUser.feature:667](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L667) -- [apiGraph/getUser.feature:668](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L668) -- [apiGraph/getUser.feature:669](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L669) -- [apiGraph/getUser.feature:670](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L670) +- [apiGraph/getUser.feature:606](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L606) +- [apiGraph/getUser.feature:607](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L607) +- [apiGraph/getUser.feature:608](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L608) +- [apiGraph/getUser.feature:609](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L609) +- [apiGraph/getUser.feature:610](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L610) +- [apiGraph/getUser.feature:611](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L611) +- [apiGraph/getUser.feature:612](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L612) +- [apiGraph/getUser.feature:613](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L613) +- [apiGraph/getUser.feature:614](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L614) +- [apiGraph/getUser.feature:615](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L615) +- [apiGraph/getUser.feature:616](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L616) +- [apiGraph/getUser.feature:617](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L617) #### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604) diff --git a/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature b/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature index c383dcebcc1..cdcd2710663 100644 --- a/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature +++ b/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature @@ -1,9 +1,9 @@ Feature: assign role As an admin, I want to assign roles to users - So that I can provide them different authority + So that I can provide them different authority + - Scenario Outline: only admin user can see all existing roles Given user "Alice" has been created with default attributes and without skeleton files And the administrator has given "Alice" the role "" using the settings api diff --git a/tests/acceptance/features/apiGraph/createUser.feature b/tests/acceptance/features/apiGraph/createUser.feature index 3e1cf5126e1..5e471eec8b2 100644 --- a/tests/acceptance/features/apiGraph/createUser.feature +++ b/tests/acceptance/features/apiGraph/createUser.feature @@ -125,6 +125,7 @@ Feature: create user Then the HTTP status code should be "200" And the Graph API response should have no role + @env-config Scenario: create user with setting OCIS assign the default user role Given the config "GRAPH_ASSIGN_DEFAULT_USER_ROLE" has been set to "true" diff --git a/tests/acceptance/features/apiGraph/editUser.feature b/tests/acceptance/features/apiGraph/editUser.feature index 76bc48cd770..7168269ed57 100644 --- a/tests/acceptance/features/apiGraph/editUser.feature +++ b/tests/acceptance/features/apiGraph/editUser.feature @@ -153,7 +153,7 @@ Feature: edit user And the user "Alice" has created a new user using the Graph API with the following settings: | userName | Carol | | displayName | Carol King | - | email | carol@example.org | + | email | carol@example.com | | password | 1234 | And the administrator has assigned the role "" to user "Carol" using the Graph API When the user "Brian" tries to change the email of user "Carol" to "newemail@example.com" using the Graph API @@ -168,7 +168,7 @@ Feature: edit user "properties": { "mail": { "type": "string", - "enum": ["carol@example.org"] + "enum": ["carol@example.com"] } } } @@ -306,37 +306,18 @@ Feature: edit user | userRole | role | | Space Admin | Space Admin | | Space Admin | User | + | Space Admin | User Light | | Space Admin | Admin | | User | Space Admin | | User | User | + | User | User Light | | User | Admin | | User Light | Space Admin | | User Light | User | + | User Light | User Light | | User Light | Admin | - Scenario Outline: normal user should not be able to reset the password of another user light user - Given the administrator has assigned the role "" to user "Brian" using the Graph API - And user "Alice" has uploaded file with content "for guest" to "/forguest.txt" - And the user "Alice" has created a new user using the Graph API with the following settings: - | userName | Carol | - | displayName | Carol King | - | email | carol@example.com | - | password | 1234 | - And the administrator has assigned the role "" to user "Carol" using the Graph API - And user "Alice" has shared file "/forguest.txt" with user "Carol" - And user "Carol" has accepted share "/forguest.txt" offered by user "Alice" - When the user "Brian" resets the password of user "Carol" to "newpassword" using the Graph API - Then the HTTP status code should be "401" - And the content of file "Shares/forguest.txt" for user "Carol" using password "1234" should be "for guest" - But user "Carol" using password "newpassword" should not be able to download file "Shares/forguest.txt" - Examples: - | userRole | role | - | Space Admin | User Light | - | User | User Light | - | User Light | User Light | - - Scenario: admin user disables another user When the user "Alice" disables user "Brian" using the Graph API Then the HTTP status code should be "200" diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 49ba1d0339f..142fb04d9bd 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1341,7 +1341,6 @@ public function getJSONSchema($schemaString) { $schemaString = $this->substituteInLineCodes($schemaString); $schema = \json_decode($schemaString); Assert::assertNotNull($schema, 'schema is not valid JSON'); - return $schema; } diff --git a/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature b/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature index 5cf2752ff18..8f8e540f3fd 100644 --- a/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature +++ b/tests/acceptance/features/coreApiShareOperationsToShares2/uploadToShare.feature @@ -57,11 +57,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -85,11 +85,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -109,11 +109,11 @@ Feature: sharing When user "Brian" uploads file "filesForUpload/textfile.txt" to "/Shares/FOLDER/textfile.txt" using the WebDAV API Then the HTTP status code should be "201" And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -135,11 +135,11 @@ Feature: sharing When user "Brian" uploads file "filesForUpload/textfile.txt" to "/Shares/FOLDER/textfile.txt" using the WebDAV API Then the HTTP status code should be "201" And the content of file "/FOLDER/textfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -158,11 +158,11 @@ Feature: sharing And the following headers should match these regular expressions for user "Brian" | ETag | /^"[a-f0-9:\.]{1,32}"$/ | And the content of file "/myfile.txt" for user "Alice" should be: - """ - This is a testfile. + """ + This is a testfile. - Cheers. - """ + Cheers. + """ Examples: | dav-path-version | | old | @@ -171,7 +171,7 @@ Feature: sharing @skipOnGraph Scenario Outline: uploading to a user shared folder with read/write permission when the sharer has insufficient quota does not work Given using DAV path - And user "Brian" has been created with default attributes and without skeleton files + And user "Brian" has been created with default attributes and small skeleton files And user "Alice" has created folder "FOLDER" And user "Alice" has created a share with settings | path | FOLDER | From a55f8c924a0063d6e16bb49098504d8038c7b26f Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 21 Aug 2023 15:01:32 +0545 Subject: [PATCH 06/12] add user not initialize step --- .../expected-failures-localAPI-on-OCIS-storage.md | 2 +- .../acceptance/features/bootstrap/GraphContext.php | 14 ++++++++++++++ .../acceptance/features/bootstrap/Provisioning.php | 11 ++++++++--- .../acceptShares.feature | 4 ++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index eaddb97e877..71e071abce8 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -71,7 +71,6 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/getUser.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L91) - [apiGraph/getUser.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L92) - [apiGraph/getUser.feature:93](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L93) -- [apiGraph/getUser.feature:606](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L606) - [apiGraph/getUser.feature:607](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L607) - [apiGraph/getUser.feature:608](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L608) - [apiGraph/getUser.feature:609](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L609) @@ -83,6 +82,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/getUser.feature:615](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L615) - [apiGraph/getUser.feature:616](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L616) - [apiGraph/getUser.feature:617](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L617) +- [apiGraph/getUser.feature:618](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L618) #### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604) diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index c51838ea019..80815ef928b 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -738,6 +738,20 @@ public function userHasBeenCreatedWithDefaultAttributes( $this->featureContext->userHasBeenCreated(["userName" => $user]); } + /** + * @Given these users have been created without skeleton files and not initialized: + * + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized( + TableNode $table + ):void { + $this->featureContext->usersHaveBeenCreated($table, true, false); + } + /** * @Given these users have been created with default attributes and without skeleton files: * expects a table of users with the heading diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 63cb47b0c9d..ec6e542b904 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -726,6 +726,7 @@ public function manuallyAddSkeletonFiles(array $usersAttributes):void { * * @param TableNode $table * @param bool $useDefault + * @param bool $initialize * * @return void * @throws Exception @@ -733,7 +734,8 @@ public function manuallyAddSkeletonFiles(array $usersAttributes):void { */ public function usersHaveBeenCreated( TableNode $table, - bool $useDefault=true + bool $useDefault=true, + bool $initialize=true ) { $this->verifyTableNodeColumns($table, ['username'], ['displayname', 'email', 'password']); $table = $table->getColumnsHash(); @@ -831,8 +833,11 @@ public function usersHaveBeenCreated( "User '" . $user["userid"] . "' should exist but does not exist" ); } - foreach ($users as $user) { - $this->initializeUser($user['userid'], $user['password']); + + if ($initialize) { + foreach ($users as $user) { + $this->initializeUser($user['userid'], $user['password']); + } } } diff --git a/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature b/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature index c7d0b88ec88..a06e61813f5 100644 --- a/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature +++ b/tests/acceptance/features/coreApiShareManagementToShares/acceptShares.feature @@ -230,7 +230,7 @@ Feature: accept/decline shares coming from internal users Then the OCS status code should be "100" And the HTTP status code should be "200" And the sharing API should report to user "Brian" that these shares are in the pending state - | path | + | path | | /Shares/PARENT/ | And the sharing API should report that no shares are shared with user "Alice" @@ -419,7 +419,7 @@ Feature: accept/decline shares coming from internal users Scenario: user shares folder with matching folder name to a user before that user has logged in - Given these users have been created with default attributes and without skeleton files: + Given these users have been created without skeleton files and not initialized: | username | | David | And user "Alice" has uploaded file with content "uploaded content" to "/PARENT/abc.txt" From 0ddcfea89ed9249ff8820b5e6de567112e8fe53a Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 21 Aug 2023 16:58:14 +0545 Subject: [PATCH 07/12] corrected the testcode --- tests/acceptance/features/bootstrap/WebDav.php | 2 -- .../acceptance/features/coreApiVersions/fileVersions.feature | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 08bd2507c7c..1e5809cb632 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -2390,8 +2390,6 @@ public function userUploadsAFileToWithAllMechanismsExceptNewChunking( false, 'new' ); - - $this->pushToLastStatusCodesArrays(); } /** diff --git a/tests/acceptance/features/coreApiVersions/fileVersions.feature b/tests/acceptance/features/coreApiVersions/fileVersions.feature index 40e5b48bf18..92124d2fae1 100644 --- a/tests/acceptance/features/coreApiVersions/fileVersions.feature +++ b/tests/acceptance/features/coreApiVersions/fileVersions.feature @@ -17,7 +17,7 @@ Feature: dav-versions Scenario: upload file and no version is available using various chunking methods (except new chunking) When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API - Then the HTTP status code should be "200" + Then the HTTP status code of all upload responses should be "201" And the version folder of file "/davtest.txt-olddav-regular" for user "Alice" should contain "0" elements And the version folder of file "/davtest.txt-newdav-regular" for user "Alice" should contain "0" elements And the version folder of file "/davtest.txt-olddav-oldchunking" for user "Alice" should contain "0" elements @@ -34,7 +34,7 @@ Feature: dav-versions Scenario: upload a file twice and versions are available using various chunking methods (except new chunking) When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API And user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API - Then the HTTP status code of responses on all endpoints should be "200" + Then the HTTP status code of all upload responses should be between "201" and "204" And the version folder of file "/davtest.txt-olddav-regular" for user "Alice" should contain "1" element And the version folder of file "/davtest.txt-newdav-regular" for user "Alice" should contain "1" element And the version folder of file "/davtest.txt-olddav-oldchunking" for user "Alice" should contain "1" element From bc91ca25596fd091988327f8b6650078d6816efc Mon Sep 17 00:00:00 2001 From: Sabin Date: Tue, 22 Aug 2023 12:53:17 +0545 Subject: [PATCH 08/12] moved the steps from graph to provisioning file --- .../features/bootstrap/GraphContext.php | 60 ------------------ .../features/bootstrap/Provisioning.php | 62 +++++++++++++++++++ 2 files changed, 62 insertions(+), 60 deletions(-) diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 80815ef928b..13a8344e0ad 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -724,66 +724,6 @@ public function theAdminHasRetrievedMembersListOfGroupUsingTheGraphApi(string $g return $this->getArrayOfUsersResponded($this->listGroupMembers($group)); } - /** - * @Given user :user has been created with default attributes and without skeleton files - * - * @param string $user - * - * @return void - * @throws Exception|GuzzleException - */ - public function userHasBeenCreatedWithDefaultAttributes( - string $user - ):void { - $this->featureContext->userHasBeenCreated(["userName" => $user]); - } - - /** - * @Given these users have been created without skeleton files and not initialized: - * - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized( - TableNode $table - ):void { - $this->featureContext->usersHaveBeenCreated($table, true, false); - } - - /** - * @Given these users have been created with default attributes and without skeleton files: - * expects a table of users with the heading - * "|username|" - * - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void { - $this->featureContext->usersHaveBeenCreated($table); - } - - /** - * @Given the administrator has created a new user with the following attributes: - * @Given the user :byUser has created a new user using the Graph API with the following settings: - * - * @param string $byUser - * @param TableNode $table - * - * @return void - * @throws Exception|GuzzleException - */ - public function theAdministratorHasCreatedANewUserWithFollowingAttributes(string $byUser, TableNode $table): void { - $rows = $table->getRowsHash(); - $this->featureContext->userHasBeenCreated( - $rows, - $byUser - ); - } - /** * @When /^the user "([^"]*)" creates a new user using GraphAPI with the following settings:$/ * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index ec6e542b904..4bb6f2f2ab9 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -362,6 +362,66 @@ public function theGroupShouldExist(string $groupname):bool { ); } + /** + * @Given user :user has been created with default attributes and without skeleton files + * + * @param string $user + * + * @return void + * @throws Exception|GuzzleException + */ + public function userHasBeenCreatedWithDefaultAttributes( + string $user + ):void { + $this->userHasBeenCreated(["userName" => $user]); + } + + /** + * @Given these users have been created without skeleton files and not initialized: + * + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized( + TableNode $table + ):void { + $this->usersHaveBeenCreated($table, true, false); + } + + /** + * @Given these users have been created with default attributes and without skeleton files: + * expects a table of users with the heading + * "|username|" + * + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void { + $this->usersHaveBeenCreated($table); + } + + /** + * @Given the administrator has created a new user with the following attributes: + * @Given the user :byUser has created a new user using the Graph API with the following settings: + * + * @param string $byUser + * @param TableNode $table + * + * @return void + * @throws Exception|GuzzleException + */ + public function theAdministratorHasCreatedANewUserWithFollowingAttributes(string $byUser, TableNode $table): void { + $rows = $table->getRowsHash(); + $this->userHasBeenCreated( + $rows, + $byUser + ); + } + /** * * @param string $groupname @@ -813,6 +873,8 @@ public function usersHaveBeenCreated( // can be fetched with the "onPremisesSamAccountName" i.e. userid $this->graphContext->adminHasRetrievedUserUsingTheGraphApi($userAttributes['userid']); $userAttributes['id'] = $this->getJsonDecodedResponse()['id']; + } else { + $userAttributes['id'] = null; } $this->addUserToCreatedUsersList( $userAttributes['userid'], From 16798535fc09399307308cd3bb6bb2e6144cf52e Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 28 Aug 2023 12:37:48 +0545 Subject: [PATCH 09/12] fix creating single ldap user --- tests/acceptance/features/bootstrap/Provisioning.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 4bb6f2f2ab9..101892a0a25 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -2676,14 +2676,12 @@ public function userHasBeenCreated( $user = \trim($user); if ($this->isTestingWithLdap()) { - $settings = []; $setting["userid"] = $user; $setting["displayName"] = $displayName; $setting["password"] = $password; $setting["email"] = $email; - $settings[] = $setting; try { - $this->createLdapUser($settings); + $this->createLdapUser($setting); } catch (LdapException $exception) { throw new Exception( __METHOD__ . " cannot create a LDAP user with provided data. Error: $exception" From 14c98f68a5518447efb693b35fd3bd7e016d0eb1 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 28 Aug 2023 14:35:33 +0545 Subject: [PATCH 10/12] fix: user check method --- tests/acceptance/features/bootstrap/Provisioning.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 101892a0a25..ecd9a6e2c2e 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -2776,11 +2776,19 @@ public function userExists(string $user):bool { : "/ocs/v2.php/cloud"; $fullUrl = $this->getBaseUrl() . $path . "/users/$user"; + if (OcisHelper::isTestingOnReva()) { + $requestingUser = $this->getActualUsername($user); + $requestingPassword = $this->getPasswordForUser($user); + } else { + $requestingUser = $this->getAdminUsername(); + $requestingPassword = $this->getAdminPassword(); + } + $response = HttpRequestHelper::get( $fullUrl, $this->getStepLineRef(), - $this->getAdminUsername(), - $this->getAdminPassword() + $requestingUser, + $requestingPassword ); if ($response->getStatusCode() >= 400) { return false; From 138c747a3b029a881cfe8095b9cec26f0c2308b9 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 28 Aug 2023 16:08:10 +0545 Subject: [PATCH 11/12] initialize user via graph --- tests/acceptance/features/bootstrap/Provisioning.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index ecd9a6e2c2e..51848b2b685 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -405,7 +405,6 @@ public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeleton } /** - * @Given the administrator has created a new user with the following attributes: * @Given the user :byUser has created a new user using the Graph API with the following settings: * * @param string $byUser @@ -2529,8 +2528,13 @@ public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user):v * @return void */ public function initializeUser(string $user, string $password):void { - $url = $this->getBaseUrl() - . "/ocs/v$this->ocsApiVersion.php/cloud/users/$user"; + $url = $this->getBaseUrl() . "/graph/v1.0/users/$user"; + + if (OcisHelper::isTestingOnReva()) { + $url = $this->getBaseUrl() + . "/ocs/v$this->ocsApiVersion.php/cloud/users/$user"; + } + HttpRequestHelper::get( $url, $this->getStepLineRef(), @@ -5317,7 +5321,7 @@ private function setSkeletonDirByType(string $skeletonType): string { * @return string skeleton folder before the change * @throws Exception */ - public function setSkeletonDir(string $skeletonDir): string { + private function setSkeletonDir(string $skeletonDir): string { $originalSkeletonPath = \getenv("SKELETON_DIR"); if ($skeletonDir !== '') { \putenv("SKELETON_DIR=" . $skeletonDir); From 8aadb656470d405d26bc2d727cd8d3ba6caf383c Mon Sep 17 00:00:00 2001 From: Sabin Date: Tue, 5 Sep 2023 09:55:30 +0545 Subject: [PATCH 12/12] addressing reviews --- tests/acceptance/features/bootstrap/Provisioning.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 51848b2b685..3ab6aa6d26a 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -413,7 +413,7 @@ public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeleton * @return void * @throws Exception|GuzzleException */ - public function theAdministratorHasCreatedANewUserWithFollowingAttributes(string $byUser, TableNode $table): void { + public function theAdministratorHasCreatedANewUserWithFollowingSettings(string $byUser, TableNode $table): void { $rows = $table->getRowsHash(); $this->userHasBeenCreated( $rows,