Removed method isTestingOnOcisOrReva, and refactored its use

This commit is contained in:
Prarup Gurung
2023-03-02 10:43:37 +05:45
parent d9092d7e17
commit fab9bfc734
11 changed files with 147 additions and 1063 deletions

View File

@@ -76,12 +76,9 @@ class HttpRequestHelper {
* @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;
}
/**

View File

@@ -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 @@ class LoggingHelper {
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 @@ class LoggingHelper {
?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 @@ class LoggingHelper {
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 @@ class LoggingHelper {
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 @@ class LoggingHelper {
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 @@ class LoggingHelper {
?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 @@ class LoggingHelper {
?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 @@ class LoggingHelper {
?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 @@ class LoggingHelper {
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"
];
}
}

View File

@@ -47,18 +47,11 @@ class OcisHelper {
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 @@ class OcisHelper {
*/
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)) {

View File

@@ -789,54 +789,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?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 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?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' => '' ];
}
/**

View File

@@ -73,12 +73,7 @@ class AppConfigurationContext implements Context {
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;
}
/**

View File

@@ -1593,11 +1593,7 @@ class FeatureContext extends BehatVariablesContext {
$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 @@ class FeatureContext extends BehatVariablesContext {
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,49 +3934,7 @@ class FeatureContext extends BehatVariablesContext {
* @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
);
return;
}
/**
@@ -4349,25 +4285,6 @@ class FeatureContext extends BehatVariablesContext {
}
}
/**
*
* @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 +4357,6 @@ class FeatureContext extends BehatVariablesContext {
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
*

View File

@@ -65,86 +65,9 @@ class LoggingContext implements Context {
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 @@ class LoggingContext implements Context {
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 @@ class LoggingContext implements Context {
$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;
}
/**

View File

@@ -642,25 +642,6 @@ trait Provisioning {
$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']);
}
}
}
/**
* prepares suitable nested array with user-attributes for multiple users to be created
*
@@ -861,35 +842,18 @@ trait Provisioning {
* @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->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
);
}
$this->theLdapUsersHaveBeenResynced();
}
@@ -1034,18 +998,16 @@ trait Provisioning {
$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(
@@ -1134,33 +1096,14 @@ trait Provisioning {
$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()
);
// We don't need to set displayName and email while running in oCIS
// As they are set when creating the user
}
if (isset($exceptionToThrow)) {
@@ -1171,7 +1114,7 @@ trait Provisioning {
// 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);
}
@@ -1461,10 +1404,8 @@ trait Provisioning {
$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 = [
@@ -1480,9 +1421,7 @@ trait Provisioning {
$userAttributes[] = ["email", $email];
}
if (OcisHelper::isTestingOnOcisOrReva()) {
$userAttributes[] = ["username", $username];
}
$userAttributes[] = ["username", $username];
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$this->getAdminUsername(),
@@ -1498,9 +1437,7 @@ trait Provisioning {
null,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFilesForUser($username, $password);
}
$this->manuallyAddSkeletonFilesForUser($username, $password);
}
/**
@@ -1515,20 +1452,15 @@ trait Provisioning {
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(
[
$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]]);
}
);
$this->emptyLastHTTPStatusCodesArray();
$this->emptyLastOCSStatusCodesArray();
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
@@ -1547,7 +1479,7 @@ trait Provisioning {
null,
$success
);
if (OcisHelper::isTestingOnOcisOrReva() && $success) {
if ($success) {
OcisHelper::createEOSStorageHome(
$this->getBaseUrl(),
$user,
@@ -1587,20 +1519,15 @@ trait Provisioning {
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(
[
$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]]);
}
);
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$user,
"POST",
@@ -1634,23 +1561,16 @@ trait Provisioning {
):void {
$user = $this->getActualUsername($user);
$password = $this->getActualPassword($password);
if (OcisHelper::isTestingOnOcisOrReva()) {
$email = $user . '@owncloud.com';
$bodyTable = new TableNode(
[
$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]]
);
}
);
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$this->getAdminUsername(),
"POST",
@@ -1665,9 +1585,7 @@ trait Provisioning {
null,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFilesForUser($user, $password);
}
$this->manuallyAddSkeletonFilesForUser($user, $password);
}
/**
@@ -1689,23 +1607,16 @@ trait Provisioning {
):void {
$userToCreate = $this->getActualUsername($userToCreate);
$password = $this->getActualPassword($password);
if (OcisHelper::isTestingOnOcisOrReva()) {
$email = $userToCreate . '@owncloud.com';
$bodyTable = new TableNode(
[
$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]]
);
}
);
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$groupadmin,
"POST",
@@ -1720,9 +1631,7 @@ trait Provisioning {
null,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFilesForUser($userToCreate, $password);
}
$this->manuallyAddSkeletonFilesForUser($userToCreate, $password);
}
/**
@@ -1743,23 +1652,16 @@ trait Provisioning {
):void {
$userToCreate = $this->getActualUsername($userToCreate);
$password = $this->getActualPassword($password);
if (OcisHelper::isTestingOnOcisOrReva()) {
$email = $userToCreate . '@owncloud.com';
$bodyTable = new TableNode(
[
$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]]
);
}
);
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$groupadmin,
"POST",
@@ -3389,27 +3291,22 @@ trait Provisioning {
// 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"
@@ -4511,7 +4408,7 @@ trait Provisioning {
* @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) {
@@ -5779,13 +5676,12 @@ trait Provisioning {
$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();
}
@@ -5863,27 +5759,6 @@ trait Provisioning {
$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
*
@@ -5894,34 +5769,6 @@ trait Provisioning {
$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
*
@@ -6074,36 +5921,16 @@ trait Provisioning {
* @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;
}
@@ -6119,22 +5946,9 @@ trait Provisioning {
* @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;
}

View File

@@ -125,7 +125,7 @@ class PublicWebDavContext implements Context {
* @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 @@ class PublicWebDavContext implements Context {
* @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 @@ class PublicWebDavContext implements Context {
string $password,
string $expectedContent
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -869,7 +869,7 @@ class PublicWebDavContext implements Context {
string $password,
string $content
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -901,7 +901,7 @@ class PublicWebDavContext implements Context {
string $password,
string $content
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -977,7 +977,7 @@ class PublicWebDavContext implements Context {
string $publicWebDAVAPIVersion,
string $password
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -1009,7 +1009,7 @@ class PublicWebDavContext implements Context {
string $password,
string $expectedHttpCode = "401"
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -1093,7 +1093,7 @@ class PublicWebDavContext implements Context {
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 @@ class PublicWebDavContext implements Context {
string $publicWebDAVAPIVersion,
string $expectedHttpCode = null
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -1219,7 +1219,7 @@ class PublicWebDavContext implements Context {
$path = "whateverfilefortesting-$publicWebDAVAPIVersion-publicWebDAVAPI.txt";
$content = "test $publicWebDAVAPIVersion";
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
@@ -1259,7 +1259,7 @@ class PublicWebDavContext implements Context {
):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 @@ class PublicWebDavContext implements Context {
):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 @@ class PublicWebDavContext implements Context {
array $additionalHeaders = [],
string $publicWebDAVAPIVersion = "old"
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
$password = $this->featureContext->getActualPassword($password);
@@ -1599,7 +1587,7 @@ class PublicWebDavContext implements Context {
* @throws GuzzleException
*/
public function publicSendsRequestToLastPublicShare(string $method, string $publicWebDAVAPIVersion, ?string $password = ''):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
if ($publicWebDAVAPIVersion === "old") {
return;
}
if ($method === "PROPFIND") {

View File

@@ -423,17 +423,9 @@ trait Sharing {
* @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;
}
/**

View File

@@ -4466,12 +4466,6 @@ trait WebDav {
// 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;
}