aboutsummaryrefslogtreecommitdiffstats
path: root/apps/oauth2
diff options
context:
space:
mode:
authorArtur Neumann <artur@jankaritech.com>2022-11-22 12:15:28 +0545
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-03-14 17:13:29 +0100
commit707e69b203bd63149e9731a76a93049cc0eaf12e (patch)
tree77c8f3a9eb7d3e6583a4f4fcc967ed9a62bb8882 /apps/oauth2
parentf634badf1218baff90acde501859081e3765d79f (diff)
downloadnextcloud-server-707e69b203bd63149e9731a76a93049cc0eaf12e.tar.gz
nextcloud-server-707e69b203bd63149e9731a76a93049cc0eaf12e.zip
adjust SettingsController tests
Signed-off-by: Artur Neumann <artur@jankaritech.com>
Diffstat (limited to 'apps/oauth2')
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php20
1 files changed, 5 insertions, 15 deletions
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 6be8a4ee4b9..b11c59fd414 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -27,7 +27,7 @@
namespace OCA\OAuth2\Tests\Controller;
use OC\Authentication\Token\IToken;
-use OC\Authentication\Token\IProvider as IAuthTokenProvider;
+use OCP\Authentication\Token\IProvider as IAuthTokenProvider;
use OCA\OAuth2\Controller\SettingsController;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
@@ -133,24 +133,13 @@ class SettingsControllerTest extends TestCase {
};
$userManager->callForAllUsers($function);
$user1 = $userManager->createUser('test101', 'test101');
- $tokenMocks[0] = $this->getMockBuilder(IToken::class)->getMock();
- $tokenMocks[0]->method('getName')->willReturn('Firefox session');
- $tokenMocks[0]->method('getId')->willReturn(1);
- $tokenMocks[1] = $this->getMockBuilder(IToken::class)->getMock();
- $tokenMocks[1]->method('getName')->willReturn('My Client Name');
- $tokenMocks[1]->method('getId')->willReturn(2);
- $tokenMocks[2] = $this->getMockBuilder(IToken::class)->getMock();
- $tokenMocks[2]->method('getName')->willReturn('mobile client');
- $tokenMocks[2]->method('getId')->willReturn(3);
-
$tokenProviderMock = $this->getMockBuilder(IAuthTokenProvider::class)->getMock();
- $tokenProviderMock->method('getTokenByUser')->willReturn($tokenMocks);
- // expect one call per user and make sure the correct tokeId is selected
+ // expect one call per user and ensure the correct client name
$tokenProviderMock
->expects($this->exactly($count + 1))
- ->method('invalidateTokenById')
- ->with($this->isType('string'), 2);
+ ->method('invalidateTokensOfUser')
+ ->with($this->isType('string'), 'My Client Name');
$client = new Client();
$client->setId(123);
@@ -168,6 +157,7 @@ class SettingsControllerTest extends TestCase {
->method('deleteByClientId')
->with(123);
$this->clientMapper
+ ->expects($this->once())
->method('delete')
->with($client);