Removed DAV tech preview steps and related code (#5526) (#5530)

Co-authored-by: Prarup Gurung <grgprarup@users.noreply.github.com>
This commit is contained in:
Amrita
2023-02-08 15:30:49 +05:45
committed by GitHub
co-authored by Prarup Gurung
parent 0e5d0cb9b1
commit 3a61f8c919
6 changed files with 6 additions and 214 deletions
@@ -222,11 +222,6 @@ cannot share a folder with create permission
- [coreApiShareOperationsToShares1/gettingShares.feature:222](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L222)
#### [Public link enforce permissions](https://github.com/owncloud/ocis/issues/1269)
- [coreApiSharePublicLink1/accessToPublicLinkShare.feature:10](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature#L10)
- [coreApiSharePublicLink1/accessToPublicLinkShare.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature#L21)
- [coreApiSharePublicLink1/accessToPublicLinkShare.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature#L31)
- [coreApiSharePublicLink1/accessToPublicLinkShare.feature:47](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature#L47)
- [coreApiSharePublicLink1/createPublicLinkShare.feature:528](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/createPublicLinkShare.feature#L528)
- [coreApiSharePublicLink1/createPublicLinkShare.feature:549](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink1/createPublicLinkShare.feature#L549)
@@ -58,67 +58,6 @@ class OccContext implements Context {
*/
private $lastDeletedJobId;
/**
* The code to manage dav.enable.tech_preview was used in 10.4/10.3
* The use of the steps to enable/disable it has been removed from the
* feature files. But the infrastructure has been left here, as a similar
* thing might likely happen in the future.
*
* @var boolean
*/
private $doTechPreview = false;
/**
* @var boolean techPreviewEnabled
*/
private $techPreviewEnabled = false;
/**
* @var string initialTechPreviewStatus
*/
private $initialTechPreviewStatus;
/**
* @return boolean
*/
public function isTechPreviewEnabled():bool {
return $this->techPreviewEnabled;
}
/**
* @return boolean
* @throws Exception
*/
public function enableDAVTechPreview():bool {
if ($this->doTechPreview) {
if (!$this->isTechPreviewEnabled()) {
$this->addSystemConfigKeyUsingTheOccCommand(
"dav.enable.tech_preview",
"true",
"boolean"
);
$this->techPreviewEnabled = true;
return true;
}
}
return false;
}
/**
* @return boolean true if delete-system-config-key was done
* @throws Exception
*/
public function disableDAVTechPreview():bool {
if ($this->doTechPreview) {
$this->deleteSystemConfigKeyUsingTheOccCommand(
"dav.enable.tech_preview"
);
$this->techPreviewEnabled = false;
return true;
}
return false;
}
/**
* @param string $cmd
*
@@ -604,28 +543,6 @@ class OccContext implements Context {
$this->invokingTheCommand('files_external:list --show-password --output=json');
}
/**
* @When the administrator enables DAV tech_preview
*
* @return void
* @throws Exception
*/
public function theAdministratorEnablesDAVTechPreview():void {
$this->enableDAVTechPreview();
}
/**
* @Given the administrator has enabled DAV tech_preview
*
* @return void
* @throws Exception
*/
public function theAdministratorHasEnabledDAVTechPreview():void {
if ($this->enableDAVTechPreview()) {
$this->theCommandShouldHaveBeenSuccessful();
}
}
/**
* @When /^the administrator invokes occ command "([^"]*)"$/
*
@@ -3556,30 +3473,6 @@ class OccContext implements Context {
}
}
/**
* This will run after EVERY scenario.
* It will set the properties for this object.
*
* @AfterScenario
*
* @return void
* @throws Exception
*/
public function resetDAVTechPreview():void {
if ($this->doTechPreview) {
if ($this->initialTechPreviewStatus === "") {
SetupHelper::deleteSystemConfig(
'dav.enable.tech_preview',
$this->featureContext->getStepLineRef()
);
} elseif ($this->initialTechPreviewStatus === 'true' && !$this->techPreviewEnabled) {
$this->enableDAVTechPreview();
} elseif ($this->initialTechPreviewStatus === 'false' && $this->techPreviewEnabled) {
$this->disableDAVTechPreview();
}
}
}
/**
* This will run after EVERY scenario.
* Some local_storage tests import storage from an export file. In that case
@@ -3625,19 +3518,6 @@ class OccContext implements Context {
'version',
$this->featureContext->getStepLineRef()
);
// dav.enable.tech_preview was used in some ownCloud versions before 10.4.0
// only set it on those versions of ownCloud
if (\version_compare($ocVersion, '10.4.0') === -1) {
$this->doTechPreview = true;
$techPreviewEnabled = \trim(
SetupHelper::getSystemConfigValue(
'dav.enable.tech_preview',
$this->featureContext->getStepLineRef()
)
);
$this->initialTechPreviewStatus = $techPreviewEnabled;
$this->techPreviewEnabled = $techPreviewEnabled === 'true';
}
}
/**
@@ -728,10 +728,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->downloadPublicFileWithRange(
@@ -745,10 +741,6 @@ class PublicWebDavContext implements Context {
"Checking the content of the last public shared file after downloading with the $publicWebDAVAPIVersion public WebDAV API"
);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
}
@@ -885,10 +877,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicDownloadsTheFileInsideThePublicSharedFolderWithPassword(
@@ -899,9 +887,6 @@ class PublicWebDavContext implements Context {
$this->featureContext->downloadedContentShouldBePlusEndOfLine($content);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
}
@@ -924,10 +909,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicDownloadsTheFileInsideThePublicSharedFolderWithPassword(
@@ -938,9 +919,6 @@ class PublicWebDavContext implements Context {
$this->featureContext->downloadedContentShouldBe($content);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
}
@@ -1007,10 +985,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicDownloadsTheFileInsideThePublicSharedFolderWithPasswordAndRange(
@@ -1043,10 +1017,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicDownloadsTheFileInsideThePublicSharedFolderWithPasswordAndRange(
@@ -1064,10 +1034,6 @@ class PublicWebDavContext implements Context {
"response body: \n$responseContent\n"
);
$this->featureContext->theHTTPStatusCodeShouldBe($expectedHttpCode);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
}
/**
@@ -1135,12 +1101,8 @@ class PublicWebDavContext implements Context {
$filename = "";
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$filename = (string)$this->featureContext->getLastPublicShareData()->data[0]->file_target;
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$filename = (string)$this->featureContext->getLastPublicShareData()->data[0]->file_target;
$this->publicUploadContent(
$filename,
@@ -1152,10 +1114,6 @@ class PublicWebDavContext implements Context {
);
$this->featureContext->theHTTPStatusCodeShouldBe($expectedHttpCode);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
}
/**
@@ -1174,10 +1132,6 @@ class PublicWebDavContext implements Context {
):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicUploadContent(
@@ -1189,10 +1143,6 @@ class PublicWebDavContext implements Context {
$publicWebDAVAPIVersion
);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
$response = $this->featureContext->getResponse();
if ($expectedHttpCode === null) {
$expectedHttpCode = [507, 400, 401, 403, 404, 423];
@@ -1277,10 +1227,6 @@ class PublicWebDavContext implements Context {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
} else {
$techPreviewHadToBeEnabled = false;
}
$this->publicUploadContent(
@@ -1302,10 +1248,6 @@ class PublicWebDavContext implements Context {
$publicWebDAVAPIVersion
);
$this->featureContext->checkDownloadedContentMatches($content);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
}
/**
@@ -1326,10 +1268,8 @@ class PublicWebDavContext implements Context {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
} elseif ($publicWebDAVAPIVersion === "new") {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
$path = $this->featureContext->getLastPublicSharePath();
} else {
$techPreviewHadToBeEnabled = false;
$path = "";
}
@@ -1367,10 +1307,6 @@ class PublicWebDavContext implements Context {
$response->getStatusCode()
);
}
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
}
/**
@@ -3831,8 +3831,7 @@ trait Sharing {
*/
public function getPublicPreviewOfFile(string $fileName, string $token):void {
$url = $this->getBaseUrl() .
"/index.php/apps/files_sharing/ajax/publicpreview.php" .
"?file=$fileName&t=$token";
"/remote.php/dav/public-files/$token/$fileName?preview=1";
$resp = HttpRequestHelper::get(
$url,
$this->getStepLineRef()
@@ -308,11 +308,7 @@ class TrashbinContext implements Context {
* @throws Exception
*/
public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth):void {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
$this->listTopOfTrashbinFolder($user, $depth);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
}
/**
@@ -678,8 +674,6 @@ class TrashbinContext implements Context {
$path = \trim($path, '/');
$sections = \explode('/', $path, 2);
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
$firstEntry = $this->findFirstTrashedEntry($user, \trim($sections[0], '/'));
Assert::assertNotNull(
@@ -692,10 +686,6 @@ class TrashbinContext implements Context {
$listing = $this->listTrashbinFolderCollection($user, \basename(\rtrim($firstEntry['href'], '/')));
}
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
// query was on the main element ?
if (\count($sections) === 1) {
// already found, return
@@ -729,14 +719,10 @@ class TrashbinContext implements Context {
* @throws Exception
*/
private function isInTrash(?string $user, ?string $originalPath):bool {
$techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview();
$res = $this->featureContext->getResponse();
$listing = $this->listTrashbinFolder($user);
$this->featureContext->setResponse($res);
if ($techPreviewHadToBeEnabled) {
$this->occContext->disableDAVTechPreview();
}
// we don't care if the test step writes a leading "/" or not
$originalPath = \ltrim($originalPath, '/');
@@ -8,8 +8,7 @@ Feature: accessing a public link share
Scenario: Access to the preview of password protected public link without providing the password is not allowed
Given the administrator has enabled DAV tech_preview
And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
Given user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
And user "Alice" has created a public link share with settings
| path | /testavatar.jpg |
| permissions | change |
@@ -19,8 +18,7 @@ Feature: accessing a public link share
Scenario: Access to the preview of public shared file without password
Given the administrator has enabled DAV tech_preview
And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
Given user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
And user "Alice" has created a public link share with settings
| path | /testavatar.jpg |
| permissions | change |
@@ -29,8 +27,7 @@ Feature: accessing a public link share
Scenario: Access to the preview of password protected public shared file inside a folder without providing the password is not allowed
Given the administrator has enabled DAV tech_preview
And user "Alice" has created folder "FOLDER"
Given user "Alice" has created folder "FOLDER"
And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "FOLDER/testavatar.jpg"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "FOLDER/textfile0.txt"
And user "Alice" has created a public link share with settings
@@ -45,8 +42,7 @@ Feature: accessing a public link share
Scenario: Access to the preview of public shared file inside a folder without password
Given the administrator has enabled DAV tech_preview
And user "Alice" has created folder "FOLDER"
Given user "Alice" has created folder "FOLDER"
And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "FOLDER/testavatar.jpg"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "FOLDER/textfile0.txt"
And user "Alice" has created a public link share with settings