mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -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
bd5350c7a1
commit
f6f4bce01e
2 changed files with 40 additions and 0 deletions
|
|
@ -9,7 +9,9 @@ namespace OCA\Files_External\Controller;
|
|||
|
||||
use OCA\Files_External\NotFoundException;
|
||||
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;
|
||||
|
|
@ -60,6 +62,7 @@ class GlobalStoragesController extends StoragesController {
|
|||
* @param ?array $applicableGroups groups for which to mount the storage
|
||||
* @param ?int $priority priority
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
#[PasswordConfirmationRequired(strict: true)]
|
||||
public function create(
|
||||
string $mountPoint,
|
||||
|
|
@ -123,6 +126,7 @@ class GlobalStoragesController extends StoragesController {
|
|||
* @param ?array $applicableGroups groups for which to mount the storage
|
||||
* @param ?int $priority priority
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Admin::class)]
|
||||
#[PasswordConfirmationRequired(strict: true)]
|
||||
public function update(
|
||||
int $id,
|
||||
|
|
@ -173,4 +177,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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,4 +126,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