Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-06-07 22:37:02 +0300
committerGitHub <noreply@github.com>2021-06-07 22:37:02 +0300
commit9f62c8023de1425887b8a21283c265ff91c0ceea (patch)
tree36308f3f366e1768662e16675801bdaa6822a09f /tests
parentac5d4a8bfc59893aded2ea164abd7b9a7b0da714 (diff)
parentb486855783c38cd857f233485187a7a31ba0fe47 (diff)
Merge pull request #27349 from nextcloud/backport/25280/stable20
[stable20] Set umask before operations that create local files
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Storage/LocalTest.php37
-rw-r--r--tests/lib/Preview/Provider.php4
2 files changed, 38 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'));
+ }
}
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php
index 761f6b7f83f..90287116512 100644
--- a/tests/lib/Preview/Provider.php
+++ b/tests/lib/Preview/Provider.php
@@ -141,6 +141,10 @@ abstract class Provider extends \Test\TestCase {
$file = new File(\OC::$server->getRootFolder(), $this->rootView, $this->imgPath);
$preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);
+ if (get_class($this) === BitmapTest::class && $preview === null) {
+ $this->markTestSkipped('An error occured while operating with Imagick.');
+ }
+
$this->assertNotEquals(false, $preview);
$this->assertEquals(true, $preview->valid());