mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
feat(files_external): add #[AuthorizedAdminSetting] to GlobalStoragesController
Signed-off-by: Tatjana Kaschperko Lindt <kaschperko-lindt@strato.de>
This commit is contained in:
parent
ad39ad91a0
commit
397dbc6496
2 changed files with 40 additions and 0 deletions
|
|
@ -10,7 +10,9 @@ namespace OCA\Files_External\Controller;
|
|||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCA\Files_External\Settings\Admin;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
|
||||
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -74,6 +76,7 @@ class GlobalStoragesController extends StoragesController {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
#[PasswordConfirmationRequired(strict: true)]
|
||||
public function create(
|
||||
$mountPoint,
|
||||
|
|
@ -129,6 +132,7 @@ class GlobalStoragesController extends StoragesController {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
#[PasswordConfirmationRequired(strict: true)]
|
||||
public function update(
|
||||
$id,
|
||||
|
|
@ -179,4 +183,22 @@ class GlobalStoragesController extends StoragesController {
|
|||
Http::STATUS_OK
|
||||
);
|
||||
}
|
||||
|
||||
// PHP attributes are not inherited, so these methods override the parent
|
||||
// solely to attach #[AuthorizedAdminSetting] and expose them to delegated admins.
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
public function index() {
|
||||
return parent::index();
|
||||
}
|
||||
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
public function show(int $id, $testOnly = true) {
|
||||
return parent::show($id, $testOnly);
|
||||
}
|
||||
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
#[PasswordConfirmationRequired(strict: true)]
|
||||
public function destroy(int $id) {
|
||||
return parent::destroy($id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,4 +98,22 @@ class AdminTest extends TestCase {
|
|||
public function testGetPriority(): void {
|
||||
$this->assertSame(40, $this->admin->getPriority());
|
||||
}
|
||||
|
||||
public function testGetName(): void {
|
||||
$this->l10n->expects($this->once())
|
||||
->method('t')
|
||||
->with('External storage')
|
||||
->willReturn('External storage');
|
||||
|
||||
$this->assertSame('External storage', $this->admin->getName());
|
||||
}
|
||||
|
||||
public function testGetAuthorizedAppConfig(): void {
|
||||
$this->assertSame([], $this->admin->getAuthorizedAppConfig());
|
||||
}
|
||||
|
||||
public function testImplementsIDelegatedSettings(): void {
|
||||
$this->assertInstanceOf(\OCP\Settings\IDelegatedSettings::class, $this->admin);
|
||||
$this->assertInstanceOf(\OCP\Settings\ISettings::class, $this->admin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue