From bb59f16e31b58e3074db15b64ff029db4a1f5415 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Wed, 14 May 2025 20:19:00 +0200 Subject: [PATCH] PosixTest. Check that version, share and link still exist (#837) --- tests/acceptance/bootstrap/CliContext.php | 24 +++++++ tests/acceptance/config/behat.yml | 2 + .../collaborativePosixFS.feature | 70 +++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/tests/acceptance/bootstrap/CliContext.php b/tests/acceptance/bootstrap/CliContext.php index a1d450ca59..9c343baf3e 100644 --- a/tests/acceptance/bootstrap/CliContext.php +++ b/tests/acceptance/bootstrap/CliContext.php @@ -578,6 +578,30 @@ class CliContext implements Context { sleep(1); } + /** + * @When the administrator renames the file :file to :newName for user :user on the POSIX filesystem + * + * @param string $user + * @param string $file + * @param string $newName + * + * @return void + */ + public function theAdministratorRenamesFile(string $user, string $file, string $newName): void { + $userUuid = $this->featureContext->getUserIdByUserName($user); + $storagePath = $this->getUsersStoragePath(); + + $source = "$storagePath/$userUuid/$file"; + $destination = "$storagePath/$userUuid/$newName"; + + $body = [ + "command" => "mv $source $destination", + "raw" => true + ]; + $this->featureContext->setResponse(CliHelper::runCommand($body)); + sleep(1); + } + /** * @When the administrator moves the file :file to the folder :folder for user :user on the POSIX filesystem * diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 0001130420..4fb3ca79ac 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -466,6 +466,8 @@ default: - FeatureContext: *common_feature_context_params - CliContext: - OcConfigContext: + - SharingNgContext: + - PublicWebDavContext: coreApiMain: paths: diff --git a/tests/acceptance/features/collaborativePosix/collaborativePosixFS.feature b/tests/acceptance/features/collaborativePosix/collaborativePosixFS.feature index ec454f796b..73c1ae2ca1 100644 --- a/tests/acceptance/features/collaborativePosix/collaborativePosixFS.feature +++ b/tests/acceptance/features/collaborativePosix/collaborativePosixFS.feature @@ -44,6 +44,13 @@ Feature: create a resources using collaborative posixfs And the content of file "/folder/test.txt" for user "Alice" should be "content" + Scenario: rename file + Given user "Alice" has uploaded file with content "content" to "test.txt" + When the administrator renames the file "test.txt" to "new-name.txt" for user "Alice" on the POSIX filesystem + Then the command should be successful + And the content of file "/new-name.txt" for user "Alice" should be "content" + + Scenario: move file to folder Given user "Alice" has created folder "/folder" And user "Alice" has uploaded file with content "content" to "test.txt" @@ -85,3 +92,66 @@ Feature: create a resources using collaborative posixfs When the administrator deletes the project space "Project space" on the POSIX filesystem Then the command should be successful And the user "Alice" should not have a space called "Project space" + + + Scenario: user doesn't lose file versions after renaming the file + Given user "Brian" has been created with default attributes + And user "Alice" has uploaded file with content "content" to "textfile.txt" + And user "Alice" has uploaded file with content "new content version 2" to "textfile.txt" + And user "Alice" has uploaded file with content "new content version 3" to "textfile.txt" + When the administrator renames the file "textfile.txt" to "new-name.txt" for user "Alice" on the POSIX filesystem + Then the command should be successful + When user "Alice" gets the number of versions of file "new-name.txt" + Then the HTTP status code should be "207" + And the number of versions should be "2" + + + Scenario: user doesn't lose file versions after changing the file content + Given user "Alice" has uploaded file with content "content" to "textfile.txt" + And user "Alice" has uploaded file with content "new content version 2" to "textfile.txt" + And user "Alice" has uploaded file with content "new content version 3" to "textfile.txt" + When the administrator puts the content "new" into the file "textfile.txt" in the POSIX storage folder of user "Alice" + Then the command should be successful + When user "Alice" gets the number of versions of file "textfile.txt" + Then the HTTP status code should be "207" + And the number of versions should be "2" + + + Scenario: user doesn't lose share and public link after renaming the file + Given user "Brian" has been created with default attributes + And user "Alice" has uploaded file with content "content" to "textfile.txt" + And user "Alice" has created the following resource link share: + | resource | textfile.txt | + | space | Personal | + | permissionsRole | view | + | password | %public% | + And user "Alice" has sent the following resource share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When the administrator renames the file "textfile.txt" to "new-name.txt" for user "Alice" on the POSIX filesystem + Then the command should be successful + And user "Brian" should have a share "textfile.txt" shared by user "Alice" from space "Personal" + And the public should be able to download file "textfile.txt" from the last link share with password "%public%" and the content should be "content" + + + Scenario: user doesn't lose share and public link after changing the file content + Given user "Brian" has been created with default attributes + And user "Alice" has uploaded file with content "content" to "textfile.txt" + And user "Alice" has created the following resource link share: + | resource | textfile.txt | + | space | Personal | + | permissionsRole | view | + | password | %public% | + And user "Alice" has sent the following resource share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When the administrator puts the content "new" into the file "textfile.txt" in the POSIX storage folder of user "Alice" + Then the command should be successful + And for user "Brian" the content of the file "textfile.txt" of the space "Shares" should be "contentnew" + And the public should be able to download file "textfile.txt" from the last link share with password "%public%" and the content should be "contentnew"