Merge pull request #5808 from owncloud/remove-isTestingOnOcis-method-master

[full-ci] [tests-only] Removed method `isTestingOnOcis`, and refactored code
This commit is contained in:
Prarup Gurung
2023-03-13 12:51:23 +05:45
committed by GitHub
5 changed files with 12 additions and 63 deletions

View File

@@ -33,13 +33,6 @@ use GuzzleHttp\Exception\GuzzleException;
* @package TestHelpers
*/
class OcisHelper {
/**
* @return bool
*/
public static function isTestingOnOcis():bool {
return (\getenv("TEST_OCIS") === "true");
}
/**
* @return bool
*/

View File

@@ -2961,15 +2961,7 @@ class FeatureContext extends BehatVariablesContext {
* @throws Exception
*/
public function theFileWithContentShouldExistInTheServerRoot(string $path, string $content): void {
if (OcisHelper::isTestingOnOcis()) {
$fileContent = $this->readFileInServerRootForOCIS($path);
} else {
$this->readFileInServerRootForCore($path);
$this->theHTTPStatusCodeShouldBe(200, 'Failed to read the file $path');
$fileContent = $this->getResponseXml();
$fileContent = (string)$fileContent->data->element->contentUrlEncoded;
$fileContent = \urldecode($fileContent);
}
$fileContent = $this->readFileInServerRootForOCIS($path);
Assert::assertSame(
$content,
$fileContent,

View File

@@ -720,16 +720,15 @@ trait Provisioning {
}
if (isset($setting["email"])) {
$entry['mail'] = $setting["email"];
} elseif (OcisHelper::isTestingOnOcis()) {
} else {
$entry['mail'] = $userId . '@owncloud.com';
}
$entry['gidNumber'] = 5000;
$entry['uidNumber'] = $uidNumber;
if (OcisHelper::isTestingOnOcis()) {
$entry['objectclass'][] = 'ownCloud';
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
}
$entry['objectclass'][] = 'ownCloud';
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
if (OcisHelper::isTestingParallelDeployment()) {
$entry['ownCloudSelector'] = $this->getOCSelector();
}
@@ -765,10 +764,9 @@ trait Provisioning {
$entry['objectclass'][] = 'groupOfNames';
$entry['member'] = "";
}
if (OcisHelper::isTestingOnOcis()) {
$entry['objectclass'][] = 'ownCloud';
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
}
$entry['objectclass'][] = 'ownCloud';
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
$this->ldap->add($newDN, $entry);
$this->ldapCreatedGroups[] = $group;
}
@@ -1108,12 +1106,6 @@ trait Provisioning {
if ($skeleton) {
$this->manuallyAddSkeletonFiles($usersAttributes);
}
if ($initialize && ($this->isEmptySkeleton() || !OcisHelper::isTestingOnOcis())) {
// We need to initialize each user using the individual authentication of each user.
// That is not possible in Guzzle6 batch mode. So we do it with normal requests in serial.
$this->initializeUsers($users);
}
}
/**
@@ -2991,30 +2983,6 @@ trait Provisioning {
$this->lastUploadTime = \time();
}
/**
* Touch an API end-point for each user so that their file-system gets setup
*
* @param array $users
*
* @return void
* @throws Exception
*/
public function initializeUsers(array $users):void {
$url = "/cloud/users/%s";
foreach ($users as $user) {
$response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$user,
$this->getPasswordForUser($user),
'GET',
\sprintf($url, $user),
$this->getStepLineRef()
);
$this->setResponse($response);
$this->theHTTPStatusCodeShouldBe(200);
}
}
/**
* adds a user to the list of users that were created during test runs
* makes it possible to use this list in other test steps
@@ -3292,13 +3260,11 @@ trait Provisioning {
} elseif (OcisHelper::isTestingWithGraphApi()) {
$requestingUser = $this->getAdminUsername();
$requestingPassword = $this->getAdminPassword();
} elseif (OcisHelper::isTestingOnOcis()) {
} else {
$requestingUser = 'moss';
$requestingPassword = 'vista';
} else {
$requestingUser = $this->getActualUsername($user);
$requestingPassword = $this->getPasswordForUser($requestingUser);
}
$path = (OcisHelper::isTestingWithGraphApi())
? "/graph/v1.0"
: "/ocs/v2.php/cloud";

View File

@@ -59,9 +59,7 @@ class SearchContext implements Context {
TableNode $properties = null
):void {
// Because indexing of newly uploaded files or directories with ocis is decoupled and occurs asynchronously, a short wait is necessary before searching files or folders.
if (OcisHelper::isTestingOnOcis()) {
sleep(4);
}
sleep(4);
$user = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
$password = $this->featureContext->getPasswordForUser($user);

View File

@@ -5344,7 +5344,7 @@ trait WebDav {
if ($multistatusResults !== null) {
foreach ($multistatusResults as $multistatusResult) {
$entryPath = $multistatusResult['value'][0]['value'];
if (OcisHelper::isTestingOnOcis() && $method === "REPORT") {
if ($method === "REPORT") {
if ($entryNameToSearch !== null && str_ends_with($entryPath, $entryNameToSearch)) {
return $multistatusResult;
} else {