From 61c624234589091564e6606ff35f80ce871bf10c Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 17 Sep 2020 14:59:44 -0600 Subject: [PATCH] Some more test work - Refactoring to reduce duplication - Tests for with & without permission --- api/tests/Vfs/StreamWrapperTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/tests/Vfs/StreamWrapperTest.php b/api/tests/Vfs/StreamWrapperTest.php index c7228ad458..79fcfc0047 100644 --- a/api/tests/Vfs/StreamWrapperTest.php +++ b/api/tests/Vfs/StreamWrapperTest.php @@ -48,4 +48,22 @@ class StreamWrapperTest extends StreamWrapperBase parent::testNoReadAccess(); } + public function testWithAccess() : void + { + // Put it in the group directory this time so we can give access + $this->files[] = $this->test_file = $this->getFilename('/home/Default'); + + parent::testWithAccess(); + } + + protected function allowAccess(string $test_name, string $test_file, int $test_user, string $needed) + { + // We'll allow access by putting test user in Default group + $command = new \admin_cmd_edit_user($test_user, ['account_groups' => array_merge($this->account['account_groups'],['Default'])]); + $command->run(); + + // Add explicit permission on group + Vfs::chmod($test_file, Vfs::mode2int('g+'.$needed)); + + } } \ No newline at end of file