Skip to content

Commit 67deefe

Browse files
tanyakaprintminion-co
authored andcommitted
feat(files_external): add #[AuthorizedAdminSetting] to GlobalStoragesController
Signed-off-by: Tatjana Kaschperko Lindt <kaschperko-lindt@strato.de>
1 parent 14ae3f1 commit 67deefe

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

apps/files_external/lib/Controller/GlobalStoragesController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
use OCA\Files_External\NotFoundException;
1111
use OCA\Files_External\Service\GlobalStoragesService;
12+
use OCA\Files_External\Settings\Admin;
1213
use OCP\AppFramework\Http;
14+
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
1315
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
1416
use OCP\AppFramework\Http\DataResponse;
1517
use OCP\IConfig;
@@ -60,6 +62,7 @@ public function __construct(
6062
* @param ?array $applicableGroups groups for which to mount the storage
6163
* @param ?int $priority priority
6264
*/
65+
#[AuthorizedAdminSetting(settings: Admin::class)]
6366
#[PasswordConfirmationRequired(strict: true)]
6467
public function create(
6568
string $mountPoint,
@@ -123,6 +126,7 @@ public function create(
123126
* @param ?array $applicableGroups groups for which to mount the storage
124127
* @param ?int $priority priority
125128
*/
129+
#[AuthorizedAdminSetting(settings: Admin::class)]
126130
#[PasswordConfirmationRequired(strict: true)]
127131
public function update(
128132
int $id,
@@ -173,4 +177,22 @@ public function update(
173177
Http::STATUS_OK
174178
);
175179
}
180+
181+
// PHP attributes are not inherited, so these methods override the parent
182+
// solely to attach #[AuthorizedAdminSetting] and expose them to delegated admins.
183+
#[AuthorizedAdminSetting(settings: Admin::class)]
184+
public function index() {
185+
return parent::index();
186+
}
187+
188+
#[AuthorizedAdminSetting(settings: Admin::class)]
189+
public function show(int $id, $testOnly = true) {
190+
return parent::show($id, $testOnly);
191+
}
192+
193+
#[AuthorizedAdminSetting(settings: Admin::class)]
194+
#[PasswordConfirmationRequired(strict: true)]
195+
public function destroy(int $id) {
196+
return parent::destroy($id);
197+
}
176198
}

apps/files_external/tests/Settings/AdminTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,22 @@ public function testGetSection(): void {
126126
public function testGetPriority(): void {
127127
$this->assertSame(40, $this->admin->getPriority());
128128
}
129+
130+
public function testGetName(): void {
131+
$this->l10n->expects($this->once())
132+
->method('t')
133+
->with('External storage')
134+
->willReturn('External storage');
135+
136+
$this->assertSame('External storage', $this->admin->getName());
137+
}
138+
139+
public function testGetAuthorizedAppConfig(): void {
140+
$this->assertSame([], $this->admin->getAuthorizedAppConfig());
141+
}
142+
143+
public function testImplementsIDelegatedSettings(): void {
144+
$this->assertInstanceOf(\OCP\Settings\IDelegatedSettings::class, $this->admin);
145+
$this->assertInstanceOf(\OCP\Settings\ISettings::class, $this->admin);
146+
}
129147
}

0 commit comments

Comments
 (0)