Skip to content

Commit d81b4e2

Browse files
authored
Merge pull request #23030 from nextcloud/backport/22948/stable20
[stable20] Add more integration tests for "files:transfer-ownership" command
2 parents 3320d8e + 0dd18e0 commit d81b4e2

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

build/integration/features/bootstrap/CommandLineContext.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
require __DIR__ . '/../../vendor/autoload.php';
2828

2929
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
30+
use PHPUnit\Framework\Assert;
3031

3132
class CommandLineContext implements \Behat\Behat\Context\Context {
3233
use CommandLine;
@@ -129,4 +130,11 @@ public function usingTransferFolderAsDavPath($user) {
129130
$davPath = rtrim($davPath, '/') . $this->lastTransferPath;
130131
$this->featureContext->usingDavPath($davPath);
131132
}
133+
134+
/**
135+
* @Then /^transfer folder name contains "([^"]+)"$/
136+
*/
137+
public function transferFolderNameContains($text) {
138+
Assert::assertContains($text, $this->lastTransferPath);
139+
}
132140
}

build/integration/features/bootstrap/Provisioning.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function assureUserExists($user) {
7070
}
7171

7272
/**
73-
* @Given /^user "([^"]*)" with displayname "([^"]*)" exists$/
73+
* @Given /^user "([^"]*)" with displayname "((?:[^"]|\\")*)" exists$/
7474
* @param string $user
7575
*/
7676
public function assureUserWithDisplaynameExists($user, $displayname) {

build/integration/features/transfer-ownership.feature

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ Feature: transfer-ownership
2929
And using received transfer folder of "user1" as dav path
3030
And as "user1" the folder "/test" exists
3131

32+
Scenario: transferring ownership from user with risky display name
33+
Given user "user0" with displayname "user0 \"risky\"? ヂspḷay 'na|\/|e':.#" exists
34+
And user "user1" exists
35+
And User "user0" created a folder "/test"
36+
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
37+
When transferring ownership from "user0" to "user1"
38+
And the command was successful
39+
And As an "user1"
40+
And using received transfer folder of "user1" as dav path
41+
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
42+
And transfer folder name contains "transferred from user0 -risky- ヂspḷay -na|-|e- on"
43+
And using old dav path
44+
And as "user0" the folder "/test" does not exist
45+
And using received transfer folder of "user1" as dav path
46+
And as "user1" the folder "/test" exists
47+
3248
Scenario: transferring ownership of file shares
3349
Given user "user0" exists
3450
And user "user1" exists
@@ -290,6 +306,20 @@ Feature: transfer-ownership
290306
Then the command error output contains the text "Unknown target user"
291307
And the command failed with exit code 1
292308

309+
Scenario: transferring ownership of a file
310+
Given user "user0" exists
311+
And user "user1" exists
312+
And User "user0" uploads file "data/textfile.txt" to "/somefile.txt"
313+
When transferring ownership of path "somefile.txt" from "user0" to "user1"
314+
And the command was successful
315+
And As an "user1"
316+
And using received transfer folder of "user1" as dav path
317+
Then Downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"
318+
And using old dav path
319+
And as "user0" the file "/somefile.txt" does not exist
320+
And using received transfer folder of "user1" as dav path
321+
And as "user1" the file "/somefile.txt" exists
322+
293323
Scenario: transferring ownership of a folder
294324
Given user "user0" exists
295325
And user "user1" exists
@@ -305,6 +335,73 @@ Feature: transfer-ownership
305335
And using received transfer folder of "user1" as dav path
306336
And as "user1" the folder "/test" exists
307337

338+
Scenario: transferring ownership from user with risky display name
339+
Given user "user0" with displayname "user0 \"risky\"? ヂspḷay 'na|\/|e':.#" exists
340+
And user "user1" exists
341+
And User "user0" created a folder "/test"
342+
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
343+
When transferring ownership of path "test" from "user0" to "user1"
344+
And the command was successful
345+
And As an "user1"
346+
And using received transfer folder of "user1" as dav path
347+
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
348+
And transfer folder name contains "transferred from user0 -risky- ヂspḷay -na|-|e- on"
349+
And using old dav path
350+
And as "user0" the folder "/test" does not exist
351+
And using received transfer folder of "user1" as dav path
352+
And as "user1" the folder "/test" exists
353+
354+
Scenario: transferring ownership of path does not affect other files
355+
Given user "user0" exists
356+
And user "user1" exists
357+
And User "user0" created a folder "/test"
358+
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
359+
And User "user0" created a folder "/test2"
360+
And User "user0" uploads file "data/textfile.txt" to "/test2/somefile.txt"
361+
When transferring ownership of path "test" from "user0" to "user1"
362+
And the command was successful
363+
And As an "user1"
364+
And using received transfer folder of "user1" as dav path
365+
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
366+
And using old dav path
367+
And as "user0" the folder "/test" does not exist
368+
And as "user0" the folder "/test2" exists
369+
And as "user0" the file "/test2/somefile.txt" exists
370+
And using received transfer folder of "user1" as dav path
371+
And as "user1" the folder "/test" exists
372+
And as "user1" the folder "/test2" does not exist
373+
374+
Scenario: transferring ownership of path does not affect other shares
375+
Given user "user0" exists
376+
And user "user1" exists
377+
And User "user0" created a folder "/test"
378+
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
379+
And User "user0" created a folder "/test2"
380+
And User "user0" uploads file "data/textfile.txt" to "/test2/sharedfile.txt"
381+
And file "/test2/sharedfile.txt" of user "user0" is shared with user "user1" with permissions 19
382+
And user "user1" accepts last share
383+
When transferring ownership of path "test" from "user0" to "user1"
384+
And the command was successful
385+
And As an "user1"
386+
And using received transfer folder of "user1" as dav path
387+
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"
388+
And using old dav path
389+
And as "user0" the folder "/test" does not exist
390+
And as "user0" the folder "/test2" exists
391+
And as "user0" the file "/test2/sharedfile.txt" exists
392+
And using received transfer folder of "user1" as dav path
393+
And as "user1" the folder "/test" exists
394+
And as "user1" the folder "/test2" does not exist
395+
And using old dav path
396+
And as "user1" the file "/sharedfile.txt" exists
397+
And As an "user1"
398+
And Getting info of last share
399+
And the OCS status code should be "100"
400+
And Share fields of last share match with
401+
| uid_owner | user0 |
402+
| uid_file_owner | user0 |
403+
| share_with | user1 |
404+
308405
Scenario: transferring ownership of file shares
309406
Given user "user0" exists
310407
And user "user1" exists

0 commit comments

Comments
 (0)