Skip to content

Commit 834c901

Browse files
committed
test: add unit tests to local external storage
1 parent b4b4924 commit 834c901

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

apps/files_external/tests/Controller/GlobalStoragesControllerTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,38 @@ public function testCreate() {
111111
$this->assertEquals($expectedStorage, $actual);
112112
}
113113

114+
public function testCreateLocal() {
115+
$mount = 'randomMount';
116+
$backend = 'local';
117+
$auth = 'identifier:\Random\Missing\Auth\Class';
118+
$backendOpts = [
119+
'datadir' => '/tmp',
120+
];
121+
$priority = 3;
122+
123+
// there is already a teardown in the parent class setting this value to false
124+
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);
125+
126+
$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
127+
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
128+
}
129+
130+
public function testCreateLocalClassname() {
131+
$mount = 'randomMount';
132+
$backend = '\OC\Files\Storage\Local';
133+
$auth = 'identifier:\Random\Missing\Auth\Class';
134+
$backendOpts = [
135+
'datadir' => '/tmp',
136+
];
137+
$priority = 3;
138+
139+
// there is already a teardown in the parent class setting this value to false
140+
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);
141+
142+
$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
143+
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
144+
}
145+
114146
public function testUpdate() {
115147
$mount = 'randomMount';
116148
$backend = 'identifier:\This\Doesnt\Exist';

apps/files_external/tests/Controller/UserStoragesControllerTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,38 @@ public function testCreate() {
195195
$this->assertEquals($expectedStorage, $actual);
196196
}
197197

198+
public function testCreateLocal() {
199+
$mount = 'randomMount';
200+
$backend = 'local';
201+
$auth = 'identifier:\Random\Missing\Auth\Class';
202+
$backendOpts = [
203+
'datadir' => '/tmp',
204+
];
205+
$priority = 3;
206+
207+
// there is already a teardown in the parent class setting this value to false
208+
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);
209+
210+
$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
211+
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
212+
}
213+
214+
public function testCreateLocalClassname() {
215+
$mount = 'randomMount';
216+
$backend = '\OC\Files\Storage\Local';
217+
$auth = 'identifier:\Random\Missing\Auth\Class';
218+
$backendOpts = [
219+
'datadir' => '/tmp',
220+
];
221+
$priority = 3;
222+
223+
// there is already a teardown in the parent class setting this value to false
224+
\OC::$server->getSystemConfig()->setValue('files_external_allow_create_new_local', false);
225+
226+
$result = $this->controller->create($mount, $backend, $auth, $backendOpts, [], [], [], $priority);
227+
$this->assertEquals(Http::STATUS_FORBIDDEN, $result->getStatus());
228+
}
229+
198230
public function testUpdate() {
199231
$mount = 'randomMount';
200232
$backend = 'identifier:\This\Doesnt\Exist';

0 commit comments

Comments
 (0)