diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-03-30 21:55:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 21:55:50 +0200 |
commit | f3738eeff70ead6657149fa5d25bfde04f731746 (patch) | |
tree | a86cfadb738b1753d6cf469f3e2b613926cc21ad /tests | |
parent | 0a6416f84fd69fad1aaa01c6d96f1c64a77917b0 (diff) | |
parent | e5dc1a8085226492b6d323142381fd163451c06d (diff) | |
download | nextcloud-server-f3738eeff70ead6657149fa5d25bfde04f731746.tar.gz nextcloud-server-f3738eeff70ead6657149fa5d25bfde04f731746.zip |
Merge pull request #25280 from nextcloud/explicit-file-permissions
Set umask before operations that create local files
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Storage/LocalTest.php | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index 46784811248..e324d2b28db 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -63,21 +63,21 @@ class LocalTest extends Storage { $this->assertNotEquals($etag1, $etag2); } - + public function testInvalidArgumentsEmptyArray() { $this->expectException(\InvalidArgumentException::class); new \OC\Files\Storage\Local([]); } - + public function testInvalidArgumentsNoArray() { $this->expectException(\InvalidArgumentException::class); new \OC\Files\Storage\Local(null); } - + public function testDisallowSymlinksOutsideDatadir() { $this->expectException(\OCP\Files\ForbiddenException::class); @@ -108,4 +108,35 @@ class LocalTest extends Storage { $storage->file_put_contents('sym/foo', 'bar'); $this->addToAssertionCount(1); } + + public function testWriteUmaskFilePutContents() { + $oldMask = umask(0333); + $this->instance->file_put_contents('test.txt', 'sad'); + umask($oldMask); + $this->assertTrue($this->instance->isUpdatable('test.txt')); + } + + public function testWriteUmaskMkdir() { + $oldMask = umask(0333); + $this->instance->mkdir('test.txt'); + umask($oldMask); + $this->assertTrue($this->instance->isUpdatable('test.txt')); + } + + public function testWriteUmaskFopen() { + $oldMask = umask(0333); + $handle = $this->instance->fopen('test.txt', 'w'); + fwrite($handle, 'foo'); + fclose($handle); + umask($oldMask); + $this->assertTrue($this->instance->isUpdatable('test.txt')); + } + + public function testWriteUmaskCopy() { + $this->instance->file_put_contents('source.txt', 'sad'); + $oldMask = umask(0333); + $this->instance->copy('source.txt', 'test.txt'); + umask($oldMask); + $this->assertTrue($this->instance->isUpdatable('test.txt')); + } } |