From a61d2ab4c4795f8e8df2b0a6c7baa844296ddc18 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 2 Oct 2024 17:00:53 +0200 Subject: [PATCH] test: add test for nested jail cross-storage move Signed-off-by: Robin Appelman --- tests/lib/Files/Storage/LocalTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index 1190a2b2da043..adee2e8253d01 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -22,6 +22,8 @@ namespace Test\Files\Storage; +use OC\Files\Storage\Wrapper\Jail; + /** * Class LocalTest * @@ -150,4 +152,25 @@ public function testUnavailableNonExternal() { // no exception thrown $this->assertNotNull($this->instance); } + + public function testMoveNestedJail(): void { + $this->instance->mkdir('foo'); + $this->instance->mkdir('foo/bar'); + $this->instance->mkdir('target'); + $this->instance->file_put_contents('foo/bar/file.txt', 'foo'); + $jail1 = new Jail([ + 'storage' => $this->instance, + 'root' => 'foo' + ]); + $jail2 = new Jail([ + 'storage' => $jail1, + 'root' => 'bar' + ]); + $jail3 = new Jail([ + 'storage' => $this->instance, + 'root' => 'target' + ]); + $jail3->moveFromStorage($jail2, 'file.txt', 'file.txt'); + $this->assertTrue($this->instance->file_exists('target/file.txt')); + } }