diff --git a/.drone.star b/.drone.star index 5eec27e3952..ca4988126ed 100644 --- a/.drone.star +++ b/.drone.star @@ -822,7 +822,6 @@ def localApiTestPipeline(ctx): def localApiTests(suite, storage, extra_environment = {}): environment = { - "TEST_WITH_GRAPH_API": "true", "PATH_TO_OCIS": dirs["base"], "TEST_SERVER_URL": "https://ocis-server:9200", "OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""), @@ -1006,7 +1005,6 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac "name": "oC10ApiTests-%s-storage-%s" % (storage, part_number), "image": OC_CI_PHP % DEFAULT_PHP_VERSION, "environment": { - "TEST_WITH_GRAPH_API": "true", "PATH_TO_OCIS": "%s" % dirs["base"], "TEST_SERVER_URL": "https://ocis-server:9200", "OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""), diff --git a/docs/ocis/development/testing.md b/docs/ocis/development/testing.md index 65df0a865e1..c9d62f81644 100644 --- a/docs/ocis/development/testing.md +++ b/docs/ocis/development/testing.md @@ -223,7 +223,6 @@ ocis/bin/ocis server ```bash make test-acceptance-api \ TEST_SERVER_URL=https://localhost:9200 \ -TEST_WITH_GRAPH_API=true \ ``` #### Run Tests Transferred From ownCloud Core (prefix `coreApi`) @@ -231,7 +230,6 @@ TEST_WITH_GRAPH_API=true \ ```bash make test-acceptance-from-core-api \ TEST_SERVER_URL=https://localhost:9200 \ -TEST_WITH_GRAPH_API=true \ ``` Useful environment variables: @@ -289,7 +287,6 @@ If you want to work on a specific issue ```bash make test-acceptance-from-core-api \ TEST_SERVER_URL=https://localhost:9200 \ - TEST_WITH_GRAPH_API=true \ STORAGE_DRIVER=OCIS \ BEHAT_FEATURE='tests/acceptance/features/coreApiVersions/fileVersions.feature:147' ``` @@ -326,7 +323,6 @@ PROXY_ENABLE_BASIC_AUTH=true \ ```bash OCIS_WRAPPER_URL=http://localhost:5200 \ -TEST_WITH_GRAPH_API=true \ TEST_SERVER_URL="https://localhost:9200" \ BEHAT_FEATURE=tests/acceptance/features/apiAsyncUpload/delayPostprocessing.feature \ make test-acceptance-api @@ -374,7 +370,6 @@ ocis/bin/ocis server Run the acceptance test with the following command: ```bash -TEST_WITH_GRAPH_API=true \ TEST_SERVER_URL="https://localhost:9200" \ EMAIL_HOST="localhost" \ EMAIL_PORT=9000 \ @@ -417,7 +412,6 @@ ocis/bin/ocis server Run the acceptance test with the following command: ```bash -TEST_WITH_GRAPH_API=true \ TEST_SERVER_URL="https://localhost:9200" \ BEHAT_FEATURE="tests/acceptance/features/apiSearch/contentSearch.feature" \ make test-acceptance-api @@ -539,7 +533,6 @@ For antivirus running with docker, use `ANTIVIRUS_CLAMAV_SOCKET= "tcp://host.doc Run the acceptance test with the following command: ```bash -TEST_WITH_GRAPH_API=true \ TEST_SERVER_URL="https://localhost:9200" \ BEHAT_FEATURE="tests/acceptance/features/apiAntivirus/antivirus.feature" \ make test-acceptance-api diff --git a/tests/TestHelpers/OcisHelper.php b/tests/TestHelpers/OcisHelper.php index 3232429b4e4..53120c209c5 100644 --- a/tests/TestHelpers/OcisHelper.php +++ b/tests/TestHelpers/OcisHelper.php @@ -47,13 +47,6 @@ public static function isTestingParallelDeployment(): bool { return (\getenv("TEST_PARALLEL_DEPLOYMENT") === "true"); } - /** - * @return bool - */ - public static function isTestingWithGraphApi(): bool { - return \getenv('TEST_WITH_GRAPH_API') === 'true'; - } - /** * @return bool|string false if no command given or the command as string */ diff --git a/tests/acceptance/docker/src/acceptance.yml b/tests/acceptance/docker/src/acceptance.yml index 85a78c25485..e98a1f7f6c2 100644 --- a/tests/acceptance/docker/src/acceptance.yml +++ b/tests/acceptance/docker/src/acceptance.yml @@ -6,7 +6,6 @@ services: environment: OCIS_ROOT: /drone/src TEST_SERVER_URL: https://ocis-server:9200 - TEST_WITH_GRAPH_API: "true" OCIS_WRAPPER_URL: http://ocis-server:5200 STORAGE_DRIVER: $STORAGE_DRIVER TEST_SOURCE: $TEST_SOURCE diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index d6b3661599e..53571a961c7 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -3244,11 +3244,9 @@ public function before(BeforeScenarioScope $scope): void { $this->connectToLdap($suiteParameters); } - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext = new GraphContext(); - $this->graphContext->before($scope); - $environment->registerContext($this->graphContext); - } + $this->graphContext = new GraphContext(); + $this->graphContext->before($scope); + $environment->registerContext($this->graphContext); } /** diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 0f28e7c1904..0a8c1b22ba6 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -902,60 +902,6 @@ public function usersHaveBeenCreated( } } - /** - * @When the administrator changes the password of user :user to :password using the provisioning API - * - * @param string $user - * @param string $password - * - * @return void - * @throws Exception - */ - public function adminChangesPasswordOfUserToUsingTheProvisioningApi( - string $user, - string $password - ):void { - $this->response = UserHelper::editUser( - $this->getBaseUrl(), - $user, - 'password', - $password, - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getStepLineRef() - ); - } - - /** - * @Given the administrator has changed the password of user :user to :password - * - * @param string $user - * @param string $password - * - * @return void - * @throws Exception - */ - public function adminHasChangedPasswordOfUserTo( - string $user, - string $password - ):void { - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->adminChangesPasswordOfUserToUsingTheGraphApi( - $user, - $password - ); - } else { - $this->adminChangesPasswordOfUserToUsingTheProvisioningApi( - $user, - $password - ); - } - $this->theHTTPStatusCodeShouldBe( - 200, - "could not change password of user $user" - ); - } - /** * @When /^user "([^"]*)" (enables|disables) app "([^"]*)"$/ * @@ -1472,53 +1418,6 @@ public function adminChangesTheEmailOfUserToUsingTheProvisioningApi( $this->rememberUserEmailAddress($user, $email); } - /** - * @Given /^the administrator has changed the email of user "([^"]*)" to "([^"]*)"$/ - * - * @param string $user - * @param string $email - * - * @return void - * @throws Exception - */ - public function adminHasChangedTheEmailOfUserTo(string $user, string $email):void { - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userHasBeenEditedUsingTheGraphApi( - $user, - null, - null, - $email - ); - $updatedUserData = $this->getJsonDecodedResponse(); - Assert::assertEquals( - $email, - $updatedUserData['mail'] - ); - } else { - $this->adminChangesTheEmailOfUserToUsingTheProvisioningApi( - $user, - $email - ); - $this->theHTTPStatusCodeShouldBe( - 200, - "could not change email of user $user" - ); - } - } - - /** - * @Given the administrator has changed their own email address to :email - * - * @param string|null $email - * - * @return void - * @throws Exception - */ - public function theAdministratorHasChangedTheirOwnEmailAddressTo(?string $email):void { - $admin = $this->getAdminUsername(); - $this->adminHasChangedTheEmailOfUserTo($admin, $email); - } - /** * @param string $requestingUser * @param string $targetUser @@ -1592,49 +1491,6 @@ public function userTriesToChangeTheEmailOfUserUsingTheProvisioningApi( ); } - /** - * @Given /^user "([^"]*)" has changed the email of user "([^"]*)" to "([^"]*)"$/ - * - * @param string $requestingUser - * @param string $targetUser - * @param string $email - * - * @return void - * @throws Exception - */ - public function userHasChangedTheEmailOfUserUsingTheProvisioningApi( - string $requestingUser, - string $targetUser, - string $email - ):void { - $requestingUser = $this->getActualUsername($requestingUser); - $targetUser = $this->getActualUsername($targetUser); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userHasBeenEditedUsingTheGraphApi( - $targetUser, - null, - null, - $email, - null, - $requestingUser, - $this->getPasswordForUser($requestingUser) - ); - $updatedUserData = $this->getJsonDecodedResponse(); - Assert::assertEquals( - $email, - $updatedUserData['mail'], - ); - } else { - $response = $this->userChangesUserEmailUsingProvisioningApi( - $requestingUser, - $targetUser, - $email - ); - $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); - } - $this->rememberUserEmailAddress($targetUser, $email); - } - /** * Edit the "display name" of a user by sending the key "displayname" to the API end point. * @@ -1663,60 +1519,6 @@ public function adminChangesTheDisplayNameOfUserUsingTheProvisioningApi( $this->rememberUserDisplayName($user, $displayName); } - /** - * @Given /^the administrator has changed the display name of user "([^"]*)" to "([^"]*)"$/ - * - * @param string $user - * @param string $displayName - * - * @return void - * @throws Exception - */ - public function adminHasChangedTheDisplayNameOfUser( - string $user, - string $displayName - ):void { - $user = $this->getActualUsername($user); - if ($this->isTestingWithLdap()) { - $this->editLdapUserDisplayName( - $user, - $displayName - ); - } elseif (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userHasBeenEditedUsingTheGraphApi( - $user, - null, - null, - null, - $displayName - ); - $updatedUserData = $this->getJsonDecodedResponse(); - Assert::assertEquals( - $displayName, - $updatedUserData['displayName'] - ); - } else { - $this->adminChangesTheDisplayNameOfUserUsingKey( - $user, - 'displayname', - $displayName - ); - $response = UserHelper::getUser( - $this->getBaseUrl(), - $user, - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getStepLineRef() - ); - $actualDisplayName = $this->getDisplayNameFromResponse($response); - Assert::assertEquals( - $displayName, - $actualDisplayName - ); - } - $this->rememberUserDisplayName($user, $displayName); - } - /** * As the administrator, edit the "display name" of a user by sending the key "display" to the API end point. * @@ -1866,50 +1668,6 @@ public function userChangesTheDisplayOfUserUsingTheProvisioningApi( $this->pushToLastStatusCodesArrays(); } - /** - * @Given /^user "([^"]*)" has changed the display name of user "([^"]*)" to "([^"]*)"$/ - * - * @param string $requestingUser - * @param string $targetUser - * @param string $displayName - * - * @return void - * @throws Exception - */ - public function userHasChangedTheDisplayNameOfUserUsingTheProvisioningApi( - string $requestingUser, - string $targetUser, - string $displayName - ):void { - $requestingUser = $this->getActualUsername($requestingUser); - $targetUser = $this->getActualUsername($targetUser); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userHasBeenEditedUsingTheGraphApi( - $targetUser, - null, - null, - null, - $displayName, - $requestingUser, - $this->getPasswordForUser($requestingUser) - ); - $updatedUserData = $this->getJsonDecodedResponse(); - Assert::assertEquals( - $displayName, - $updatedUserData['displayName'] - ); - } else { - $response = $this->userChangesTheDisplayNameOfUserUsingKey( - $requestingUser, - $targetUser, - 'displayname', - $displayName - ); - $this->theHTTPStatusCodeShouldBeSuccess(); - $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); - } - $this->rememberUserDisplayName($targetUser, $displayName); - } /** * * @param string $requestingUser @@ -2139,10 +1897,7 @@ public function theFollowingGroupsShouldNotExist(TableNode $table):void { public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table):void { $should = ($shouldOrNot !== "not"); $this->verifyTableNodeColumns($table, ['groupname']); - $useGraph = OcisHelper::isTestingWithGraphApi(); - if ($useGraph) { - $this->graphContext->theseGroupsShouldNotExist($shouldOrNot, $table); - } else { + if ($this->isTestingWithLdap()) { $groups = $this->getArrayOfGroupsResponded($this->getAllGroups()); foreach ($table as $row) { if (\in_array($row['groupname'], $groups, true) !== $should) { @@ -2153,6 +1908,8 @@ public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table) ); } } + } else { + $this->graphContext->theseGroupsShouldNotExist($shouldOrNot, $table); } } @@ -2622,12 +2379,7 @@ public function userExists(string $user):bool { */ public function userShouldBelongToGroup(string $user, string $group):void { $user = $this->getActualUsername($user); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userShouldBeMemberInGroupUsingTheGraphApi( - $user, - $group - ); - } else { + if (OcisHelper::isTestingOnReva()) { $this->theAdministratorGetsAllTheGroupsOfUser($user); $respondedArray = $this->getArrayOfGroupsResponded($this->response); \sort($respondedArray); @@ -2646,6 +2398,11 @@ public function userShouldBelongToGroup(string $user, string $group):void { . $this->response->getStatusCode() . "'" ); + } else { + $this->graphContext->userShouldBeMemberInGroupUsingTheGraphApi( + $user, + $group + ); } } @@ -2688,9 +2445,7 @@ public function getUsersOfLdapGroup(string $group):array { */ public function userShouldNotBelongToGroup(string $user, string $group):void { $user = $this->getActualUsername($user); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->userShouldNotBeMemberInGroupUsingTheGraphApi($user, $group); - } else { + if (OcisHelper::isTestingOnReva()) { $fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/users/$user/groups"; $response = HttpRequestHelper::get( $fullUrl, @@ -2705,6 +2460,8 @@ public function userShouldNotBelongToGroup(string $user, string $group):void { 200, $response->getStatusCode() ); + } else { + $this->graphContext->userShouldNotBeMemberInGroupUsingTheGraphApi($user, $group); } } @@ -3240,10 +2997,10 @@ public function theAdministratorDisablesTheFollowingUsersUsingTheProvisioningApi */ public function adminHasDisabledUserUsingTheProvisioningApi(?string $user):void { $user = $this->getActualUsername($user); - if (OcisHelper::isTestingWithGraphApi()) { - $response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false); - } else { + if (OcisHelper::isTestingOnReva()) { $response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable'); + } else { + $response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false); } Assert::assertEquals( 200, @@ -3335,10 +3092,7 @@ public function userTriesToEnableUserUsingTheProvisioningApi( */ public function deleteUser(string $user):ResponseInterface { // Always try to delete the user - if (OcisHelper::isTestingWithGraphApi()) { - // users can be deleted using the username in the GraphApi too - $response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user); - } else { + if (OcisHelper::isTestingOnReva()) { $response = UserHelper::deleteUser( $this->getBaseUrl(), $user, @@ -3347,6 +3101,9 @@ public function deleteUser(string $user):ResponseInterface { $this->getStepLineRef(), $this->ocsApiVersion ); + } else { + // users can be deleted using the username in the GraphApi too + $response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user); } return $response; } @@ -3414,7 +3171,7 @@ public function adminHasRemovedUserFromGroup(string $user, string $group):void { && \in_array($group, $this->ldapCreatedGroups) ) { $this->removeUserFromLdapGroup($user, $group); - } elseif (OcisHelper::isTestingWithGraphApi()) { + } else { $user = $this->getActualUsername($user); $response = $this->graphContext->removeUserFromGroup($group, $user); $this->TheHTTPStatusCodeShouldBe(204, '', $response); @@ -3433,14 +3190,7 @@ public function adminHasRemovedUserFromGroup(string $user, string $group):void { */ public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void { $user = $this->getActualUsername($user); - if (OcisHelper::isTestingWithGraphApi()) { - $this->setResponse( - $this->graphContext->removeUserFromGroup( - $group, - $user - ) - ); - } else { + if (OcisHelper::isTestingOnReva()) { $this->response = UserHelper::removeUserFromGroup( $this->getBaseUrl(), $user, @@ -3450,6 +3200,13 @@ public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, s $this->getStepLineRef(), $this->ocsApiVersion ); + } else { + $this->setResponse( + $this->graphContext->removeUserFromGroup( + $group, + $user + ) + ); } $this->pushToLastStatusCodesArrays(); @@ -3625,9 +3382,7 @@ function ($user) { }, $this->simplifyArray($users) ); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->theseUsersShouldBeInTheResponse($usersSimplified); - } else { + if ($this->isTestingWithLdap()) { $respondedArray = $this->getArrayOfUsersResponded($this->response); Assert::assertEqualsCanonicalizing( $usersSimplified, @@ -3635,6 +3390,8 @@ function ($user) { __METHOD__ . " Provided users do not match the users returned in the response." ); + } else { + $this->graphContext->theseUsersShouldBeInTheResponse($usersSimplified); } } @@ -3680,15 +3437,15 @@ public function theGroupsShouldBe(TableNode $groupsList):void { $groups = $groupsList->getRows(); $groupsSimplified = $this->simplifyArray($groups); $respondedArray = $this->getArrayOfGroupsResponded($this->response); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified); - } else { + if ($this->isTestingWithLdap()) { Assert::assertEqualsCanonicalizing( $groupsSimplified, $respondedArray, __METHOD__ . " Provided groups do not match the groups returned in the response." ); + } else { + $this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified); } } @@ -3704,9 +3461,7 @@ public function theExtraGroupsShouldBe(TableNode $groupsList):void { $this->verifyTableNodeColumnsCount($groupsList, 1); $groups = $groupsList->getRows(); $groupsSimplified = $this->simplifyArray($groups); - if (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified); - } else { + if ($this->isTestingWithLdap()) { $expectedGroups = \array_merge($this->startingGroups, $groupsSimplified); $respondedArray = $this->getArrayOfGroupsResponded($this->response); Assert::assertEqualsCanonicalizing( @@ -3715,6 +3470,8 @@ public function theExtraGroupsShouldBe(TableNode $groupsList):void { __METHOD__ . " Provided groups do not match the groups returned in the response." ); + } else { + $this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified); } } @@ -4490,22 +4247,22 @@ public function cleanupDatabaseGroups():void { $previousServer = $this->currentServer; $this->usingServer('LOCAL'); foreach ($this->createdGroups as $group => $groupData) { - if (OcisHelper::isTestingWithGraphApi()) { + if ($this->isTestingWithLdap()) { + $this->cleanupGroup((string)$group); + } else { $this->graphContext->adminDeletesGroupWithGroupId( $groupData['id'] ); - } else { - $this->cleanupGroup((string)$group); } } $this->usingServer('REMOTE'); foreach ($this->createdRemoteGroups as $remoteGroup => $groupData) { - if (OcisHelper::isTestingWithGraphApi()) { + if ($this->isTestingWithLdap()) { + $this->cleanupGroup((string)$remoteGroup); + } else { $this->graphContext->adminDeletesGroupWithGroupId( $groupData['id'] ); - } else { - $this->cleanupGroup((string)$remoteGroup); } } $this->usingServer($previousServer);