Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] Remove isTestingOnOcisOrReva() method and its references #40628

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions tests/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ 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;
}

Expand Down
40 changes: 0 additions & 40 deletions tests/TestHelpers/LoggingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ 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
Expand Down Expand Up @@ -132,9 +128,6 @@ public static function getLogFileContent(
public static function getLogLevel(
?string $xRequestId = ''
):string {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "debug";
}
$result = SetupHelper::runOcc(
["log:manage"],
$xRequestId
Expand Down Expand Up @@ -163,10 +156,6 @@ 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");
}
Expand All @@ -193,9 +182,6 @@ public static function setLogLevel(
public static function getLogBackend(
?string $xRequestId = ''
):string {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "errorlog";
}
$result = SetupHelper::runOcc(
["log:manage"],
$xRequestId
Expand Down Expand Up @@ -232,10 +218,6 @@ 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
Expand All @@ -259,9 +241,6 @@ public static function setLogBackend(
public static function getLogTimezone(
?string $xRequestId = ''
):string {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "UTC";
}
$result = SetupHelper::runOcc(
["log:manage"],
$xRequestId
Expand Down Expand Up @@ -295,10 +274,6 @@ 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
Expand Down Expand Up @@ -327,10 +302,6 @@ 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,
Expand Down Expand Up @@ -360,10 +331,6 @@ 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");
}
Expand Down Expand Up @@ -408,13 +375,6 @@ 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
Expand Down
11 changes: 2 additions & 9 deletions tests/TestHelpers/OcisHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,11 @@
* @package TestHelpers
*/
class OcisHelper {
/**
* @return bool
*/
public static function isTestingOnOcisOrReva():bool {
return false;
}

/**
* @return bool
*/
public static function isTestingOnOc10():bool {
return (!self::isTestingOnOcisOrReva());
return true;
}

/**
Expand Down Expand Up @@ -293,7 +286,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)) {
Expand Down
6 changes: 0 additions & 6 deletions tests/TestHelpers/SetupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,6 @@ 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");
Expand Down Expand Up @@ -864,9 +861,6 @@ 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ 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();
Expand Down
112 changes: 54 additions & 58 deletions tests/acceptance/features/bootstrap/CorsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,69 +49,65 @@ class CorsContext implements Context {
* @throws Exception
*/
public function addDomainToPrivateCORSLists(string $user, string $domain):void {
if (OcisHelper::isTestingOnOcisOrReva()) {
echo "WARNING: server is expected to start with 'OCIS_CORS_ALLOW_ORIGINS=' environment";
$user = $this->featureContext->getActualUsername($user);
$occStatus = $this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains'
]
);
if ($occStatus === 0) {
$domainsJson = $this->featureContext->getStdOutOfOccCommand();
$domains = \json_decode($domainsJson);
} else {
$user = $this->featureContext->getActualUsername($user);
$occStatus = $this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains'
]
);
if ($occStatus === 0) {
$domainsJson = $this->featureContext->getStdOutOfOccCommand();
$domains = \json_decode($domainsJson);
} else {
$domainsJson = "";
$domains = [];
}
if ($user === $this->featureContext->getAdminUsername()
&& $this->originalAdminCorsDomains === null
) {
$this->originalAdminCorsDomains = $domainsJson;
}
$domainsJson = "";
$domains = [];
}
if ($user === $this->featureContext->getAdminUsername()
&& $this->originalAdminCorsDomains === null
) {
$this->originalAdminCorsDomains = $domainsJson;
}

$domains[] = $domain;
$valueString = \json_encode($domains);
$occStatus = $this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains',
'--value=\'' . $valueString . '\''
]
);
if ($occStatus !== 0) {
throw new \Exception(
"could not set CORS domain. " .
$this->featureContext->getStdErrOfOccCommand()
);
}
//double check if it was set
$this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains'
]
$domains[] = $domain;
$valueString = \json_encode($domains);
$occStatus = $this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains',
'--value=\'' . $valueString . '\''
]
);
if ($occStatus !== 0) {
throw new \Exception(
"could not set CORS domain. " .
$this->featureContext->getStdErrOfOccCommand()
);
$domains = \json_decode($this->featureContext->getStdOutOfOccCommand());
}
//double check if it was set
$this->featureContext->runOcc(
[
'user:setting',
$user,
'core',
'domains'
]
);
$domains = \json_decode($this->featureContext->getStdOutOfOccCommand());

Assert::assertIsArray(
$domains,
__METHOD__ . " The output of 'occ user:setting $user core domains' was not valid JSON"
);
Assert::assertIsArray(
$domains,
__METHOD__ . " The output of 'occ user:setting $user core domains' was not valid JSON"
);

if (!\in_array($domain, $domains)) {
throw new \Exception(
"domain $domain is not included in CORS domain $domains, but was expected to be"
);
}
if (!\in_array($domain, $domains)) {
throw new \Exception(
"domain $domain is not included in CORS domain $domains, but was expected to be"
);
}
}

Expand Down
Loading