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] Adjust logic for testing on OCIS or REVA #38077

Merged
merged 2 commits into from
Nov 4, 2020
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
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ def acceptance(ctx):
environment['MAILHOG_HOST'] = 'email'

if params['ldapNeeded']:
environment['TEST_EXTERNAL_USER_BACKENDS'] = True
environment['TEST_WITH_LDAP'] = True

if params['testingRemoteSystem']:
environment['TESTING_REMOTE_SYSTEM'] = True
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST_PHP_SUITE=
# Acceptance test flags (for shells supporting autocompletion of makefiles, eg: zsh)
TEST_SERVER_URL?=
TEST_SERVER_FED_URL?=
TEST_EXTERNAL_USER_BACKENDS?=
TEST_WITH_LDAP?=
BEHAT_FEATURE?=
NORERUN?=
BEHAT_RERUN_TIMES?=
Expand Down
6 changes: 3 additions & 3 deletions tests/TestHelpers/LoggingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function getLogFileContent(
* @return string
*/
public static function getLogLevel() {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "debug";
}
$result = SetupHelper::runOcc(["log:manage"]);
Expand Down Expand Up @@ -144,7 +144,7 @@ public static function setLogLevel($logLevel) {
* @return string
*/
public static function getLogBackend() {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "errorlog";
}
$result = SetupHelper::runOcc(["log:manage"]);
Expand Down Expand Up @@ -192,7 +192,7 @@ public static function setLogBackend($backend) {
* @return string
*/
public static function getLogTimezone() {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return "UTC";
}
$result = SetupHelper::runOcc(["log:manage"]);
Expand Down
16 changes: 15 additions & 1 deletion tests/TestHelpers/OcisHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public static function isTestingOnReva() {
return (\getenv("TEST_REVA") === "true");
}

/**
* @return bool
*/
public static function isTestingOnOcisOrReva() {
return (self::isTestingOnOcis() || self::isTestingOnReva());
}

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

/**
* @return bool|string false if no command given or the command as string
*/
Expand Down Expand Up @@ -224,7 +238,7 @@ public static function getBindDN() {
*/
private static function getOcisRevaDataRoot() {
$root = \getenv("OCIS_REVA_DATA_ROOT");
if (($root === false || $root === "") && self::isTestingOnOcis()) {
if (($root === false || $root === "") && self::isTestingOnOcisOrReva()) {
$root = "/var/tmp/ocis/owncloud/";
}
if (!\file_exists($root)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestHelpers/SetupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public static function runOcc(
$ocPath = null,
$envVariables = null
) {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return ['code' => '', 'stdOut' => '', 'stdErr' => '' ];
}
$baseUrl = self::checkBaseUrl($baseUrl, "runOcc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function adminSetsServerParameterToUsingAPI(
public function serverParameterHasBeenSetTo($parameter, $app, $value) {
// The capturing group of the regex always includes the quotes at each
// end of the captured string, so trim them.
if (\TestHelpers\OcisHelper::isTestingOnOcis()) {
if (\TestHelpers\OcisHelper::isTestingOnOcisOrReva()) {
return;
}
$value = \trim($value, $value[0]);
Expand Down
12 changes: 6 additions & 6 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public function getLdapPort() {
* @return bool
*/
public function isTestingWithLdap() {
return (\getenv("TEST_EXTERNAL_USER_BACKENDS") === "true");
return (\getenv("TEST_WITH_LDAP") === "true");
}

/**
Expand Down Expand Up @@ -1316,7 +1316,7 @@ public function isAPublicLinkUrl($url) {
$urlEnding = \substr($url, \strlen($this->getBaseUrl() . '/'));
}

if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return \preg_match("%^(#/)?s/([a-zA-Z0-9]{15})$%", $urlEnding);
} else {
return \preg_match("%^(index.php/)?s/([a-zA-Z0-9]{15})$%", $urlEnding);
Expand Down Expand Up @@ -3162,7 +3162,7 @@ public function clearFileLocksForServer($serverUrl) {
* @return void
*/
public function clearFileLocks() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
$this->authContext->deleteTokenAuthEnforcedAfterScenario();
$this->clearFileLocksForServer($this->getBaseUrl());
if ($this->remoteBaseUrl !== $this->localBaseUrl) {
Expand All @@ -3180,7 +3180,7 @@ public function clearFileLocks() {
* @throws \Exception
*/
public static function useBigFileIDs(BeforeSuiteScope $scope) {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
return;
}
$fullUrl = \getenv('TEST_SERVER_URL');
Expand Down Expand Up @@ -3596,7 +3596,7 @@ public function restoreTrustedServers($server) {
* @return void
*/
public function restoreParametersAfterScenario() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
$this->authContext->deleteTokenAuthEnforcedAfterScenario();
$user = $this->getCurrentUser();
$this->setCurrentUser($this->getAdminUsername());
Expand Down Expand Up @@ -3686,7 +3686,7 @@ public function getBodyForOCSRequest($method, $property) {
* @return void
*/
public function prepareParametersBeforeScenario() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
$user = $this->getCurrentUser();
$this->setCurrentUser($this->getAdminUsername());
$previousServer = $this->getCurrentServer();
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ public function theOccCommandJsonOutputShouldNotReturnAnyData() {
* @throws Exception
*/
public function theAdministratorHasSetTheDefaultFolderForReceivedSharesTo($folder) {
if (OcisHelper::isTestingOnOcis()) {
// The default folder for received shares is already "Shares" on OCIS.
if (OcisHelper::isTestingOnOcisOrReva()) {
// The default folder for received shares is already "Shares" on OCIS and REVA.
// If the step is asking for a different folder, then fail.
// Otherwise just return - the setting is already done by default.
Assert::assertEquals(
Expand Down
34 changes: 17 additions & 17 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public function importLdifData($ldifData) {
*/
public function connectToLdap($suiteParameters) {
$useSsl = false;
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->ldapBaseDN = OcisHelper::getBaseDN();
$this->ldapHost = OcisHelper::getHostname();
$this->ldapPort = OcisHelper::getLdapPort();
Expand Down Expand Up @@ -603,7 +603,7 @@ public function connectToLdap($suiteParameters) {
* @throws Exception
*/
public function theLdapUsersHaveBeenReSynced() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
$occResult = SetupHelper::runOcc(
['user:sync', 'OCA\User_LDAP\User_Proxy', '-m', 'remove']
);
Expand Down Expand Up @@ -939,7 +939,7 @@ public function usersHaveBeenCreated(
} else {
$attributesToCreateUser['userid'] = $userAttributes['userid'];
$attributesToCreateUser['password'] = $userAttributes['password'];
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$attributesToCreateUser['username'] = $userAttributes['userid'];
if ($userAttributes['email'] === null) {
Assert::assertArrayHasKey(
Expand Down Expand Up @@ -988,7 +988,7 @@ public function usersHaveBeenCreated(
$users = [];
$editData = [];
foreach ($usersAttributes as $userAttributes) {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
OcisHelper::createEOSStorageHome(
$this->getBaseUrl(),
$userAttributes['userid'],
Expand Down Expand Up @@ -1018,7 +1018,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::isTestingOnOcis()) {
if ($skeleton && OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFiles($usersAttributes);
}

Expand Down Expand Up @@ -1266,7 +1266,7 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv
"email" => $email
];

if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
if ($email === null) {
$email = $username . '@owncloud.org';
}
Expand All @@ -1289,7 +1289,7 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv
$email,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFilesForUser($username, $password);
}
}
Expand All @@ -1306,7 +1306,7 @@ public function adminSendsUserCreationRequestWithFollowingAttributesUsingTheProv
public function adminSendsUserCreationRequestUsingTheProvisioningApi($user, $password) {
$user = $this->getActualUsername($user);
$password = $this->getActualPassword($password);
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$email = $user . '@owncloud.org';
$bodyTable = new TableNode(
[
Expand Down Expand Up @@ -1335,7 +1335,7 @@ public function adminSendsUserCreationRequestUsingTheProvisioningApi($user, $pas
$email,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
OcisHelper::createEOSStorageHome($this->getBaseUrl(), $user, $password);
$this->manuallyAddSkeletonFilesForUser($user, $password);
}
Expand All @@ -1356,7 +1356,7 @@ public function theAdministratorCreatesUserPasswordGroupUsingTheProvisioningApi(
) {
$user = $this->getActualUsername($user);
$password = $this->getActualPassword($password);
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$email = $user . '@owncloud.org';
$bodyTable = new TableNode(
[
Expand Down Expand Up @@ -1388,7 +1388,7 @@ public function theAdministratorCreatesUserPasswordGroupUsingTheProvisioningApi(
$email,
$this->theHTTPStatusCodeWasSuccess()
);
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$this->manuallyAddSkeletonFilesForUser($user, $password);
}
}
Expand Down Expand Up @@ -2605,7 +2605,7 @@ public function userExists($user) {
// 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::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
$requestingUser = $this->getActualUsername($user);
$requestingPassword = $this->getPasswordForUser($requestingUser);
} else {
Expand Down Expand Up @@ -3431,7 +3431,7 @@ public function userTriesToDeleteGroupUsingTheProvisioningApi($user, $group) {
* @throws Exception
*/
public function groupExists($group) {
if ($this->isTestingWithLdap() && OcisHelper::isTestingOnOcis()) {
if ($this->isTestingWithLdap() && OcisHelper::isTestingOnOcisOrReva()) {
$baseDN = $this->getLdapBaseDN();
$newDN = 'cn=' . $group . ',ou=' . $this->ou . ',' . $baseDN;
if ($this->ldap->getEntry($newDN) !== null) {
Expand Down Expand Up @@ -4359,12 +4359,12 @@ public function theListOfGroupsReturnedByTheApiShouldBeEmpty() {
public function afterScenario() {
$this->restoreParametersAfterScenario();

if (OcisHelper::isTestingOnOcis() && $this->someUsersHaveBeenCreated()) {
if (OcisHelper::isTestingOnOcisOrReva() && $this->someUsersHaveBeenCreated()) {
foreach ($this->getCreatedUsers() as $user) {
$this->deleteAllSharesForUser($user["actualUsername"]);
OcisHelper::deleteRevaUserData($user["actualUsername"]);
}
} elseif (!OcisHelper::isTestingOnOcis()) {
} elseif (OcisHelper::isTestingOnOc10()) {
$this->resetAdminUserAttributes();
}
if ($this->isTestingWithLdap()) {
Expand Down Expand Up @@ -4437,7 +4437,7 @@ public function cleanupDatabaseGroups() {
* @return void
*/
public function rememberAppEnabledDisabledState() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
SetupHelper::init(
$this->getAdminUsername(),
$this->getAdminPassword(),
Expand All @@ -4457,7 +4457,7 @@ public function rememberAppEnabledDisabledState() {
* @return void
*/
public function restoreAppEnabledDisabledState() {
if (!OcisHelper::isTestingOnOcis()) {
if (!OcisHelper::isTestingOnOcisOrReva()) {
$this->runOcc(['app:list', '--output json']);
$apps = \json_decode($this->getStdOutOfOccCommand(), true);
$currentlyEnabledApps = \array_keys($apps["enabled"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe
$tokenArray = $this->featureContext->getLastShareData()->data->token;
$token = (string)$tokenArray[0];
$baseUrl = $this->featureContext->getBaseUrl();
if (\TestHelpers\OcisHelper::isTestingOnOcis()) {
if (\TestHelpers\OcisHelper::isTestingOnOcisOrReva()) {
$mtime = \explode(" ", $mtime);
\array_pop($mtime);
$mtime = \implode(" ", $mtime);
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function createShareWithSettings($user, $body) {
* @return void
*/
public function autoAcceptSharesHasBeenDisabled() {
if (OcisHelper::isTestingOnOcis()) {
if (OcisHelper::isTestingOnOcisOrReva()) {
// auto-accept shares is disabled by default on OCIS.
// so there is nothing to do, just return
return;
Expand Down
10 changes: 5 additions & 5 deletions tests/acceptance/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export LANG=C
# sets $REMOTE_OCC_STDOUT and $REMOTE_OCC_STDERR from returned xml data
# @return occ return code given in the xml data
function remote_occ() {
if [ "${TEST_OCIS}" == "true" ]
if [ "${TEST_OCIS}" == "true" ] || [ "${TEST_REVA}" == "true" ]
then
return 0
fi
Expand Down Expand Up @@ -295,7 +295,7 @@ function assert_testing_app_enabled() {
# $4 text description of the server being checked, e.g. "local", "remote"
# return 0 if given module is enabled, else return with 1
function check_apache_module_enabled() {
if [ "${TEST_OCIS}" == "true" ]
if [ "${TEST_OCIS}" == "true" ] || [ "${TEST_REVA}" == "true" ]
then
return 0
fi
Expand Down Expand Up @@ -695,9 +695,9 @@ then
DIR_URL="${TESTING_APP_URL}dir"
# test that server is up and running, and testing app is enabled.
assert_server_up ${TEST_SERVER_URL}
if [ "${TEST_OCIS}" != "true" ]
if [ "${TEST_OCIS}" != "true" ] && [ "${TEST_REVA}" != "true" ]
then
assert_testing_app_enabled ${TEST_SERVER_URL}
assert_testing_app_enabled ${TEST_SERVER_URL}
fi

if [ -n "${TEST_SERVER_FED_URL}" ]
Expand All @@ -706,7 +706,7 @@ then
OCC_FED_URL="${TESTING_APP_FED_URL}occ"
# test that fed server is up and running, and testing app is enabled.
assert_server_up ${TEST_SERVER_FED_URL}
if [ "${TEST_OCIS}" != "true" ]
if [ "${TEST_OCIS}" != "true" ] && [ "${TEST_REVA}" != "true" ]
then
assert_testing_app_enabled ${TEST_SERVER_URL}
fi
Expand Down