Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions apps/oauth2/lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*/
namespace OCA\OAuth2\Controller;

use OC\Authentication\Token\DefaultTokenMapper;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
Expand All @@ -48,34 +47,22 @@ class SettingsController extends Controller {
private $secureRandom;
/** @var AccessTokenMapper */
private $accessTokenMapper;
/** @var DefaultTokenMapper */
private $defaultTokenMapper;
/** @var IL10N */
private $l;

public const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

/**
* @param string $appName
* @param IRequest $request
* @param ClientMapper $clientMapper
* @param ISecureRandom $secureRandom
* @param AccessTokenMapper $accessTokenMapper
* @param DefaultTokenMapper $defaultTokenMapper
*/
public function __construct(string $appName,
IRequest $request,
ClientMapper $clientMapper,
ISecureRandom $secureRandom,
AccessTokenMapper $accessTokenMapper,
DefaultTokenMapper $defaultTokenMapper,
IL10N $l
) {
parent::__construct($appName, $request);
$this->secureRandom = $secureRandom;
$this->clientMapper = $clientMapper;
$this->accessTokenMapper = $accessTokenMapper;
$this->defaultTokenMapper = $defaultTokenMapper;
$this->l = $l;
}

Expand Down Expand Up @@ -106,7 +93,6 @@ public function addClient(string $name,
public function deleteClient(int $id): JSONResponse {
$client = $this->clientMapper->getByUid($id);
$this->accessTokenMapper->deleteByClientId($id);
$this->defaultTokenMapper->deleteByName($client->getName());
$this->clientMapper->delete($client);
return new JSONResponse([]);
}
Expand Down
14 changes: 7 additions & 7 deletions apps/oauth2/tests/Controller/OauthApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

use OC\Authentication\Exceptions\ExpiredTokenException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\IProvider as TokenProvider;
use OC\Authentication\Token\PublicKeyToken;
use OC\Security\Bruteforce\Throttler;
use OCA\OAuth2\Controller\OauthApiController;
use OCA\OAuth2\Db\AccessToken;
Expand Down Expand Up @@ -238,7 +238,7 @@ public function testGetTokenValidAppToken() {
'validrefresh'
)->willReturn('decryptedToken');

$appToken = new DefaultToken();
$appToken = new PublicKeyToken();
$appToken->setUid('userId');
$this->tokenProvider->method('getTokenById')
->with(1337)
Expand Down Expand Up @@ -267,7 +267,7 @@ public function testGetTokenValidAppToken() {
$this->tokenProvider->expects($this->once())
->method('updateToken')
->with(
$this->callback(function (DefaultToken $token) {
$this->callback(function (PublicKeyToken $token) {
return $token->getExpires() === 4600;
})
);
Expand Down Expand Up @@ -330,7 +330,7 @@ public function testGetTokenValidAppTokenBasicAuth() {
'validrefresh'
)->willReturn('decryptedToken');

$appToken = new DefaultToken();
$appToken = new PublicKeyToken();
$appToken->setUid('userId');
$this->tokenProvider->method('getTokenById')
->with(1337)
Expand Down Expand Up @@ -359,7 +359,7 @@ public function testGetTokenValidAppTokenBasicAuth() {
$this->tokenProvider->expects($this->once())
->method('updateToken')
->with(
$this->callback(function (DefaultToken $token) {
$this->callback(function (PublicKeyToken $token) {
return $token->getExpires() === 4600;
})
);
Expand Down Expand Up @@ -425,7 +425,7 @@ public function testGetTokenExpiredAppToken() {
'validrefresh'
)->willReturn('decryptedToken');

$appToken = new DefaultToken();
$appToken = new PublicKeyToken();
$appToken->setUid('userId');
$this->tokenProvider->method('getTokenById')
->with(1337)
Expand Down Expand Up @@ -454,7 +454,7 @@ public function testGetTokenExpiredAppToken() {
$this->tokenProvider->expects($this->once())
->method('updateToken')
->with(
$this->callback(function (DefaultToken $token) {
$this->callback(function (PublicKeyToken $token) {
return $token->getExpires() === 4600;
})
);
Expand Down
9 changes: 0 additions & 9 deletions apps/oauth2/tests/Controller/SettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
namespace OCA\OAuth2\Tests\Controller;

use OC\Authentication\Token\DefaultTokenMapper;
use OCA\OAuth2\Controller\SettingsController;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
Expand All @@ -47,8 +46,6 @@ class SettingsControllerTest extends TestCase {
private $secureRandom;
/** @var AccessTokenMapper|\PHPUnit\Framework\MockObject\MockObject */
private $accessTokenMapper;
/** @var DefaultTokenMapper|\PHPUnit\Framework\MockObject\MockObject */
private $defaultTokenMapper;
/** @var SettingsController */
private $settingsController;

Expand All @@ -59,7 +56,6 @@ protected function setUp(): void {
$this->clientMapper = $this->createMock(ClientMapper::class);
$this->secureRandom = $this->createMock(ISecureRandom::class);
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
$this->defaultTokenMapper = $this->createMock(DefaultTokenMapper::class);
$l = $this->createMock(IL10N::class);
$l->method('t')
->willReturnArgument(0);
Expand All @@ -70,7 +66,6 @@ protected function setUp(): void {
$this->clientMapper,
$this->secureRandom,
$this->accessTokenMapper,
$this->defaultTokenMapper,
$l
);
}
Expand Down Expand Up @@ -136,10 +131,6 @@ public function testDeleteClient() {
->expects($this->once())
->method('deleteByClientId')
->with(123);
$this->defaultTokenMapper
->expects($this->once())
->method('deleteByName')
->with('My Client Name');
$this->clientMapper
->method('delete')
->with($client);
Expand Down
18 changes: 9 additions & 9 deletions apps/settings/tests/Controller/AuthSettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
use OC\AppFramework\Http;
use OC\Authentication\Exceptions\ExpiredTokenException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Authentication\Token\IWipeableToken;
use OC\Authentication\Token\PublicKeyToken;
use OC\Authentication\Token\RemoteWipe;
use OCA\Settings\Controller\AuthSettingsController;
use OCP\Activity\IEvent;
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testCreateInvalidToken() {

public function testDestroy() {
$tokenId = 124;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);
$this->mockActivityManager();
Expand All @@ -200,7 +200,7 @@ public function testDestroy() {

public function testDestroyExpired() {
$tokenId = 124;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$token->expects($this->exactly(2))
->method('getId')
Expand All @@ -224,7 +224,7 @@ public function testDestroyExpired() {

public function testDestroyWrongUser() {
$tokenId = 124;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);

Expand Down Expand Up @@ -252,7 +252,7 @@ public function dataRenameToken(): array {
*/
public function testUpdateRename(string $name, string $newName): void {
$tokenId = 42;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);
$this->mockActivityManager();
Expand Down Expand Up @@ -295,7 +295,7 @@ public function dataUpdateFilesystemScope(): array {
*/
public function testUpdateFilesystemScope(bool $filesystem, bool $newFilesystem): void {
$tokenId = 42;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);
$this->mockActivityManager();
Expand Down Expand Up @@ -325,7 +325,7 @@ public function testUpdateFilesystemScope(bool $filesystem, bool $newFilesystem)

public function testUpdateNoChange(): void {
$tokenId = 42;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);

Expand Down Expand Up @@ -356,7 +356,7 @@ public function testUpdateNoChange(): void {

public function testUpdateExpired() {
$tokenId = 42;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$token->expects($this->once())
->method('getUID')
Expand All @@ -376,7 +376,7 @@ public function testUpdateExpired() {

public function testUpdateTokenWrongUser() {
$tokenId = 42;
$token = $this->createMock(DefaultToken::class);
$token = $this->createMock(PublicKeyToken::class);

$this->mockGetTokenById($tokenId, $token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
namespace OCA\Settings\Tests\Settings\Personal\Security;

use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\IProvider as IAuthTokenProvider;
use OC\Authentication\Token\PublicKeyToken;
use OCA\Settings\Settings\Personal\Security\Authtokens;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
Expand Down Expand Up @@ -74,15 +74,15 @@ protected function setUp(): void {
}

public function testGetForm() {
$token1 = new DefaultToken();
$token1 = new PublicKeyToken();
$token1->setId(100);
$token2 = new DefaultToken();
$token2 = new PublicKeyToken();
$token2->setId(200);
$tokens = [
$token1,
$token2,
];
$sessionToken = new DefaultToken();
$sessionToken = new PublicKeyToken();
$sessionToken->setId(100);

$this->authTokenProvider->expects($this->once())
Expand Down
4 changes: 0 additions & 4 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,6 @@
'OC\\Authentication\\Login\\WebAuthnChain' => $baseDir . '/lib/private/Authentication/Login/WebAuthnChain.php',
'OC\\Authentication\\Login\\WebAuthnLoginCommand' => $baseDir . '/lib/private/Authentication/Login/WebAuthnLoginCommand.php',
'OC\\Authentication\\Notifications\\Notifier' => $baseDir . '/lib/private/Authentication/Notifications/Notifier.php',
'OC\\Authentication\\Token\\DefaultToken' => $baseDir . '/lib/private/Authentication/Token/DefaultToken.php',
'OC\\Authentication\\Token\\DefaultTokenCleanupJob' => $baseDir . '/lib/private/Authentication/Token/DefaultTokenCleanupJob.php',
'OC\\Authentication\\Token\\DefaultTokenMapper' => $baseDir . '/lib/private/Authentication/Token/DefaultTokenMapper.php',
'OC\\Authentication\\Token\\DefaultTokenProvider' => $baseDir . '/lib/private/Authentication/Token/DefaultTokenProvider.php',
'OC\\Authentication\\Token\\INamedToken' => $baseDir . '/lib/private/Authentication/Token/INamedToken.php',
'OC\\Authentication\\Token\\IProvider' => $baseDir . '/lib/private/Authentication/Token/IProvider.php',
'OC\\Authentication\\Token\\IToken' => $baseDir . '/lib/private/Authentication/Token/IToken.php',
Expand Down
4 changes: 0 additions & 4 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Authentication\\Login\\WebAuthnChain' => __DIR__ . '/../../..' . '/lib/private/Authentication/Login/WebAuthnChain.php',
'OC\\Authentication\\Login\\WebAuthnLoginCommand' => __DIR__ . '/../../..' . '/lib/private/Authentication/Login/WebAuthnLoginCommand.php',
'OC\\Authentication\\Notifications\\Notifier' => __DIR__ . '/../../..' . '/lib/private/Authentication/Notifications/Notifier.php',
'OC\\Authentication\\Token\\DefaultToken' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/DefaultToken.php',
'OC\\Authentication\\Token\\DefaultTokenCleanupJob' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/DefaultTokenCleanupJob.php',
'OC\\Authentication\\Token\\DefaultTokenMapper' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/DefaultTokenMapper.php',
'OC\\Authentication\\Token\\DefaultTokenProvider' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/DefaultTokenProvider.php',
'OC\\Authentication\\Token\\INamedToken' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/INamedToken.php',
'OC\\Authentication\\Token\\IProvider' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/IProvider.php',
'OC\\Authentication\\Token\\IToken' => __DIR__ . '/../../..' . '/lib/private/Authentication/Token/IToken.php',
Expand Down
Loading