From 8e2a8521ecb84f2fd011e42d95e15202798c6cb3 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Thu, 2 Mar 2023 12:40:51 +0545 Subject: [PATCH] Removed restoreParameters methods --- .../features/bootstrap/FeatureContext.php | 102 ------------------ .../features/bootstrap/Provisioning.php | 67 +++++------- 2 files changed, 28 insertions(+), 141 deletions(-) diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index d03dd9c9c0b..bbee48c4484 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -3964,29 +3964,6 @@ class FeatureContext extends BehatVariablesContext { return; } - /** - * runs a function on every server (LOCAL & REMOTE). - * The callable function receives the server (LOCAL or REMOTE) as first argument - * - * @param callable $callback - * - * @return array - */ - public function runFunctionOnEveryServer(callable $callback): array { - $previousServer = $this->getCurrentServer(); - $result = []; - foreach (['LOCAL', 'REMOTE'] as $server) { - $this->usingServer($server); - if (($server === 'LOCAL') - || $this->federatedServerExists() - ) { - $result[$server] = \call_user_func($callback, $server); - } - } - $this->usingServer($previousServer); - return $result; - } - /** * Verify that the tableNode contains expected headers * @@ -4399,85 +4376,6 @@ class FeatureContext extends BehatVariablesContext { ]; } - /** - * restore settings of the system and delete new settings that were created in the test runs - * - * @param string $server LOCAL|REMOTE - * - * @return void - * - * @throws Exception - * @throws GuzzleException - * - */ - private function restoreParameters(string $server): void { - $commands = []; - if ($this->isTestingWithLdap()) { - $this->resetOldLdapConfig(); - } - $result = SetupHelper::runOcc( - ['config:list'], - $this->getStepLineRef(), - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getBaseUrl(), - $this->getOcPath() - ); - $currentConfigList = \json_decode($result['stdOut'], true); - foreach ($currentConfigList['system'] as $configKey => $configValue) { - if (!\array_key_exists( - $configKey, - $this->savedConfigList[$server]['system'] - ) - ) { - $commands[] = ["command" => ['config:system:delete', $configKey]]; - } - } - foreach ($this->savedConfigList[$server]['system'] as $configKey => $configValue) { - if (!\array_key_exists($configKey, $currentConfigList["system"]) - || $currentConfigList["system"][$configKey] !== $this->savedConfigList[$server]['system'][$configKey] - ) { - $commands[] = ["command" => ['config:system:set', "--type=json", "--value=" . \json_encode($configValue), $configKey]]; - } - } - foreach ($currentConfigList['apps'] as $appName => $appSettings) { - foreach ($appSettings as $configKey => $configValue) { - //only check if the app was there in the original configuration - if (\array_key_exists($appName, $this->savedConfigList[$server]['apps']) - && !\array_key_exists( - $configKey, - $this->savedConfigList[$server]['apps'][$appName] - ) - ) { - $commands[] = ["command" => ['config:app:delete', $appName, $configKey]]; - } elseif (\array_key_exists($appName, $this->savedConfigList[$server]['apps']) - && \array_key_exists($configKey, $this->savedConfigList[$server]['apps'][$appName]) - && $this->savedConfigList[$server]['apps'][$appName][$configKey] !== $configValue - ) { - // Do not accidentally disable apps here (perhaps too early) - // That is done in Provisioning.php restoreAppEnabledDisabledState() - if ($configKey !== "enabled") { - $commands[] = [ - "command" => [ - 'config:app:set', - $appName, - $configKey, - "--value=" . $this->savedConfigList[$server]['apps'][$appName][$configKey] - ] - ]; - } - } - } - } - SetupHelper::runBulkOcc( - $commands, - $this->getStepLineRef(), - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getBaseUrl() - ); - } - /** * The method returns userId * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 4c27ea55659..4164068a880 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -635,7 +635,6 @@ trait Provisioning { if (!$this->skipImportLdif) { $this->importLdifFile($ldifFile); } - $this->theLdapUsersHaveBeenResynced(); } /** @@ -743,7 +742,6 @@ trait Provisioning { $this->ldap->add($newDN, $entry); } $this->ldapCreatedUsers[] = $setting["userid"]; - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -850,7 +848,6 @@ trait Provisioning { ); $this->rememberThatGroupIsNotExpectedToExist($group); } - $this->theLdapUsersHaveBeenResynced(); } /** @@ -1098,8 +1095,6 @@ trait Provisioning { $userAttributes['password'], $this->getStepLineRef() ); - // We don't need to set displayName and email while running in oCIS - // As they are set when creating the user } if (isset($exceptionToThrow)) { @@ -1451,11 +1446,11 @@ trait Provisioning { $email = $user . '@owncloud.com'; $bodyTable = new TableNode( [ - ['userid', $user], - ['password', $password], - ['username', $user], - ['email', $email] - ] + ['userid', $user], + ['password', $password], + ['username', $user], + ['email', $email] + ] ); $this->emptyLastHTTPStatusCodesArray(); $this->emptyLastOCSStatusCodesArray(); @@ -1518,11 +1513,11 @@ trait Provisioning { $email = $userToCreate . '@owncloud.com'; $bodyTable = new TableNode( [ - ['userid', $userToCreate], - ['password', $password], - ['username', $userToCreate], - ['email', $email] - ] + ['userid', $userToCreate], + ['password', $password], + ['username', $userToCreate], + ['email', $email] + ] ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $user, @@ -1560,12 +1555,12 @@ trait Provisioning { $email = $user . '@owncloud.com'; $bodyTable = new TableNode( [ - ['userid', $user], - ['password', $password], - ['username', $user], - ['email', $email], - ['groups[]', $group], - ] + ['userid', $user], + ['password', $password], + ['username', $user], + ['email', $email], + ['groups[]', $group], + ] ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), @@ -1606,12 +1601,12 @@ trait Provisioning { $email = $userToCreate . '@owncloud.com'; $bodyTable = new TableNode( [ - ['userid', $userToCreate], - ['password', $userToCreate], - ['username', $userToCreate], - ['email', $email], - ['groups[]', $group], - ] + ['userid', $userToCreate], + ['password', $userToCreate], + ['username', $userToCreate], + ['email', $email], + ['groups[]', $group], + ] ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $groupadmin, @@ -1651,12 +1646,12 @@ trait Provisioning { $email = $userToCreate . '@owncloud.com'; $bodyTable = new TableNode( [ - ['userid', $userToCreate], - ['password', $userToCreate], - ['username', $userToCreate], - ['email', $email], - ['groups[]', $group], - ] + ['userid', $userToCreate], + ['password', $userToCreate], + ['username', $userToCreate], + ['email', $email], + ['groups[]', $group], + ] ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $groupadmin, @@ -3971,7 +3966,6 @@ trait Provisioning { $ldapEntry = $this->ldap->getEntry($entry . "," . $this->ldapBaseDN); Laminas\Ldap\Attribute::setAttribute($ldapEntry, $attribute, $value, $append); $this->ldap->update($entry . "," . $this->ldapBaseDN, $ldapEntry); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4045,7 +4039,6 @@ trait Provisioning { $memberAttr, "cn=$group,ou=$ou" ); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4056,7 +4049,6 @@ trait Provisioning { */ public function deleteTheLdapEntry(string $entry):void { $this->ldap->delete($entry . "," . $this->ldapBaseDN); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4072,7 +4064,6 @@ trait Provisioning { $ou = $this->getLdapGroupsOU(); } $this->deleteTheLdapEntry("cn=$group,ou=$ou"); - $this->theLdapUsersHaveBeenReSynced(); $key = \array_search($group, $this->ldapCreatedGroups); if ($key !== false) { unset($this->ldapCreatedGroups[$key]); @@ -4119,7 +4110,6 @@ trait Provisioning { $entry, $displayName ); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -5670,7 +5660,6 @@ trait Provisioning { */ public function afterScenario():void { $this->waitForDavRequestsToFinish(); - $this->restoreParametersAfterScenario(); if ($this->someUsersHaveBeenCreated()) { foreach ($this->getCreatedUsers() as $user) {