diff --git a/tests/TestHelpers/HttpRequestHelper.php b/tests/TestHelpers/HttpRequestHelper.php index 828314681cc..caef4e44415 100644 --- a/tests/TestHelpers/HttpRequestHelper.php +++ b/tests/TestHelpers/HttpRequestHelper.php @@ -76,12 +76,9 @@ public static function setOCSelectorCookie(string $oCSelectorCookie): void { * @return int */ public static function numRetriesOnHttpTooEarly():int { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently reva and oCIS may return HTTP_TOO_EARLY - // So try up to 10 times before giving up. - return 10; - } - return 0; + // Currently reva and oCIS may return HTTP_TOO_EARLY + // So try up to 10 times before giving up. + return 10; } /** diff --git a/tests/TestHelpers/LoggingHelper.php b/tests/TestHelpers/LoggingHelper.php index 574527ef8ca..33f52e02f38 100644 --- a/tests/TestHelpers/LoggingHelper.php +++ b/tests/TestHelpers/LoggingHelper.php @@ -53,32 +53,8 @@ class LoggingHelper { public static function getLogFilePath( ?string $xRequestId = '' ):string { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - return ""; - } - $result = SetupHelper::runOcc( - ['log:owncloud'], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not get owncloud log file information" . - $result ["stdOut"] . " " . $result ["stdErr"] - ); - } - \preg_match( - "/Log backend ownCloud: (\w+)\sLog file: (.*)/", - $result ['stdOut'], - $matches - ); - if (!isset($matches[1]) || $matches[1] !== "enabled") { - throw new Exception("log backend is not set to 'owncloud'"); - } - if (!isset($matches[2])) { - throw new Exception("could not get owncloud log file information"); - } - return $matches[2]; + // Currently we don't interact with the log file on reva or OCIS + return ""; } /** @@ -132,23 +108,7 @@ public static function getLogFileContent( public static function getLogLevel( ?string $xRequestId = '' ):string { - if (OcisHelper::isTestingOnOcisOrReva()) { - return "debug"; - } - $result = SetupHelper::runOcc( - ["log:manage"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not get log level " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } - if (!\preg_match("/Log level:\s(\w+)\s\(/", $result["stdOut"], $matches)) { - throw new Exception("could not get log level"); - } - return \strtolower($matches[1]); + return "debug"; } /** @@ -163,23 +123,8 @@ public static function setLogLevel( ?string $logLevel, ?string $xRequestId = '' ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we can't manage log file settings on reva or OCIS - return; - } - if (!\in_array($logLevel, self::LOG_LEVEL_ARRAY)) { - throw new InvalidArgumentException("invalid log level"); - } - $result = SetupHelper::runOcc( - ["log:manage", "--level=$logLevel"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not set log level " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } + // Currently we can't manage log file settings on reva or OCIS + return; } /** @@ -193,28 +138,7 @@ public static function setLogLevel( public static function getLogBackend( ?string $xRequestId = '' ):string { - if (OcisHelper::isTestingOnOcisOrReva()) { - return "errorlog"; - } - $result = SetupHelper::runOcc( - ["log:manage"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not get log backend " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } - $pregResult = \preg_match( - "/Enabled logging backend:\s(\w+)\n/", - $result ["stdOut"], - $matches - ); - if (!$pregResult) { - throw new Exception("could not get log backend"); - } - return \strtolower($matches[1]); + return "errorlog"; } /** @@ -232,20 +156,8 @@ public static function setLogBackend( if (!\in_array($backend, ["owncloud", "syslog", "errorlog"])) { throw new InvalidArgumentException("invalid log backend"); } - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we can't manage log file settings on reva or OCIS - return; - } - $result = SetupHelper::runOcc( - ["log:manage", "--backend=$backend"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not set log backend " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } + // Currently we can't manage log file settings on reva or OCIS + return; } /** @@ -259,28 +171,7 @@ public static function setLogBackend( public static function getLogTimezone( ?string $xRequestId = '' ):string { - if (OcisHelper::isTestingOnOcisOrReva()) { - return "UTC"; - } - $result = SetupHelper::runOcc( - ["log:manage"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not get log timezone " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } - $pregResult = \preg_match( - "/Log timezone:\s(\w+)/", - $result ["stdOut"], - $matches - ); - if (!$pregResult) { - throw new Exception("could not get log timezone"); - } - return $matches[1]; + return "UTC"; } /** @@ -295,20 +186,8 @@ public static function setLogTimezone( ?string $timezone, ?string $xRequestId = '' ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we can't manage log file settings on reva or OCIS - return; - } - $result = SetupHelper::runOcc( - ["log:manage", "--timezone=$timezone"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not set log timezone " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } + // Currently we can't manage log file settings on reva or OCIS + return; } /** @@ -327,21 +206,8 @@ public static function clearLogFile( ?string $adminPassword, ?string $xRequestId = '' ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - return; - } - $result = OcsApiHelper::sendRequest( - $baseUrl, - $adminUsername, - $adminPassword, - "DELETE", - "/apps/testing/api/v1/logfile", - $xRequestId - ); - if ($result->getStatusCode() !== 200) { - throw new Exception("could not clear logfile"); - } + // Currently we don't interact with the log file on reva or OCIS + return; } /** @@ -360,41 +226,8 @@ public static function restoreLoggingStatus( ?string $timezone, ?string $xRequestId = '' ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - return; - } - if (!\in_array(\strtolower($logLevel), self::LOG_LEVEL_ARRAY)) { - throw new InvalidArgumentException("invalid log level"); - } - if (!\in_array(\strtolower($backend), ["owncloud", "syslog", "errorlog"])) { - throw new InvalidArgumentException("invalid log backend"); - } - - $commands = ["log:manage"]; - - if ($timezone) { - \array_push($commands, "--timezone=$timezone"); - } - if ($logLevel) { - \array_push($commands, "--backend=$backend"); - } - if ($backend) { - \array_push($commands, "--level=$logLevel"); - } - - if (\count($commands) > 1) { - $result = SetupHelper::runOcc( - $commands, - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not restore log status " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } - } + // Currently we don't interact with the log file on reva or OCIS + return; } /** @@ -408,50 +241,10 @@ public static function restoreLoggingStatus( public static function getLogInfo( ?string $xRequestId = '' ):array { - if (OcisHelper::isTestingOnOcisOrReva()) { - return [ - "level" => "debug", - "backend" => "errorlog", - "timezone" => "UTC" - ]; - } - $result = SetupHelper::runOcc( - ["log:manage"], - $xRequestId - ); - if ($result["code"] != 0) { - throw new Exception( - "could not get log level " . $result ["stdOut"] . " " . - $result ["stdErr"] - ); - } - - $logging = []; - if (!\preg_match("/Log level:\s(\w+)\s\(/", $result["stdOut"], $matches)) { - throw new Exception("could not get log level"); - } - $logging["level"] = $matches[1]; - - $pregResult = \preg_match( - "/Log timezone:\s(\w+)/", - $result ["stdOut"], - $matches - ); - if (!$pregResult) { - throw new Exception("could not get log timezone"); - } - $logging["timezone"] = $matches[1]; - - $pregResult = \preg_match( - "/Enabled logging backend:\s(\w+)\n/", - $result ["stdOut"], - $matches - ); - if (!$pregResult) { - throw new Exception("could not get log backend"); - } - $logging["backend"] = $matches[1]; - - return $logging; + return [ + "level" => "debug", + "backend" => "errorlog", + "timezone" => "UTC" + ]; } } diff --git a/tests/TestHelpers/OcisHelper.php b/tests/TestHelpers/OcisHelper.php index e8627babaef..38f13ab5aec 100644 --- a/tests/TestHelpers/OcisHelper.php +++ b/tests/TestHelpers/OcisHelper.php @@ -47,18 +47,11 @@ public static function isTestingOnReva():bool { return (\getenv("TEST_REVA") === "true"); } - /** - * @return bool - */ - public static function isTestingOnOcisOrReva():bool { - return (self::isTestingOnOcis() || self::isTestingOnReva()); - } - /** * @return bool */ public static function isTestingOnOc10():bool { - return (!self::isTestingOnOcisOrReva()); + return false; } /** @@ -307,7 +300,7 @@ public static function getBindPassword():string { */ private static function getOcisRevaDataRoot():string { $root = \getenv("OCIS_REVA_DATA_ROOT"); - if (($root === false || $root === "") && self::isTestingOnOcisOrReva()) { + if ($root === false || $root === "") { $root = "/var/tmp/ocis/owncloud/"; } if (!\file_exists($root)) { diff --git a/tests/TestHelpers/SetupHelper.php b/tests/TestHelpers/SetupHelper.php index 16e7d043ea3..0b6809dd5e5 100644 --- a/tests/TestHelpers/SetupHelper.php +++ b/tests/TestHelpers/SetupHelper.php @@ -789,54 +789,7 @@ public static function runBulkOcc( ?string $adminPassword = null, ?string $baseUrl = null ):array { - if (OcisHelper::isTestingOnOcisOrReva()) { - return []; - } - $baseUrl = self::checkBaseUrl($baseUrl, "runOcc"); - $adminUsername = self::checkAdminUsername($adminUsername, "runOcc"); - $adminPassword = self::checkAdminPassword($adminPassword, "runOcc"); - - if (!\is_array($commands)) { - throw new Exception("commands must be an array"); - } - - $isTestingAppEnabledText = "Is the testing app installed and enabled?\n"; - $bodies = []; - - foreach ($commands as $occ) { - if (!\array_key_exists('command', $occ)) { - throw new \InvalidArgumentException("command key is missing in array passed to runBulkOcc"); - } - - $body = [ - 'command' => \implode(' ', $occ['command']) - ]; - - if (isset($occ['envVariables'])) { - $body['env_variables'] = $occ['envVariables']; - } - \array_push($bodies, $body); - } - try { - $result = OcsApiHelper::sendRequest( - $baseUrl, - $adminUsername, - $adminPassword, - "POST", - "/apps/testing/api/v1/occ/bulk?format=json", - $xRequestId, - \json_encode($bodies) - ); - } catch (ServerException $e) { - throw new Exception( - "Could not execute 'occ'. " . - $isTestingAppEnabledText . - $e->getResponse()->getBody() - ); - } - $result = \json_decode($result->getBody()->getContents()); - - return $result->ocs->data; + return []; } /** @@ -864,129 +817,7 @@ public static function runOcc( ?string $ocPath = null, ?array $envVariables = null ):array { - if (OcisHelper::isTestingOnOcisOrReva() && !OcisHelper::isTestingParallelDeployment()) { - return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; - } - $baseUrl = self::checkBaseUrl($baseUrl, "runOcc"); - $adminUsername = self::checkAdminUsername($adminUsername, "runOcc"); - $adminPassword = self::checkAdminPassword($adminPassword, "runOcc"); - if (self::$ocPath === null - && $ocPath === null - ) { - throw new Exception( - "runOcc called without ocPath - pass the ocPath or call SetupHelper::init" - ); - } - if ($ocPath === null) { - $ocPath = self::$ocPath; - } else { - $ocPath = self::normaliseOcPath($ocPath); - } - - $body = []; - $argsString = \implode(' ', $args); - $body['command'] = $argsString; - - if ($envVariables !== null) { - $body['env_variables'] = $envVariables; - } - - $isTestingAppEnabledText = "Is the testing app installed and enabled?\n"; - - try { - $result = OcsApiHelper::sendRequest( - $baseUrl, - $adminUsername, - $adminPassword, - "POST", - $ocPath, - $xRequestId, - $body - ); - } catch (ServerException $e) { - throw new Exception( - "Could not execute 'occ'. " . - $isTestingAppEnabledText . - $e->getResponse()->getBody() - ); - } - - $return = []; - $contents = $result->getBody()->getContents(); - $resultXml = \simplexml_load_string($contents); - - if ($resultXml === false) { - $status = $result->getStatusCode(); - throw new Exception( - "Response is not valid XML after executing 'occ $argsString'. " . - "HTTP status was $status. " . - $isTestingAppEnabledText . - "Response contents were '$contents'" - ); - } - - $return['code'] = $resultXml->xpath("//ocs/data/code"); - $return['stdOut'] = $resultXml->xpath("//ocs/data/stdOut"); - $return['stdErr'] = $resultXml->xpath("//ocs/data/stdErr"); - - if (!isset($return['code'][0])) { - throw new Exception( - "Return code not found after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - if (!isset($return['stdOut'][0])) { - throw new Exception( - "Return stdOut not found after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - if (!isset($return['stdErr'][0])) { - throw new Exception( - "Return stdErr not found after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - if (!\is_a($return['code'][0], "SimpleXMLElement")) { - throw new Exception( - "Return code is not a SimpleXMLElement after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - if (!\is_a($return['stdOut'][0], "SimpleXMLElement")) { - throw new Exception( - "Return stdOut is not a SimpleXMLElement after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - if (!\is_a($return['stdErr'][0], "SimpleXMLElement")) { - throw new Exception( - "Return stdErr is not a SimpleXMLElement after executing 'occ $argsString'. " . - $isTestingAppEnabledText . - $contents - ); - } - - $return['code'] = $return['code'][0]->__toString(); - $return['stdOut'] = $return['stdOut'][0]->__toString(); - $return['stdErr'] = $return['stdErr'][0]->__toString(); - self::resetOpcache( - $baseUrl, - $adminUsername, - $adminPassword, - $xRequestId - ); - return $return; + return ['code' => '', 'stdOut' => '', 'stdErr' => '' ]; } /** diff --git a/tests/acceptance/features/bootstrap/AppConfigurationContext.php b/tests/acceptance/features/bootstrap/AppConfigurationContext.php index 90d954ebe54..580e3524427 100644 --- a/tests/acceptance/features/bootstrap/AppConfigurationContext.php +++ b/tests/acceptance/features/bootstrap/AppConfigurationContext.php @@ -73,12 +73,7 @@ public function adminSetsServerParameterToUsingAPI( public function serverParameterHasBeenSetTo(string $parameter, string $app, string $value):void { // The capturing group of the regex always includes the quotes at each // end of the captured string, so trim them. - if (\TestHelpers\OcisHelper::isTestingOnOcisOrReva()) { - return; - } - $value = \trim($value, $value[0]); - $this->modifyAppConfig($app, $parameter, $value); - $this->featureContext->clearStatusCodeArrays(); + return; } /** diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 95c793b84fc..11d27f1f529 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1593,11 +1593,7 @@ public function isAPublicLinkUrl(string $url): bool { $urlEnding = \substr($url, \strlen($this->getBaseUrl() . '/')); } - if (OcisHelper::isTestingOnOcisOrReva()) { - $matchResult = \preg_match("%^(#/)?s/([a-zA-Z0-9]{15})$%", $urlEnding); - } else { - $matchResult = \preg_match("%^(index.php/)?s/([a-zA-Z0-9]{15})$%", $urlEnding); - } + $matchResult = \preg_match("%^(#/)?s/([a-zA-Z0-9]{15})$%", $urlEnding); // preg_match returns (int) 1 for a match, we want to return a boolean. if ($matchResult === 1) { @@ -3915,24 +3911,6 @@ public function clearFileLocksForServer(string $serverUrl): void { Assert::assertEquals("200", $response->getStatusCode()); } - /** - * After Scenario. clear file locks - * - * @AfterScenario - * - * @return void - * @throws Exception - */ - public function clearFileLocks(): void { - if (!OcisHelper::isTestingOnOcisOrReva()) { - $this->authContext->deleteTokenAuthEnforcedAfterScenario(); - $this->clearFileLocksForServer($this->getBaseUrl()); - if ($this->remoteBaseUrl !== $this->localBaseUrl) { - $this->clearFileLocksForServer($this->getRemoteBaseUrl()); - } - } - } - /** * @AfterScenario * @@ -3956,72 +3934,7 @@ public function clearSpaceId(): void { * @throws Exception */ public static function useBigFileIDs(BeforeSuiteScope $scope): void { - if (OcisHelper::isTestingOnOcisOrReva()) { - return; - } - $fullUrl = \getenv('TEST_SERVER_URL'); - if (\substr($fullUrl, -1) !== '/') { - $fullUrl .= '/'; - } - $fullUrl .= "ocs/v1.php/apps/testing/api/v1/increasefileid"; - $suiteSettingsContexts = $scope->getSuite()->getSettings()['contexts']; - $adminUsername = null; - $adminPassword = null; - foreach ($suiteSettingsContexts as $context) { - if (isset($context[__CLASS__])) { - $adminUsername = $context[__CLASS__]['adminUsername']; - $adminPassword = $context[__CLASS__]['adminPassword']; - break; - } - } - - // get the admin username from the environment (if defined) - $adminUsernameFromEnvironment = self::getAdminUsernameFromEnvironment(); - if ($adminUsernameFromEnvironment !== false) { - $adminUsername = $adminUsernameFromEnvironment; - } - - // get the admin password from the environment (if defined) - $adminPasswordFromEnvironment = self::getAdminPasswordFromEnvironment(); - if ($adminPasswordFromEnvironment !== false) { - $adminPassword = $adminPasswordFromEnvironment; - } - - if (($adminUsername === null) || ($adminPassword === null)) { - throw new Exception( - "Could not find adminUsername and/or adminPassword in useBigFileIDs" - ); - } - - HttpRequestHelper::post( - $fullUrl, - '', - $adminUsername, - $adminPassword - ); - } - - /** - * 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; + return; } /** @@ -4349,25 +4262,6 @@ public function restoreTrustedServers(string $server): void { } } - /** - * - * @return void - * @throws Exception - */ - public function restoreParametersAfterScenario(): void { - if (!OcisHelper::isTestingOnOcisOrReva()) { - $this->authContext->deleteTokenAuthEnforcedAfterScenario(); - $user = $this->getCurrentUser(); - $this->setCurrentUser($this->getAdminUsername()); - $this->runFunctionOnEveryServer( - function ($server) { - $this->restoreParameters($server); - } - ); - $this->setCurrentUser($user); - } - } - /** * Get the array of trusted servers in format ["url" => "id"] * @@ -4440,37 +4334,6 @@ public function getBodyForOCSRequest(string $method, string $property): ?string return $body; } - /** - * @BeforeScenario - * - * @return void - * @throws Exception - */ - public function prepareParametersBeforeScenario(): void { - if (!OcisHelper::isTestingOnOcisOrReva()) { - $user = $this->getCurrentUser(); - $this->setCurrentUser($this->getAdminUsername()); - $previousServer = $this->getCurrentServer(); - foreach (['LOCAL', 'REMOTE'] as $server) { - if (($server === 'LOCAL') || $this->federatedServerExists()) { - $this->usingServer($server); - $this->resetAppConfigs(); - $result = SetupHelper::runOcc( - ['config:list', '--private'], - $this->getStepLineRef(), - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getBaseUrl(), - $this->getOcPath() - ); - $this->savedConfigList[$server] = \json_decode($result['stdOut'], true); - } - } - $this->usingServer($previousServer); - $this->setCurrentUser($user); - } - } - /** * Before Scenario to Save trusted Servers * @@ -4486,85 +4349,6 @@ public function setInitialTrustedServersBeforeScenario(): void { ]; } - /** - * 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/LoggingContext.php b/tests/acceptance/features/bootstrap/LoggingContext.php index c361da5202a..6cd49681b3b 100644 --- a/tests/acceptance/features/bootstrap/LoggingContext.php +++ b/tests/acceptance/features/bootstrap/LoggingContext.php @@ -65,86 +65,9 @@ public function theLastLinesOfTheLogFileShouldContainEntriesWithTheseAttributes( int $ignoredLines = 0, ?TableNode $expectedLogEntries = null ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - // So skip processing this test step. - return; - } - $ignoredLines = (int) $ignoredLines; - //-1 because getRows gives also the header - $linesToRead = \count($expectedLogEntries->getRows()) - 1 + $ignoredLines; - $logLines = LoggingHelper::getLogFileContent( - $this->featureContext->getBaseUrl(), - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - $this->featureContext->getStepLineRef(), - $linesToRead - ); - $lineNo = 0; - foreach ($expectedLogEntries as $expectedLogEntry) { - $logEntry = \json_decode($logLines[$lineNo], true); - if ($logEntry === null) { - throw new Exception("the log line :\n{$logLines[$lineNo]} is not valid JSON"); - } - - foreach (\array_keys($expectedLogEntry) as $attribute) { - if ($comparingMode === 'matching') { - $expectedLogEntry[$attribute] - = $this->featureContext->substituteInLineCodes( - $expectedLogEntry[$attribute], - null, - ['preg_quote' => ['/']] - ); - } else { - $expectedLogEntry[$attribute] - = $this->featureContext->substituteInLineCodes( - $expectedLogEntry[$attribute] - ); - } - - if ($expectedLogEntry[$attribute] !== "") { - Assert::assertArrayHasKey( - $attribute, - $logEntry, - "could not find attribute: '$attribute' in log entry: '{$logLines[$lineNo]}'" - ); - $message = "log entry:\n{$logLines[$lineNo]}\n"; - if (!\is_string($logEntry[$attribute])) { - $logEntry[$attribute] = \json_encode( - $logEntry[$attribute], - JSON_UNESCAPED_SLASHES - ); - } - if ($comparingMode === 'with') { - Assert::assertEquals( - $expectedLogEntry[$attribute], - $logEntry[$attribute], - $message - ); - } elseif ($comparingMode === 'containing') { - Assert::assertStringContainsString( - $expectedLogEntry[$attribute], - $logEntry[$attribute], - $message - ); - } elseif ($comparingMode === 'matching') { - Assert::assertMatchesRegularExpression( - $expectedLogEntry[$attribute], - $logEntry[$attribute], - $message - ); - } else { - throw new \InvalidArgumentException( - "$comparingMode is not a valid mode" - ); - } - } - } - $lineNo++; - if (($lineNo + $ignoredLines) >= $linesToRead) { - break; - } - } + // Currently we don't interact with the log file on reva or OCIS + // So skip processing this test step. + return; } /** @@ -279,90 +202,9 @@ private function assertLogFileContainsAtLeastOneEntryMatchingTable( TableNode $expectedLogEntries, bool $regexCompare = false ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - // So skip processing this test step. - return; - } - $logLines = LoggingHelper::getLogFileContent( - $this->featureContext->getBaseUrl(), - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - $this->featureContext->getStepLineRef() - ); - $expectedLogEntries = $expectedLogEntries->getHash(); - foreach ($logLines as $logLine) { - $logEntry = \json_decode($logLine, true); - if ($logEntry === null) { - throw new Exception("the log line :\n{$logLine} is not valid JSON"); - } - //reindex the array, we might have deleted entries - $expectedLogEntries = \array_values($expectedLogEntries); - for ($entryNo = 0; $entryNo < \count($expectedLogEntries); $entryNo++) { - $count = 0; - $expectedLogEntry = $expectedLogEntries[$entryNo]; - $foundLine = true; - foreach (\array_keys($expectedLogEntry) as $attribute) { - if ($expectedLogEntry[$attribute] === "") { - //don't check empty table entries - continue; - } - if (!\array_key_exists($attribute, $logEntry)) { - //this line does not have the attribute we are looking for - $foundLine = false; - break; - } - if (!\is_string($logEntry[$attribute])) { - $logEntry[$attribute] = \json_encode( - $logEntry[$attribute], - JSON_UNESCAPED_SLASHES - ); - } - - if ($regexCompare === true) { - $expectedLogEntry[$attribute] - = $this->featureContext->substituteInLineCodes( - $expectedLogEntry[$attribute], - null, - ['preg_quote' => ['/']] - ); - $matchAttribute = \preg_match( - $expectedLogEntry[$attribute], - $logEntry[$attribute] - ); - } else { - $expectedLogEntry[$attribute] - = $this->featureContext->substituteInLineCodes( - $expectedLogEntry[$attribute] - ); - $matchAttribute - = ($expectedLogEntry[$attribute] === $logEntry[$attribute]); - } - if (!$matchAttribute) { - $foundLine = false; - break; - } - if ($matchAttribute and !$shouldOrNot) { - $count += 1; - Assert::assertNotEquals( - $count, - \count($expectedLogEntry), - "The entry matches" - ); - } - } - if ($foundLine === true) { - unset($expectedLogEntries[$entryNo]); - } - } - } - $notFoundLines = \print_r($expectedLogEntries, true); - if ($shouldOrNot) { - Assert::assertEmpty( - $expectedLogEntries, - "could not find these expected line(s):\n $notFoundLines" - ); - } + // Currently we don't interact with the log file on reva or OCIS + // So skip processing this test step. + return; } /** @@ -387,50 +229,9 @@ public function theLogFileShouldNotContainAnyLogEntriesWithTheseAttributes( $withOrContaining, TableNode $logEntriesExpectedNotToExist ):void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // Currently we don't interact with the log file on reva or OCIS - // So skip processing this test step. - return; - } - $logLines = LoggingHelper::getLogFileContent( - $this->featureContext->getBaseUrl(), - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - $this->featureContext->getStepLineRef() - ); - foreach ($logLines as $logLine) { - $logEntry = \json_decode($logLine, true); - if ($logEntry === null) { - throw new Exception("the log line :\n$logLine is not valid JSON"); - } - foreach ($logEntriesExpectedNotToExist as $logEntryExpectedNotToExist) { - $match = true; // start by assuming the worst, we match the unwanted log entry - foreach (\array_keys($logEntryExpectedNotToExist) as $attribute) { - $logEntryExpectedNotToExist[$attribute] - = $this->featureContext->substituteInLineCodes( - $logEntryExpectedNotToExist[$attribute] - ); - - if (isset($logEntry[$attribute]) && ($logEntryExpectedNotToExist[$attribute] !== "")) { - if ($withOrContaining === 'with') { - $match = ($logEntryExpectedNotToExist[$attribute] === $logEntry[$attribute]); - } else { - $match = (\strpos($logEntry[$attribute], $logEntryExpectedNotToExist[$attribute]) !== false); - } - } - if (!isset($logEntry[$attribute])) { - $match = false; - } - if (!$match) { - break; - } - } - } - Assert::assertFalse( - $match, - "found a log entry that should not be there\n$logLine\n" - ); - } + // Currently we don't interact with the log file on reva or OCIS + // So skip processing this test step. + return; } /** diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index f1cf17664bf..4164068a880 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -635,26 +635,6 @@ public function connectToLdap(array $suiteParameters):void { if (!$this->skipImportLdif) { $this->importLdifFile($ldifFile); } - $this->theLdapUsersHaveBeenResynced(); - } - - /** - * @Given the LDAP users have been resynced - * - * @return void - * @throws Exception - */ - public function theLdapUsersHaveBeenReSynced():void { - // we need to sync ldap users when testing for parallel deployment - if (!OcisHelper::isTestingOnOcisOrReva() || OcisHelper::isTestingParallelDeployment()) { - $occResult = SetupHelper::runOcc( - ['user:sync', 'OCA\User_LDAP\User_Proxy', '-m', 'remove'], - $this->getStepLineRef() - ); - if ($occResult['code'] !== "0") { - throw new Exception(__METHOD__ . " could not sync LDAP users " . $occResult['stdErr']); - } - } } /** @@ -762,7 +742,6 @@ public function createLdapUser(array $setting):void { $this->ldap->add($newDN, $entry); } $this->ldapCreatedUsers[] = $setting["userid"]; - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -857,36 +836,18 @@ public function setLdapSetting(string $configId, string $configKey, string $conf * @throws Exception */ public function deleteLdapUsersAndGroups():void { - $isOcisOrReva = OcisHelper::isTestingOnOcisOrReva(); foreach ($this->ldapCreatedUsers as $user) { - if ($isOcisOrReva) { - $this->ldap->delete( - "uid=" . ldap_escape($user, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, - ); - } + $this->ldap->delete( + "uid=" . ldap_escape($user, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, + ); $this->rememberThatUserIsNotExpectedToExist($user); } foreach ($this->ldapCreatedGroups as $group) { - if ($isOcisOrReva) { - $this->ldap->delete( - "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, - ); - } - $this->rememberThatGroupIsNotExpectedToExist($group); - } - if (!$isOcisOrReva || !$this->skipImportLdif) { - //delete ou from LDIF import $this->ldap->delete( - "ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, - true - ); - //delete all created ldap groups - $this->ldap->delete( - "ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, - true + "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, ); + $this->rememberThatGroupIsNotExpectedToExist($group); } - $this->theLdapUsersHaveBeenResynced(); } /** @@ -1030,18 +991,16 @@ public function usersHaveBeenCreated( $attributesToCreateUser['userid'] = $userAttributes['userid']; $attributesToCreateUser['password'] = $userAttributes['password']; $attributesToCreateUser['displayname'] = $userAttributes['displayName']; - if (OcisHelper::isTestingOnOcisOrReva()) { - $attributesToCreateUser['username'] = $userAttributes['userid']; - if ($userAttributes['email'] === null) { - Assert::assertArrayHasKey( - 'userid', - $userAttributes, - __METHOD__ . " userAttributes array does not have key 'userid'" - ); - $attributesToCreateUser['email'] = $userAttributes['userid'] . '@owncloud.com'; - } else { - $attributesToCreateUser['email'] = $userAttributes['email']; - } + $attributesToCreateUser['username'] = $userAttributes['userid']; + if ($userAttributes['email'] === null) { + Assert::assertArrayHasKey( + 'userid', + $userAttributes, + __METHOD__ . " userAttributes array does not have key 'userid'" + ); + $attributesToCreateUser['email'] = $userAttributes['userid'] . '@owncloud.com'; + } else { + $attributesToCreateUser['email'] = $userAttributes['email']; } if ($useGraph) { $body = \TestHelpers\GraphHelper::prepareCreateUserPayload( @@ -1130,32 +1089,11 @@ public function usersHaveBeenCreated( $userAttributes['id'] ); - if (OcisHelper::isTestingOnOcisOrReva()) { - OcisHelper::createEOSStorageHome( - $this->getBaseUrl(), - $userAttributes['userid'], - $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 - continue; - } - if (isset($userAttributes['displayName'])) { - $editData[] = ['user' => $userAttributes['userid'], 'key' => 'displayname', 'value' => $userAttributes['displayName']]; - } - if (isset($userAttributes['email'])) { - $editData[] = ['user' => $userAttributes['userid'], 'key' => 'email', 'value' => $userAttributes['email']]; - } - } - // Edit the users in parallel to make the process faster. - if (!OcisHelper::isTestingOnOcisOrReva() && !$useLdap && \count($editData) > 0) { - UserHelper::editUserBatch( + OcisHelper::createEOSStorageHome( $this->getBaseUrl(), - $editData, - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->stepLineRef + $userAttributes['userid'], + $userAttributes['password'], + $this->getStepLineRef() ); } @@ -1167,7 +1105,7 @@ public function usersHaveBeenCreated( // 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 && OcisHelper::isTestingOnOcisOrReva()) { + if ($skeleton) { $this->manuallyAddSkeletonFiles($usersAttributes); } @@ -1457,10 +1395,8 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv $displayname = \array_key_exists("displayname", $table) ? $table["displayname"] : null; $email = \array_key_exists("email", $table) ? $table["email"] : null; - if (OcisHelper::isTestingOnOcisOrReva()) { - if ($email === null) { - $email = $username . '@owncloud.com'; - } + if ($email === null) { + $email = $username . '@owncloud.com'; } $userAttributes = [ @@ -1476,9 +1412,7 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv $userAttributes[] = ["email", $email]; } - if (OcisHelper::isTestingOnOcisOrReva()) { - $userAttributes[] = ["username", $username]; - } + $userAttributes[] = ["username", $username]; $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), @@ -1494,9 +1428,7 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv null, $this->theHTTPStatusCodeWasSuccess() ); - if (OcisHelper::isTestingOnOcisOrReva()) { - $this->manuallyAddSkeletonFilesForUser($username, $password); - } + $this->manuallyAddSkeletonFilesForUser($username, $password); } /** @@ -1511,20 +1443,15 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv public function adminSendsUserCreationRequestUsingTheProvisioningApi(string $user, string $password):void { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); - if (OcisHelper::isTestingOnOcisOrReva()) { - $email = $user . '@owncloud.com'; - $bodyTable = new TableNode( - [ - ['userid', $user], - ['password', $password], - ['username', $user], - ['email', $email] - ] - ); - } else { - $email = null; - $bodyTable = new TableNode([['userid', $user], ['password', $password]]); - } + $email = $user . '@owncloud.com'; + $bodyTable = new TableNode( + [ + ['userid', $user], + ['password', $password], + ['username', $user], + ['email', $email] + ] + ); $this->emptyLastHTTPStatusCodesArray(); $this->emptyLastOCSStatusCodesArray(); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( @@ -1543,7 +1470,7 @@ public function adminSendsUserCreationRequestUsingTheProvisioningApi(string $use null, $success ); - if (OcisHelper::isTestingOnOcisOrReva() && $success) { + if ($success) { OcisHelper::createEOSStorageHome( $this->getBaseUrl(), $user, @@ -1583,20 +1510,15 @@ public function theAdministratorSendsAUserCreationRequestForTheFollowingUsersWit public function userSendsUserCreationRequestUsingTheProvisioningApi(string $user, string $userToCreate, string $password):void { $userToCreate = $this->getActualUsername($userToCreate); $password = $this->getActualPassword($password); - if (OcisHelper::isTestingOnOcisOrReva()) { - $email = $userToCreate . '@owncloud.com'; - $bodyTable = new TableNode( - [ - ['userid', $userToCreate], - ['password', $password], - ['username', $userToCreate], - ['email', $email] - ] - ); - } else { - $email = null; - $bodyTable = new TableNode([['userid', $userToCreate], ['password', $password]]); - } + $email = $userToCreate . '@owncloud.com'; + $bodyTable = new TableNode( + [ + ['userid', $userToCreate], + ['password', $password], + ['username', $userToCreate], + ['email', $email] + ] + ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $user, "POST", @@ -1630,23 +1552,16 @@ public function theAdministratorCreatesUserPasswordGroupUsingTheProvisioningApi( ):void { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); - if (OcisHelper::isTestingOnOcisOrReva()) { - $email = $user . '@owncloud.com'; - $bodyTable = new TableNode( - [ - ['userid', $user], - ['password', $password], - ['username', $user], - ['email', $email], - ['groups[]', $group], - ] - ); - } else { - $email = null; - $bodyTable = new TableNode( - [['userid', $user], ['password', $password], ['groups[]', $group]] - ); - } + $email = $user . '@owncloud.com'; + $bodyTable = new TableNode( + [ + ['userid', $user], + ['password', $password], + ['username', $user], + ['email', $email], + ['groups[]', $group], + ] + ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $this->getAdminUsername(), "POST", @@ -1661,9 +1576,7 @@ public function theAdministratorCreatesUserPasswordGroupUsingTheProvisioningApi( null, $this->theHTTPStatusCodeWasSuccess() ); - if (OcisHelper::isTestingOnOcisOrReva()) { - $this->manuallyAddSkeletonFilesForUser($user, $password); - } + $this->manuallyAddSkeletonFilesForUser($user, $password); } /** @@ -1685,23 +1598,16 @@ public function theGroupAdminCreatesUserPasswordGroupUsingTheProvisioningApi( ):void { $userToCreate = $this->getActualUsername($userToCreate); $password = $this->getActualPassword($password); - if (OcisHelper::isTestingOnOcisOrReva()) { - $email = $userToCreate . '@owncloud.com'; - $bodyTable = new TableNode( - [ - ['userid', $userToCreate], - ['password', $userToCreate], - ['username', $userToCreate], - ['email', $email], - ['groups[]', $group], - ] - ); - } else { - $email = null; - $bodyTable = new TableNode( - [['userid', $userToCreate], ['password', $password], ['groups[]', $group]] - ); - } + $email = $userToCreate . '@owncloud.com'; + $bodyTable = new TableNode( + [ + ['userid', $userToCreate], + ['password', $userToCreate], + ['username', $userToCreate], + ['email', $email], + ['groups[]', $group], + ] + ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $groupadmin, "POST", @@ -1716,9 +1622,7 @@ public function theGroupAdminCreatesUserPasswordGroupUsingTheProvisioningApi( null, $this->theHTTPStatusCodeWasSuccess() ); - if (OcisHelper::isTestingOnOcisOrReva()) { - $this->manuallyAddSkeletonFilesForUser($userToCreate, $password); - } + $this->manuallyAddSkeletonFilesForUser($userToCreate, $password); } /** @@ -1739,23 +1643,16 @@ public function theGroupAdminCreatesUserPasswordInOtherGroupUsingTheProvisioning ):void { $userToCreate = $this->getActualUsername($userToCreate); $password = $this->getActualPassword($password); - if (OcisHelper::isTestingOnOcisOrReva()) { - $email = $userToCreate . '@owncloud.com'; - $bodyTable = new TableNode( - [ - ['userid', $userToCreate], - ['password', $userToCreate], - ['username', $userToCreate], - ['email', $email], - ['groups[]', $group], - ] - ); - } else { - $email = null; - $bodyTable = new TableNode( - [['userid', $userToCreate], ['password', $password], ['groups[]', $group]] - ); - } + $email = $userToCreate . '@owncloud.com'; + $bodyTable = new TableNode( + [ + ['userid', $userToCreate], + ['password', $userToCreate], + ['username', $userToCreate], + ['email', $email], + ['groups[]', $group], + ] + ); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $groupadmin, "POST", @@ -3385,27 +3282,22 @@ public function userExists(?string $user):bool { // 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); - if (OcisHelper::isTestingOnOcisOrReva()) { - // 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::isTestingOnOcis()) { - $requestingUser = 'moss'; - $requestingPassword = 'vista'; - } else { - $requestingUser = $this->getActualUsername($user); - $requestingPassword = $this->getPasswordForUser($requestingUser); - } - } else { + // 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::isTestingOnOcis()) { + $requestingUser = 'moss'; + $requestingPassword = 'vista'; + } else { + $requestingUser = $this->getActualUsername($user); + $requestingPassword = $this->getPasswordForUser($requestingUser); } $path = (OcisHelper::isTestingWithGraphApi()) ? "/graph/v1.0" @@ -4074,7 +3966,6 @@ public function setTheLdapAttributeOfTheEntryTo( $ldapEntry = $this->ldap->getEntry($entry . "," . $this->ldapBaseDN); Laminas\Ldap\Attribute::setAttribute($ldapEntry, $attribute, $value, $append); $this->ldap->update($entry . "," . $this->ldapBaseDN, $ldapEntry); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4148,7 +4039,6 @@ public function removeUserFromLdapGroup(string $user, string $group, ?string $ou $memberAttr, "cn=$group,ou=$ou" ); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4159,7 +4049,6 @@ public function removeUserFromLdapGroup(string $user, string $group, ?string $ou */ public function deleteTheLdapEntry(string $entry):void { $this->ldap->delete($entry . "," . $this->ldapBaseDN); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4175,7 +4064,6 @@ public function deleteLdapGroup(string $group, ?string $ou = null):void { $ou = $this->getLdapGroupsOU(); } $this->deleteTheLdapEntry("cn=$group,ou=$ou"); - $this->theLdapUsersHaveBeenReSynced(); $key = \array_search($group, $this->ldapCreatedGroups); if ($key !== false) { unset($this->ldapCreatedGroups[$key]); @@ -4222,7 +4110,6 @@ public function editLdapUserDisplayName(?string $user, ?string $displayName):voi $entry, $displayName ); - $this->theLdapUsersHaveBeenReSynced(); } /** @@ -4507,7 +4394,7 @@ public function userTriesToDeleteGroupUsingTheProvisioningApi(string $user, stri * @throws GuzzleException */ public function groupExists(string $group):bool { - if ($this->isTestingWithLdap() && OcisHelper::isTestingOnOcisOrReva()) { + if ($this->isTestingWithLdap()) { $baseDN = $this->getLdapBaseDN(); $newDN = 'cn=' . $group . ',ou=' . $this->ldapGroupsOU . ',' . $baseDN; if ($this->ldap->getEntry($newDN) !== null) { @@ -5773,15 +5660,13 @@ public function theListOfGroupsReturnedByTheApiShouldBeEmpty():void { */ public function afterScenario():void { $this->waitForDavRequestsToFinish(); - $this->restoreParametersAfterScenario(); - if (OcisHelper::isTestingOnOcisOrReva() && $this->someUsersHaveBeenCreated()) { + if ($this->someUsersHaveBeenCreated()) { foreach ($this->getCreatedUsers() as $user) { OcisHelper::deleteRevaUserData($user["actualUsername"]); } - } elseif (OcisHelper::isTestingOnOc10()) { - $this->resetAdminUserAttributes(); } + if ($this->isTestingWithLdap()) { $this->deleteLdapUsersAndGroups(); } @@ -5859,27 +5744,6 @@ public function cleanupDatabaseGroups():void { $this->usingServer($previousServer); } - /** - * @BeforeScenario - * - * @return void - * @throws Exception - */ - public function rememberAppEnabledDisabledState():void { - if (!OcisHelper::isTestingOnOcisOrReva()) { - SetupHelper::init( - $this->getAdminUsername(), - $this->getAdminPassword(), - $this->getBaseUrl(), - $this->getOcPath() - ); - $this->runOcc(['app:list', '--output json']); - $apps = \json_decode($this->getStdOutOfOccCommand(), true); - $this->enabledApps = \array_keys($apps["enabled"]); - $this->disabledApps = \array_keys($apps["disabled"]); - } - } - /** * @BeforeScenario @rememberGroupsThatExist * @@ -5890,34 +5754,6 @@ public function rememberGroupsThatExistAtTheStartOfTheScenario():void { $this->startingGroups = $this->getArrayOfGroupsResponded($this->getAllGroups()); } - /** - * @AfterScenario - * - * @return void - * @throws Exception - */ - public function restoreAppEnabledDisabledState():void { - if (!OcisHelper::isTestingOnOcisOrReva() && !$this->isRunningForDbConversion()) { - $this->runOcc(['app:list', '--output json']); - - $apps = \json_decode($this->getStdOutOfOccCommand(), true); - $currentlyEnabledApps = \array_keys($apps["enabled"]); - $currentlyDisabledApps = \array_keys($apps["disabled"]); - - foreach ($currentlyDisabledApps as $disabledApp) { - if (\in_array($disabledApp, $this->enabledApps)) { - $this->adminEnablesOrDisablesApp('enables', $disabledApp); - } - } - - foreach ($currentlyEnabledApps as $enabledApp) { - if (\in_array($enabledApp, $this->disabledApps)) { - $this->adminEnablesOrDisablesApp('disables', $enabledApp); - } - } - } - } - /** * disable or enable user * @@ -6070,36 +5906,16 @@ private function isEmptySkeleton(): bool { * @throws Exception */ private function setSkeletonDirByType(string $skeletonType): string { - if (OcisHelper::isTestingOnOcisOrReva()) { - $originalSkeletonPath = \getenv("SKELETON_DIR"); - if ($originalSkeletonPath === false) { - $originalSkeletonPath = ''; - } - if ($skeletonType !== '') { - $skeletonDirName = $skeletonType . "Skeleton"; - $newSkeletonPath = \dirname($originalSkeletonPath) . '/' . $skeletonDirName; - \putenv( - "SKELETON_DIR=" . $newSkeletonPath - ); - } - } else { - $baseUrl = $this->getBaseUrl(); - $originalSkeletonPath = $this->getSkeletonDirectory($baseUrl); - - if ($skeletonType !== '') { - OcsApiHelper::sendRequest( - $baseUrl, - $this->getAdminUsername(), - $this->getAdminPassword(), - 'POST', - "/apps/testing/api/v1/testingskeletondirectory", - $this->getStepLineRef(), - [ - 'directory' => $skeletonType . "Skeleton" - ], - $this->getOcsApiVersion() - ); - } + $originalSkeletonPath = \getenv("SKELETON_DIR"); + if ($originalSkeletonPath === false) { + $originalSkeletonPath = ''; + } + if ($skeletonType !== '') { + $skeletonDirName = $skeletonType . "Skeleton"; + $newSkeletonPath = \dirname($originalSkeletonPath) . '/' . $skeletonDirName; + \putenv( + "SKELETON_DIR=" . $newSkeletonPath + ); } return $originalSkeletonPath; } @@ -6115,22 +5931,9 @@ private function setSkeletonDirByType(string $skeletonType): string { * @throws Exception */ private function setSkeletonDir(string $skeletonDir): string { - if (OcisHelper::isTestingOnOcisOrReva()) { - $originalSkeletonPath = \getenv("SKELETON_DIR"); - if ($skeletonDir !== '') { - \putenv("SKELETON_DIR=" . $skeletonDir); - } - } else { - $baseUrl = $this->getBaseUrl(); - $originalSkeletonPath = $this->getSkeletonDirectory($baseUrl); - if ($skeletonDir !== '') { - $this->runOcc( - ["config:system:set skeletondirectory --value $skeletonDir"], - null, - null, - $baseUrl - ); - } + $originalSkeletonPath = \getenv("SKELETON_DIR"); + if ($skeletonDir !== '') { + \putenv("SKELETON_DIR=" . $skeletonDir); } return $originalSkeletonPath; } diff --git a/tests/acceptance/features/bootstrap/PublicWebDavContext.php b/tests/acceptance/features/bootstrap/PublicWebDavContext.php index 21554982d4b..4ca9a55a52f 100644 --- a/tests/acceptance/features/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/features/bootstrap/PublicWebDavContext.php @@ -125,7 +125,7 @@ public function downloadPublicFileWithPassword(string $password, string $publicW * @return void */ public function deleteFileFromPublicShare(string $fileName, string $publicWebDAVAPIVersion, string $password = ""):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } $token = $this->featureContext->getLastPublicShareToken(); @@ -179,7 +179,7 @@ public function thePublicDeletesFileFromTheLastPublicShareUsingThePasswordPasswo * @return void */ public function renameFileFromPublicShare(string $fileName, string $toFileName, string $publicWebDAVAPIVersion, ?string $password = ""):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } $token = $this->featureContext->getLastPublicShareToken(); @@ -720,7 +720,7 @@ public function checkLastPublicSharedFileWithPasswordDownload( string $password, string $expectedContent ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -869,7 +869,7 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPasswordAn string $password, string $content ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -901,7 +901,7 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPasswordAn string $password, string $content ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -977,7 +977,7 @@ public function shouldBeAbleToDownloadRangeOfFileInsidePublicSharedFolderWithPas string $publicWebDAVAPIVersion, string $password ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -1009,7 +1009,7 @@ public function shouldNotBeAbleToDownloadRangeOfFileInsidePublicSharedFolderWith string $password, string $expectedHttpCode = "401" ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -1093,7 +1093,7 @@ public function publiclyUploadingShouldToSharedFileShouldFail( string $expectedHttpCode ):void { $filename = ""; - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } $filename = (string)$this->featureContext->getLastPublicShareData()->data[0]->file_target; @@ -1124,7 +1124,7 @@ public function publiclyUploadingShouldNotWork( string $publicWebDAVAPIVersion, string $expectedHttpCode = null ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -1219,7 +1219,7 @@ public function publiclyUploadingShouldWork(string $publicWebDAVAPIVersion):void $path = "whateverfilefortesting-$publicWebDAVAPIVersion-publicWebDAVAPI.txt"; $content = "test $publicWebDAVAPIVersion"; - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } @@ -1259,7 +1259,7 @@ public function publiclyUploadingToPublicLinkSharedFileShouldWork( ):void { $content = "test $publicWebDAVAPIVersion"; $should = ($shouldOrNot !== "not"); - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } elseif ($publicWebDAVAPIVersion === "new") { $path = $this->featureContext->getLastPublicSharePath(); @@ -1435,30 +1435,18 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe ):void { $token = $this->featureContext->getLastPublicShareToken(); $baseUrl = $this->featureContext->getBaseUrl(); - if (\TestHelpers\OcisHelper::isTestingOnOcisOrReva()) { - $mtime = \explode(" ", $mtime); - \array_pop($mtime); - $mtime = \implode(" ", $mtime); - Assert::assertStringContainsString( - $mtime, - WebDavHelper::getMtimeOfFileinPublicLinkShare( - $baseUrl, - $fileName, - $token, - $this->featureContext->getStepLineRef() - ) - ); - } else { - Assert::assertEquals( - $mtime, - WebDavHelper::getMtimeOfFileinPublicLinkShare( - $baseUrl, - $fileName, - $token, - $this->featureContext->getStepLineRef() - ) - ); - } + $mtime = \explode(" ", $mtime); + \array_pop($mtime); + $mtime = \implode(" ", $mtime); + Assert::assertStringContainsString( + $mtime, + WebDavHelper::getMtimeOfFileinPublicLinkShare( + $baseUrl, + $fileName, + $token, + $this->featureContext->getStepLineRef() + ) + ); } /** @@ -1507,7 +1495,7 @@ public function publicUploadContent( array $additionalHeaders = [], string $publicWebDAVAPIVersion = "old" ):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } $password = $this->featureContext->getActualPassword($password); @@ -1599,7 +1587,7 @@ public function setUpScenario(BeforeScenarioScope $scope):void { * @throws GuzzleException */ public function publicSendsRequestToLastPublicShare(string $method, string $publicWebDAVAPIVersion, ?string $password = ''):void { - if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + if ($publicWebDAVAPIVersion === "old") { return; } if ($method === "PROPFIND") { diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index 38347fca68f..b5db9a36b97 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -423,17 +423,9 @@ public function createShareWithSettings(string $user, ?TableNode $body):void { * @return void */ public function autoAcceptSharesHasBeenDisabled():void { - if (OcisHelper::isTestingOnOcisOrReva()) { - // auto-accept shares is disabled by default on OCIS. - // so there is nothing to do, just return - return; - } - - $this->appConfigurationContext->serverParameterHasBeenSetTo( - "shareapi_auto_accept_share", - "core", - "no" - ); + // auto-accept shares is disabled by default on OCIS. + // so there is nothing to do, just return + return; } /** diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index af9a0b1212c..7746a29571c 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -4466,12 +4466,6 @@ public function encodePath(string $path):string { // slashes need to stay $encodedPath = \str_replace('%2F', '/', \rawurlencode($path)); // in ocis even brackets are encoded - if (OcisHelper::isTestingOnOcisOrReva()) { - return $encodedPath; - } - // do not encode '(' and ')' for oc10 - $encodedPath = \str_replace('%28', '(', $encodedPath); - $encodedPath = \str_replace('%29', ')', $encodedPath); return $encodedPath; }