]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add integration tests for transferring files of a user with a risky name
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 18 Sep 2020 16:32:59 +0000 (18:32 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 24 Sep 2020 12:47:47 +0000 (12:47 +0000)
The files:transfer-ownership performs a sanitization of users with
"risky" display names (including characters like "\" or "/").

In order to allow (escaped) double quotes in the display name the
regular expression used in the "user XXX with displayname YYY exists"
step had to be adjusted.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
build/integration/features/bootstrap/CommandLineContext.php
build/integration/features/bootstrap/Provisioning.php
build/integration/features/transfer-ownership.feature

index 3acb59ec40478f4f5cc9f8ff7a65106df12e4645..6db8de6b485aba2e63ea4a66933e674369da01ba 100644 (file)
@@ -27,6 +27,7 @@
 require __DIR__ . '/../../vendor/autoload.php';
 
 use Behat\Behat\Hook\Scope\BeforeScenarioScope;
+use PHPUnit\Framework\Assert;
 
 class CommandLineContext implements \Behat\Behat\Context\Context {
        use CommandLine;
@@ -129,4 +130,11 @@ class CommandLineContext implements \Behat\Behat\Context\Context {
                $davPath = rtrim($davPath, '/') . $this->lastTransferPath;
                $this->featureContext->usingDavPath($davPath);
        }
+
+       /**
+        * @Then /^transfer folder name contains "([^"]+)"$/
+        */
+       public function transferFolderNameContains($text) {
+               Assert::assertContains($text, $this->lastTransferPath);
+       }
 }
index daf5b11569c0168a2c79c57769ff8909cbef234f..31331092ae72bb0718b435ff0b25265e15f0aa73 100644 (file)
@@ -70,7 +70,7 @@ trait Provisioning {
        }
 
        /**
-        * @Given /^user "([^"]*)" with displayname "([^"]*)" exists$/
+        * @Given /^user "([^"]*)" with displayname "((?:[^"]|\\")*)" exists$/
         * @param string $user
         */
        public function assureUserWithDisplaynameExists($user, $displayname) {
index 7afaf1f3e59b12b3da2dd7634d5b782955e9a3a2..46aeabb3aa7794d5fde95ca12598e75f0c431eac 100644 (file)
@@ -29,6 +29,22 @@ Feature: transfer-ownership
                And using received transfer folder of "user1" as dav path
                And as "user1" the folder "/test" exists
 
+       Scenario: transferring ownership from user with risky display name
+               Given user "user0" with displayname "user0 \"risky\"? ヂspḷay 'na|\/|e':.#" exists
+               And user "user1" exists
+               And User "user0" created a folder "/test"
+               And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
+               When transferring ownership from "user0" to "user1"
+               And the command was successful
+               And As an "user1"
+               And using received transfer folder of "user1" as dav path
+               Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
+               And transfer folder name contains "transferred from user0 -risky- ヂspḷay -na|-|e- on"
+               And using old dav path
+               And as "user0" the folder "/test" does not exist
+               And using received transfer folder of "user1" as dav path
+               And as "user1" the folder "/test" exists
+
        Scenario: transferring ownership of file shares
                Given user "user0" exists
                And user "user1" exists
@@ -319,6 +335,22 @@ Feature: transfer-ownership
                And using received transfer folder of "user1" as dav path
                And as "user1" the folder "/test" exists
 
+       Scenario: transferring ownership from user with risky display name
+               Given user "user0" with displayname "user0 \"risky\"? ヂspḷay 'na|\/|e':.#" exists
+               And user "user1" exists
+               And User "user0" created a folder "/test"
+               And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
+               When transferring ownership of path "test" from "user0" to "user1"
+               And the command was successful
+               And As an "user1"
+               And using received transfer folder of "user1" as dav path
+               Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
+               And transfer folder name contains "transferred from user0 -risky- ヂspḷay -na|-|e- on"
+               And using old dav path
+               And as "user0" the folder "/test" does not exist
+               And using received transfer folder of "user1" as dav path
+               And as "user1" the folder "/test" exists
+
        Scenario: transferring ownership of file shares
                Given user "user0" exists
                And user "user1" exists