From 32b9d0896e4cffa5fafe768ad52d45b2b9a741a6 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Wed, 1 Mar 2023 16:48:53 +0545 Subject: [PATCH 1/3] Removed, runOcc method from setupHelper --- tests/TestHelpers/SetupHelper.php | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/TestHelpers/SetupHelper.php b/tests/TestHelpers/SetupHelper.php index 0b6809dd5e5..c7b8c580c91 100644 --- a/tests/TestHelpers/SetupHelper.php +++ b/tests/TestHelpers/SetupHelper.php @@ -792,34 +792,6 @@ public static function runBulkOcc( return []; } - /** - * invokes an OCC command - * - * @param array|null $args anything behind "occ". - * For example: "files:transfer-ownership" - * @param string|null $xRequestId - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * @param string|null $ocPath - * @param array|null $envVariables - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws GuzzleException - * @throws Exception - */ - public static function runOcc( - ?array $args, - ?string $xRequestId = '', - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null, - ?string $ocPath = null, - ?array $envVariables = null - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - /** * @param string $baseUrl * @param string $user From 810b7b5279d257b18107606cf0d4d25699df424d Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Thu, 2 Mar 2023 09:34:01 +0545 Subject: [PATCH 2/3] Refactored code where SetupHelper::runOcc method is used --- tests/TestHelpers/SetupHelper.php | 102 +++--------------- .../features/bootstrap/FeatureContext.php | 29 +---- .../features/bootstrap/Provisioning.php | 10 +- .../acceptance/features/bootstrap/WebDav.php | 42 ++------ 4 files changed, 27 insertions(+), 156 deletions(-) diff --git a/tests/TestHelpers/SetupHelper.php b/tests/TestHelpers/SetupHelper.php index c7b8c580c91..be621850bee 100644 --- a/tests/TestHelpers/SetupHelper.php +++ b/tests/TestHelpers/SetupHelper.php @@ -79,10 +79,7 @@ public static function createUser( $occCommand = \array_merge($occCommand, ["--email", $email]); } \putenv("OC_PASS=" . $password); - return self::runOcc( - \array_merge($occCommand, [$userName]), - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -98,10 +95,7 @@ public static function deleteUser( ?string $userName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['user:delete', $userName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -122,10 +116,7 @@ public static function changeUserSetting( ?string $value, ?string $xRequestId = '' ):array { - return self::runOcc( - ['user:setting', '--value ' . $value, $userName, $app, $key], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -141,10 +132,7 @@ public static function createGroup( ?string $groupName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['group:add', $groupName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -162,10 +150,7 @@ public static function addUserToGroup( ?string $userName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['group:add-member', '--member', $userName, $groupName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -183,10 +168,7 @@ public static function removeUserFromGroup( ?string $userName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['group:remove-member', '--member', $userName, $groupName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -202,10 +184,7 @@ public static function deleteGroup( ?string $groupName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['group:delete', $groupName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -219,10 +198,7 @@ public static function getGroups( ?string $xRequestId = '' ):array { return \json_decode( - self::runOcc( - ['group:list', '--output=json'], - $xRequestId - )['stdOut'] + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]['stdOut'] ); } /** @@ -653,13 +629,7 @@ public static function readSkeletonFile( ); //find the absolute path of the currently set skeletondirectory - $occResponse = self::runOcc( - ['config:system:get', 'skeletondirectory'], - $xRequestId, - $adminUsername, - $adminPassword, - $baseUrl - ); + $occResponse = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; if ((int) $occResponse['code'] !== 0) { throw new \Exception( "could not get current skeletondirectory. " . $occResponse['stdErr'] @@ -700,10 +670,7 @@ public static function enableApp( ?string $appName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['app:enable', $appName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -719,10 +686,7 @@ public static function disableApp( ?string $appName, ?string $xRequestId = '' ):array { - return self::runOcc( - ['app:disable', $appName], - $xRequestId - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -738,10 +702,7 @@ public static function isAppEnabled( ?string $appName, ?string $xRequestId = '' ):bool { - $result = self::runOcc( - ['app:list', '^' . $appName . '$'], - $xRequestId - ); + $result = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; return \strtolower(\substr($result['stdOut'], 0, 7)) === 'enabled'; } @@ -848,17 +809,7 @@ public static function createLocalStorageMount( self::$adminPassword, $xRequestId ); - $result = self::runOcc( - [ - 'files_external:create', - $mount, - 'local', - 'null::null', - '-c', - 'datadir=' . $serverRoot . '/' . $mountPath - ], - $xRequestId - ); + $result = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; // stdOut should have a string like "Storage created with id 65" $storageIdWords = \explode(" ", \trim($result['stdOut'])); if (\array_key_exists(4, $storageIdWords)) { @@ -908,14 +859,7 @@ public static function getSystemConfig( $args[] = '--no-ansi'; - return self::runOcc( - $args, - $xRequestId, - $adminUsername, - $adminPassword, - $baseUrl, - $ocPath - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -965,14 +909,7 @@ public static function setSystemConfig( if ($baseUrl === null) { $baseUrl = self::$baseUrl; } - return self::runOcc( - $args, - $xRequestId, - $adminUsername, - $adminPassword, - $baseUrl, - $ocPath - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -1059,13 +996,6 @@ public static function deleteSystemConfig( if ($baseUrl === null) { $baseUrl = self::$baseUrl; } - return SetupHelper::runOcc( - $args, - $xRequestId, - $adminUsername, - $adminPassword, - $baseUrl, - $ocPath - ); + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } } diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 914edb042f5..6dcb8dfe4c7 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -3739,15 +3739,7 @@ public function setupLocalStorageBefore(): void { ); } $this->addStorageId($storageName, (int)$storageId); - SetupHelper::runOcc( - [ - 'files_external:option', - $storageId, - 'enable_sharing', - 'true' - ], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** @@ -3785,14 +3777,7 @@ public function deleteAllResourceCreatedByAdmin(): void { public function deleteAllStorages(): void { $allStorageIds = \array_keys($this->getStorageIds()); foreach ($allStorageIds as $storageId) { - SetupHelper::runOcc( - [ - 'files_external:delete', - '-y', - $storageId - ], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } $this->storageIds = []; } @@ -4110,15 +4095,7 @@ public function runOccWithEnvVariables( if ($baseUrl == null) { $baseUrl = $this->getBaseUrl(); } - $return = SetupHelper::runOcc( - $args, - $this->getStepLineRef(), - $adminUsername, - $adminPassword, - $baseUrl, - $ocPath, - $envVariables - ); + $return = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; $this->lastStdOut = $return['stdOut']; $this->lastStdErr = $return['stdErr']; $occStatusCode = (int)$return['code']; diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index a3a1704b258..bb1ba69c972 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -816,10 +816,7 @@ public function setLdapSetting(string $configId, string $configKey, string $conf [], $substitutions ); - $occResult = SetupHelper::runOcc( - ['ldap:set-config', $configId, $configKey, $configValue], - $this->getStepLineRef() - ); + $occResult = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; if ($occResult['code'] !== "0") { throw new Exception( __METHOD__ . " could not set LDAP setting " . $occResult['stdErr'] @@ -857,10 +854,7 @@ public function deleteLdapUsersAndGroups():void { public function resetOldLdapConfig():void { $toDeleteLdapConfig = $this->getToDeleteLdapConfigs(); foreach ($toDeleteLdapConfig as $configId) { - SetupHelper::runOcc( - ['ldap:delete-config', $configId], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } foreach ($this->oldLdapConfig as $configId => $settings) { foreach ($settings as $configKey => $configValue) { diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index fab76db9d4c..798ce9cf912 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -578,10 +578,7 @@ public function triggerAsyncUpload(string $enabledOrDisabled):void { $value = 'false'; } if ($this->previousAsyncSetting === null) { - $previousAsyncSetting = SetupHelper::runOcc( - ['config:system:get', 'dav.enable.async'], - $this->getStepLineRef() - )['stdOut']; + $previousAsyncSetting = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]['stdOut']; $this->previousAsyncSetting = \trim($previousAsyncSetting); } $this->runOcc( @@ -618,10 +615,7 @@ public function setHttpTimeout(int $timeout):void { */ public function slowdownDavRequests(string $method, int $seconds):void { if ($this->previousDavSlowdownSetting === null) { - $previousDavSlowdownSetting = SetupHelper::runOcc( - ['config:system:get', 'dav.slowdown'], - $this->getStepLineRef() - )['stdOut']; + $previousDavSlowdownSetting = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]['stdOut']; $this->previousDavSlowdownSetting = \trim($previousDavSlowdownSetting); } OcsApiHelper::sendRequest( @@ -5409,38 +5403,14 @@ public function pauseUploadDelete():void { */ public function resetPreviousSettingsAfterScenario():void { if ($this->previousAsyncSetting === "") { - SetupHelper::runOcc( - ['config:system:delete', 'dav.enable.async'], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } elseif ($this->previousAsyncSetting !== null) { - SetupHelper::runOcc( - [ - 'config:system:set', - 'dav.enable.async', - '--type', - 'boolean', - '--value', - $this->previousAsyncSetting - ], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } if ($this->previousDavSlowdownSetting === "") { - SetupHelper::runOcc( - ['config:system:delete', 'dav.slowdown'], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } elseif ($this->previousDavSlowdownSetting !== null) { - SetupHelper::runOcc( - [ - 'config:system:set', - 'dav.slowdown', - '--value', - $this->previousDavSlowdownSetting - ], - $this->getStepLineRef() - ); + ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } } From 68ed280e279888fcc4985faa05689e12ca29aad7 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Mon, 13 Mar 2023 13:11:37 +0545 Subject: [PATCH 3/3] Cleaned up orphaned methods in SetupHelper --- tests/TestHelpers/SetupHelper.php | 488 ------------------ .../features/bootstrap/AuthContext.php | 23 +- .../features/bootstrap/FeatureContext.php | 125 ----- .../features/bootstrap/Provisioning.php | 60 --- .../acceptance/features/bootstrap/Sharing.php | 15 +- .../acceptance/features/bootstrap/WebDav.php | 21 - 6 files changed, 2 insertions(+), 730 deletions(-) diff --git a/tests/TestHelpers/SetupHelper.php b/tests/TestHelpers/SetupHelper.php index be621850bee..27f8f9b4f58 100644 --- a/tests/TestHelpers/SetupHelper.php +++ b/tests/TestHelpers/SetupHelper.php @@ -52,155 +52,6 @@ class SetupHelper extends \PHPUnit\Framework\Assert { */ private static $adminPassword = null; - /** - * creates a user - * - * @param string|null $userName - * @param string|null $password - * @param string|null $xRequestId - * @param string|null $displayName - * @param string|null $email - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function createUser( - ?string $userName, - ?string $password, - ?string $xRequestId = '', - ?string $displayName = null, - ?string $email = null - ):array { - $occCommand = ['user:add', '--password-from-env']; - if ($displayName !== null) { - $occCommand = \array_merge($occCommand, ["--display-name", $displayName]); - } - if ($email !== null) { - $occCommand = \array_merge($occCommand, ["--email", $email]); - } - \putenv("OC_PASS=" . $password); - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * deletes a user - * - * @param string|null $userName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function deleteUser( - ?string $userName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * - * @param string|null $userName - * @param string|null $app - * @param string|null $key - * @param string|null $value - * @param string|null $xRequestId - * - * @return string[] - * @throws Exception - */ - public static function changeUserSetting( - ?string $userName, - ?string $app, - ?string $key, - ?string $value, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * creates a group - * - * @param string|null $groupName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function createGroup( - ?string $groupName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * adds an existing user to a group, creating the group if it does not exist - * - * @param string|null $groupName - * @param string|null $userName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function addUserToGroup( - ?string $groupName, - ?string $userName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * removes a user from a group - * - * @param string|null $groupName - * @param string|null $userName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function removeUserFromGroup( - ?string $groupName, - ?string $userName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * deletes a group - * - * @param string|null $groupName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function deleteGroup( - ?string $groupName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * - * @param string|null $xRequestId - * - * @return string[] - * @throws Exception - */ - public static function getGroups( - ?string $xRequestId = '' - ):array { - return \json_decode( - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]['stdOut'] - ); - } /** * * @param HookScope $scope @@ -253,21 +104,6 @@ public static function init( self::$ocPath = self::normaliseOcPath($ocPath); } - /** - * - * @return string path to the testing app occ endpoint - * @throws Exception if ocPath has not been set yet - */ - public static function getOcPath():?string { - if (self::$ocPath === null) { - throw new Exception( - "getOcPath called before ocPath is set by init" - ); - } - - return self::$ocPath; - } - /** * * @param string|null $baseUrl @@ -657,298 +493,6 @@ public static function readSkeletonFile( return $localContent; } - /** - * enables an app - * - * @param string|null $appName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function enableApp( - ?string $appName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * disables an app - * - * @param string|null $appName - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws Exception - */ - public static function disableApp( - ?string $appName, - ?string $xRequestId = '' - ):array { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * checks if an app is currently enabled - * - * @param string|null $appName - * @param string|null $xRequestId - * - * @return bool true if enabled, false if disabled or nonexistent - * @throws Exception - */ - public static function isAppEnabled( - ?string $appName, - ?string $xRequestId = '' - ):bool { - $result = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - return \strtolower(\substr($result['stdOut'], 0, 7)) === 'enabled'; - } - - /** - * lists app status (enabled or disabled) - * - * @param string|null $appName - * @param string|null $xRequestId - * - * @return bool true if the app needed to be enabled, false otherwise - * @throws Exception - */ - public static function enableAppIfNotEnabled( - ?string $appName, - ?string $xRequestId = '' - ):bool { - if (!self::isAppEnabled($appName, $xRequestId)) { - self::enableApp( - $appName, - $xRequestId - ); - return true; - } - - return false; - } - - /** - * Runs a list of occ commands at once - * - * @param array|null $commands - * @param string|null $xRequestId - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * - * @return array - * @throws GuzzleException - * @throws Exception - */ - public static function runBulkOcc( - ?array $commands, - ?string $xRequestId = '', - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null - ):array { - return []; - } - - /** - * @param string $baseUrl - * @param string $user - * @param string $password - * @param string $xRequestId - * - * @return ResponseInterface|null - * @throws GuzzleException - */ - public static function resetOpcache( - ?string $baseUrl, - ?string $user, - ?string $password, - ?string $xRequestId = '' - ):?ResponseInterface { - try { - return OcsApiHelper::sendRequest( - $baseUrl, - $user, - $password, - "DELETE", - "/apps/testing/api/v1/opcache", - $xRequestId - ); - } catch (ServerException $e) { - echo "could not reset opcache, if tests fail try to set " . - "'opcache.revalidate_freq=0' in the php.ini file\n"; - } - return null; - } - - /** - * Create local storage mount - * - * @param string|null $mount (name of local storage mount) - * @param string|null $xRequestId - * - * @return string[] associated array with "code", "stdOut", "stdErr", "storageId" - * @throws GuzzleException - */ - public static function createLocalStorageMount( - ?string $mount, - ?string $xRequestId = '' - ):array { - $mountPath = TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER . "/$mount"; - SetupHelper::mkDirOnServer( - $mountPath, - $xRequestId - ); - // files_external:create requires absolute path - $serverRoot = self::getServerRoot( - self::$baseUrl, - self::$adminUsername, - self::$adminPassword, - $xRequestId - ); - $result = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - // stdOut should have a string like "Storage created with id 65" - $storageIdWords = \explode(" ", \trim($result['stdOut'])); - if (\array_key_exists(4, $storageIdWords)) { - $result['storageId'] = (int)$storageIdWords[4]; - } else { - // presumably something went wrong with the files_external:create command - // so return "unknown" to the caller. The result array has the command exit - // code and stdErr output etc., so the caller can process what it likes - // of that information to work out what went wrong. - $result['storageId'] = "unknown"; - } - return $result; - } - - /** - * Get a system config setting, including status code, output and standard - * error output. - * - * @param string|null $key - * @param string|null $xRequestId - * @param string|null $output e.g. json - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * @param string|null $ocPath - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws GuzzleException - */ - public static function getSystemConfig( - ?string $key, - ?string $xRequestId = '', - ?string $output = null, - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null, - ?string $ocPath = null - ):array { - $args = []; - $args[] = 'config:system:get'; - $args[] = $key; - - if ($output !== null) { - $args[] = '--output'; - $args[] = $output; - } - - $args[] = '--no-ansi'; - - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * Set a system config setting - * - * @param string|null $key - * @param string|null $value - * @param string|null $xRequestId - * @param string|null $type e.g. boolean or json - * @param string|null $output e.g. json - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * @param string|null $ocPath - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws GuzzleException - */ - public static function setSystemConfig( - ?string $key, - ?string $value, - ?string $xRequestId = '', - ?string $type = null, - ?string $output = null, - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null, - ?string $ocPath = null - ):array { - $args = []; - $args[] = 'config:system:set'; - $args[] = $key; - $args[] = '--value'; - $args[] = $value; - - if ($type !== null) { - $args[] = '--type'; - $args[] = $type; - } - - if ($output !== null) { - $args[] = '--output'; - $args[] = $output; - } - - $args[] = '--no-ansi'; - if ($baseUrl === null) { - $baseUrl = self::$baseUrl; - } - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - - /** - * Get the value of a system config setting - * - * @param string|null $key - * @param string|null $xRequestId - * @param string|null $output e.g. json - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * @param string|null $ocPath - * - * @return string - * @throws GuzzleException if parameters have not been provided yet or the testing app is not enabled - */ - public static function getSystemConfigValue( - ?string $key, - ?string $xRequestId = '', - ?string $output = null, - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null, - ?string $ocPath = null - ):string { - if ($baseUrl === null) { - $baseUrl = self::$baseUrl; - } - return self::getSystemConfig( - $key, - $xRequestId, - $output, - $adminUsername, - $adminPassword, - $baseUrl, - $ocPath - )['stdOut']; - } - /** * Finds all lines containing the given text * @@ -966,36 +510,4 @@ public static function findLines(?string $input, ?string $text):array { } return $results; } - - /** - * Delete a system config setting - * - * @param string|null $key - * @param string|null $xRequestId - * @param string|null $adminUsername - * @param string|null $adminPassword - * @param string|null $baseUrl - * @param string|null $ocPath - * - * @return string[] associated array with "code", "stdOut", "stdErr" - * @throws GuzzleException if parameters have not been provided yet or the testing app is not enabled - */ - public static function deleteSystemConfig( - ?string $key, - ?string $xRequestId = '', - ?string $adminUsername = null, - ?string $adminPassword = null, - ?string $baseUrl = null, - ?string $ocPath = null - ):array { - $args = []; - $args[] = 'config:system:delete'; - $args[] = $key; - - $args[] = '--no-ansi'; - if ($baseUrl === null) { - $baseUrl = self::$baseUrl; - } - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } } diff --git a/tests/acceptance/features/bootstrap/AuthContext.php b/tests/acceptance/features/bootstrap/AuthContext.php index 796eb2bc56d..91bb17cacb8 100644 --- a/tests/acceptance/features/bootstrap/AuthContext.php +++ b/tests/acceptance/features/bootstrap/AuthContext.php @@ -1099,12 +1099,7 @@ public function tokenAuthHasBeenEnforced(string $hasOrNot):void { } else { $value = 'false'; } - $occStatus = SetupHelper::setSystemConfig( - 'token_auth_enforced', - $value, - $this->featureContext->getStepLineRef(), - 'boolean' - ); + $occStatus = ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; if ($occStatus['code'] !== "0") { throw new \Exception("setSystemConfig token_auth_enforced returned error code " . $occStatus['code']); } @@ -1135,22 +1130,6 @@ public function generateAuthTokenForAdmin():string { */ public function deleteTokenAuthEnforcedAfterScenario():void { if ($this->tokenAuthHasBeenSet) { - if ($this->tokenAuthHasBeenSetTo === 'true') { - // Because token auth is enforced, we have to use a token - // (app password) as the password to send to the testing app - // so it will authenticate us. - $appTokenForOccCommand = $this->generateAuthTokenForAdmin(); - } else { - $appTokenForOccCommand = null; - } - SetupHelper::deleteSystemConfig( - 'token_auth_enforced', - $this->featureContext->getStepLineRef(), - null, - $appTokenForOccCommand, - null, - null - ); $this->tokenAuthHasBeenSet = false; $this->tokenAuthHasBeenSetTo = ''; } diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 6dcb8dfe4c7..b6a02f96e5b 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1150,16 +1150,6 @@ public function getStorageId(string $storageName): int { return $storageId; } - /** - * @param string $storageName - * @param integer $storageId - * - * @return void - */ - public function addStorageId(string $storageName, int $storageId): void { - $this->storageIds[$storageId] = $storageName; - } - /** * @param integer $storageId * @@ -1319,60 +1309,6 @@ public function federatedServerExists(): bool { return $this->federatedServerExists; } - /** - * disable CSRF - * - * @return string the previous setting of csrf.disabled - * @throws Exception - */ - public function disableCSRF(): string { - return $this->setCSRFDotDisabled('true'); - } - - /** - * enable CSRF - * - * @return string the previous setting of csrf.disabled - * @throws Exception - */ - public function enableCSRF(): string { - return $this->setCSRFDotDisabled('false'); - } - - /** - * set csrf.disabled - * - * @param string $setting "true", "false" or "" to delete the setting - * - * @return string the previous setting of csrf.disabled - * @throws Exception - */ - public function setCSRFDotDisabled(string $setting): string { - $oldCSRFSetting = SetupHelper::getSystemConfigValue( - 'csrf.disabled', - $this->getStepLineRef() - ); - - if ($setting === "") { - SetupHelper::deleteSystemConfig( - 'csrf.disabled', - $this->getStepLineRef() - ); - } elseif (($setting === 'true') || ($setting === 'false')) { - SetupHelper::setSystemConfig( - 'csrf.disabled', - $setting, - $this->getStepLineRef(), - 'boolean' - ); - } else { - throw new \http\Exception\InvalidArgumentException( - 'setting must be "true", "false" or ""' - ); - } - return \trim($oldCSRFSetting); - } - /** * Parses the response as XML * @@ -3720,28 +3656,6 @@ public function beforeEachStep(BeforeStepScope $scope): void { } } - /** - * @BeforeScenario @local_storage - * - * @return void - * @throws Exception - */ - public function setupLocalStorageBefore(): void { - $storageName = "local_storage"; - $result = SetupHelper::createLocalStorageMount( - $storageName, - $this->getStepLineRef() - ); - $storageId = $result['storageId']; - if (!is_numeric($storageId)) { - throw new Exception( - __METHOD__ . " storageId '$storageId' is not numeric" - ); - } - $this->addStorageId($storageName, (int)$storageId); - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - /** * @AfterScenario * @@ -3768,45 +3682,6 @@ public function deleteAllResourceCreatedByAdmin(): void { } } - /** - * deletes all created storages - * - * @return void - * @throws Exception - */ - public function deleteAllStorages(): void { - $allStorageIds = \array_keys($this->getStorageIds()); - foreach ($allStorageIds as $storageId) { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - $this->storageIds = []; - } - - /** - * @AfterScenario @local_storage - * - * @return void - * @throws Exception - */ - public function removeLocalStorageAfter(): void { - $this->removeExternalStorage(); - $this->removeTemporaryStorageOnServerAfter(); - } - - /** - * This will remove test created external mount points - * - * @AfterScenario @external_storage - * - * @return void - * @throws Exception - */ - public function removeExternalStorage(): void { - if ($this->getStorageIds() !== null) { - $this->deleteAllStorages(); - } - } - /** * @BeforeScenario @temporary_storage_on_server * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index bb1ba69c972..0ef25449f82 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -845,27 +845,6 @@ public function deleteLdapUsersAndGroups():void { } } - /** - * Sets back old settings - * - * @return void - * @throws Exception - */ - public function resetOldLdapConfig():void { - $toDeleteLdapConfig = $this->getToDeleteLdapConfigs(); - foreach ($toDeleteLdapConfig as $configId) { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - foreach ($this->oldLdapConfig as $configId => $settings) { - foreach ($settings as $configKey => $configValue) { - $this->setLdapSetting($configId, $configKey, $configValue); - } - } - foreach ($this->toDeleteDNs as $dn) { - $this->getLdap()->delete($dn, true); - } - } - /** * Manually add skeleton files for a single user on OCIS and reva systems * @@ -3130,20 +3109,6 @@ public function createUser( $user = \trim($user); $method = \trim(\strtolower($method)); switch ($method) { - case "occ": - $result = SetupHelper::createUser( - $user, - $password, - $this->getStepLineRef(), - $displayName, - $email - ); - if ($result["code"] !== "0") { - throw new Exception( - __METHOD__ . " could not create user. {$result['stdOut']} {$result['stdErr']}" - ); - } - break; case "api": case "ldap": $settings = []; @@ -3611,18 +3576,6 @@ public function addUserToGroup(string $user, string $group, ?string $method = nu $this->pushToLastStatusCodesArrays(); } break; - case "occ": - $result = SetupHelper::addUserToGroup( - $group, - $user, - $this->getStepLineRef() - ); - if ($checkResult && ($result["code"] !== "0")) { - throw new Exception( - "could not add user to group. {$result['stdOut']} {$result['stdErr']}" - ); - } - break; case "ldap": try { $this->addUserToLdapGroup( @@ -3872,19 +3825,6 @@ public function createTheGroup(string $group, ?string $method = null):void { ); } break; - case "occ": - $result = SetupHelper::createGroup( - $group, - $this->getStepLineRef() - ); - if ($result["code"] == 0) { - $groupCanBeDeleted = true; - } else { - throw new Exception( - "could not create group '$group'. {$result['stdOut']} {$result['stdErr']}" - ); - } - break; case "ldap": try { $this->createLdapGroup($group); diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index f5e26be58bd..7c55831306e 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -1022,7 +1022,7 @@ public function updateLastShareWithSettings( $this->shareFields ); $bodyRows = $body->getRowsHash(); - + if (\array_key_exists('password', $bodyRows)) { $bodyRows['password'] = $this->getActualPassword($bodyRows['password']); } @@ -3335,19 +3335,6 @@ public function userReactsToShareOfferedBy(string $user, string $action, string $dataResponded = $this->getAllSharesSharedWithUser($user); $shareId = null; foreach ($dataResponded as $shareElement) { - $shareFolder = \trim( - SetupHelper::getSystemConfigValue('share_folder', $this->getStepLineRef()) - ); - - if ($shareFolder) { - $shareFolder = \ltrim($shareFolder, '/'); - } - - // Add share folder to share path if given - if ($shareFolder && !(strpos($share, "/$shareFolder") === 0)) { - $share = '/' . $shareFolder . $share; - } - // SharingHelper::SHARE_STATES has the mapping between the words for share states // like "accepted", "pending",... and the integer constants 0, 1,... that are in // the "state" field of the share data. diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 798ce9cf912..b1580554427 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -5393,27 +5393,6 @@ public function pauseUploadDelete():void { } } - /** - * reset settings if they were set in the scenario - * - * @AfterScenario - * - * @return void - * @throws Exception - */ - public function resetPreviousSettingsAfterScenario():void { - if ($this->previousAsyncSetting === "") { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } elseif ($this->previousAsyncSetting !== null) { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - if ($this->previousDavSlowdownSetting === "") { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } elseif ($this->previousDavSlowdownSetting !== null) { - ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - } - /** * @Given /^the administrator has (enabled|disabled) the file version storage feature/ *