Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-12-02 00:17:19 +0300
committerJoas Schilling <coding@schilljs.com>2021-12-02 00:17:19 +0300
commitc6ae53096c36e6a475467eaeb6df00ac8d38e4b2 (patch)
tree80deaa0d05a26564937a03d430197d1f6a57d30b /apps
parent9f001790379829096939015e790f0a35b6a38787 (diff)
More test fixing
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/oauth2/lib/Controller/SettingsController.php14
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php9
-rw-r--r--apps/settings/tests/Controller/AuthSettingsControllerTest.php18
-rw-r--r--apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php8
4 files changed, 13 insertions, 36 deletions
diff --git a/apps/oauth2/lib/Controller/SettingsController.php b/apps/oauth2/lib/Controller/SettingsController.php
index 28500128629..046e6d77041 100644
--- a/apps/oauth2/lib/Controller/SettingsController.php
+++ b/apps/oauth2/lib/Controller/SettingsController.php
@@ -30,7 +30,6 @@ declare(strict_types=1);
*/
namespace OCA\OAuth2\Controller;
-use OC\Authentication\Token\DefaultTokenMapper;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
@@ -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;
}
@@ -106,7 +93,6 @@ class SettingsController extends Controller {
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([]);
}
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 40785e280a0..4954d379f9d 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -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;
@@ -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;
@@ -59,7 +56,6 @@ class SettingsControllerTest extends TestCase {
$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);
@@ -70,7 +66,6 @@ class SettingsControllerTest extends TestCase {
$this->clientMapper,
$this->secureRandom,
$this->accessTokenMapper,
- $this->defaultTokenMapper,
$l
);
}
@@ -136,10 +131,6 @@ class SettingsControllerTest extends TestCase {
->expects($this->once())
->method('deleteByClientId')
->with(123);
- $this->defaultTokenMapper
- ->expects($this->once())
- ->method('deleteByName')
- ->with('My Client Name');
$this->clientMapper
->method('delete')
->with($client);
diff --git a/apps/settings/tests/Controller/AuthSettingsControllerTest.php b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
index 477d0fcc8f5..b744b942e09 100644
--- a/apps/settings/tests/Controller/AuthSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AuthSettingsControllerTest.php
@@ -32,10 +32,10 @@ namespace Test\Settings\Controller;
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;
@@ -178,7 +178,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testDestroy() {
$tokenId = 124;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$this->mockGetTokenById($tokenId, $token);
$this->mockActivityManager();
@@ -200,7 +200,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testDestroyExpired() {
$tokenId = 124;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$token->expects($this->exactly(2))
->method('getId')
@@ -224,7 +224,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testDestroyWrongUser() {
$tokenId = 124;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$this->mockGetTokenById($tokenId, $token);
@@ -252,7 +252,7 @@ class AuthSettingsControllerTest extends TestCase {
*/
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();
@@ -295,7 +295,7 @@ class AuthSettingsControllerTest extends TestCase {
*/
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();
@@ -325,7 +325,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testUpdateNoChange(): void {
$tokenId = 42;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$this->mockGetTokenById($tokenId, $token);
@@ -356,7 +356,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testUpdateExpired() {
$tokenId = 42;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$token->expects($this->once())
->method('getUID')
@@ -376,7 +376,7 @@ class AuthSettingsControllerTest extends TestCase {
public function testUpdateTokenWrongUser() {
$tokenId = 42;
- $token = $this->createMock(DefaultToken::class);
+ $token = $this->createMock(PublicKeyToken::class);
$this->mockGetTokenById($tokenId, $token);
diff --git a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
index 3ee39c3624c..8fae0a44d8f 100644
--- a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
+++ b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
@@ -25,8 +25,8 @@ declare(strict_types=1);
*/
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;
@@ -74,15 +74,15 @@ class AuthtokensTest extends TestCase {
}
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())