diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-07-14 09:18:39 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-14 16:01:14 +0200 |
commit | fa9dfd83c97e7b97c78003f40667e3e25db27400 (patch) | |
tree | 8268bbf1aef181f00ec7a51252800a13cf801d55 /apps/settings | |
parent | 5dca062c975a7f4b3fbbef8f3b5354258255ec10 (diff) | |
download | nextcloud-server-fa9dfd83c97e7b97c78003f40667e3e25db27400.tar.gz nextcloud-server-fa9dfd83c97e7b97c78003f40667e3e25db27400.zip |
Fix AppFramework services
* We can't just register an alias as the services need the appId to be
injected. if we just register an alias this blows up since the main
container doesn't have the appId.
* Moved the Authtokens over to show the PoC works
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/settings')
-rw-r--r-- | apps/settings/lib/Settings/Personal/Security/Authtokens.php | 16 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php | 18 |
2 files changed, 16 insertions, 18 deletions
diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index 22aca1660d9..a0758933525 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Settings\Settings\Personal\Security; +use OCP\AppFramework\Services\IInitialState; use OCP\IUserSession; use function array_map; use OC\Authentication\Exceptions\InvalidTokenException; @@ -33,7 +34,6 @@ use OC\Authentication\Token\INamedToken; use OC\Authentication\Token\IProvider as IAuthTokenProvider; use OC\Authentication\Token\IToken; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IInitialStateService; use OCP\ISession; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\Settings\ISettings; @@ -46,8 +46,8 @@ class Authtokens implements ISettings { /** @var ISession */ private $session; - /** @var IInitialStateService */ - private $initialStateService; + /** @var IInitialState */ + private $initialState; /** @var string|null */ private $uid; @@ -58,24 +58,22 @@ class Authtokens implements ISettings { public function __construct(IAuthTokenProvider $tokenProvider, ISession $session, IUserSession $userSession, - IInitialStateService $initialStateService, + IInitialState $initialState, ?string $UserId) { $this->tokenProvider = $tokenProvider; $this->session = $session; - $this->initialStateService = $initialStateService; + $this->initialState = $initialState; $this->uid = $UserId; $this->userSession = $userSession; } public function getForm(): TemplateResponse { - $this->initialStateService->provideInitialState( - 'settings', + $this->initialState->provideInitialState( 'app_tokens', $this->getAppTokens() ); - $this->initialStateService->provideInitialState( - 'settings', + $this->initialState->provideInitialState( 'can_create_app_token', $this->userSession->getImpersonatingUserID() === null ); diff --git a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php index e03e05c149a..f3d92051e46 100644 --- a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php +++ b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php @@ -30,7 +30,7 @@ use OC\Authentication\Token\DefaultToken; use OC\Authentication\Token\IProvider as IAuthTokenProvider; use OCA\Settings\Settings\Personal\Security\Authtokens; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IInitialStateService; +use OCP\AppFramework\Services\IInitialState; use OCP\ISession; use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; @@ -47,8 +47,8 @@ class AuthtokensTest extends TestCase { /** @var IUserSession|MockObject */ private $userSession; - /** @var IInitialStateService|MockObject */ - private $initialStateService; + /** @var IInitialState|MockObject */ + private $initialState; /** @var string */ private $uid; @@ -62,14 +62,14 @@ class AuthtokensTest extends TestCase { $this->authTokenProvider = $this->createMock(IAuthTokenProvider::class); $this->session = $this->createMock(ISession::class); $this->userSession = $this->createMock(IUserSession::class); - $this->initialStateService = $this->createMock(IInitialStateService::class); + $this->initialState = $this->createMock(IInitialState::class); $this->uid = 'test123'; $this->section = new Authtokens( $this->authTokenProvider, $this->session, $this->userSession, - $this->initialStateService, + $this->initialState, $this->uid ); } @@ -97,9 +97,9 @@ class AuthtokensTest extends TestCase { ->method('getToken') ->with('session123') ->willReturn($sessionToken); - $this->initialStateService->expects($this->at(0)) + $this->initialState->expects($this->at(0)) ->method('provideInitialState') - ->with('settings', 'app_tokens', [ + ->with('app_tokens', [ [ 'id' => 100, 'name' => null, @@ -121,9 +121,9 @@ class AuthtokensTest extends TestCase { ], ]); - $this->initialStateService->expects($this->at(1)) + $this->initialState->expects($this->at(1)) ->method('provideInitialState') - ->with('settings', 'can_create_app_token', true); + ->with('can_create_app_token', true); $form = $this->section->getForm(); |