Revert controller tests to match stable21 API
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
parent
6fcb1ab834
commit
31f7257c30
|
@ -35,11 +35,11 @@ use OCP\Authentication\Exceptions\CredentialsUnavailableException;
|
||||||
use OCP\Authentication\Exceptions\PasswordUnavailableException;
|
use OCP\Authentication\Exceptions\PasswordUnavailableException;
|
||||||
use OCP\Authentication\LoginCredentials\ICredentials;
|
use OCP\Authentication\LoginCredentials\ICredentials;
|
||||||
use OCP\Authentication\LoginCredentials\IStore;
|
use OCP\Authentication\LoginCredentials\IStore;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\ISession;
|
use OCP\ISession;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class AppPasswordControllerTest extends TestCase {
|
class AppPasswordControllerTest extends TestCase {
|
||||||
|
@ -59,7 +59,7 @@ class AppPasswordControllerTest extends TestCase {
|
||||||
/** @var IRequest|MockObject */
|
/** @var IRequest|MockObject */
|
||||||
private $request;
|
private $request;
|
||||||
|
|
||||||
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $eventDispatcher;
|
private $eventDispatcher;
|
||||||
|
|
||||||
/** @var AppPasswordController */
|
/** @var AppPasswordController */
|
||||||
|
@ -73,7 +73,7 @@ class AppPasswordControllerTest extends TestCase {
|
||||||
$this->tokenProvider = $this->createMock(IProvider::class);
|
$this->tokenProvider = $this->createMock(IProvider::class);
|
||||||
$this->credentialStore = $this->createMock(IStore::class);
|
$this->credentialStore = $this->createMock(IStore::class);
|
||||||
$this->request = $this->createMock(IRequest::class);
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||||
|
|
||||||
$this->controller = new AppPasswordController(
|
$this->controller = new AppPasswordController(
|
||||||
'core',
|
'core',
|
||||||
|
@ -144,7 +144,7 @@ class AppPasswordControllerTest extends TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$this->controller->getAppPassword();
|
$this->controller->getAppPassword();
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ class AppPasswordControllerTest extends TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$this->controller->getAppPassword();
|
$this->controller->getAppPassword();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ use OCA\OAuth2\Db\ClientMapper;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\StandaloneTemplateResponse;
|
use OCP\AppFramework\Http\StandaloneTemplateResponse;
|
||||||
use OCP\Defaults;
|
use OCP\Defaults;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\ISession;
|
use OCP\ISession;
|
||||||
|
@ -42,6 +41,7 @@ use OCP\IUserSession;
|
||||||
use OCP\Security\ICrypto;
|
use OCP\Security\ICrypto;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
use OCP\Session\Exceptions\SessionNotAvailableException;
|
use OCP\Session\Exceptions\SessionNotAvailableException;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class ClientFlowLoginControllerTest extends TestCase {
|
class ClientFlowLoginControllerTest extends TestCase {
|
||||||
|
@ -67,7 +67,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
private $accessTokenMapper;
|
private $accessTokenMapper;
|
||||||
/** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $crypto;
|
private $crypto;
|
||||||
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $eventDispatcher;
|
private $eventDispatcher;
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
$this->clientMapper = $this->createMock(ClientMapper::class);
|
$this->clientMapper = $this->createMock(ClientMapper::class);
|
||||||
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
|
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
|
||||||
$this->crypto = $this->createMock(ICrypto::class);
|
$this->crypto = $this->createMock(ICrypto::class);
|
||||||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||||
|
|
||||||
$this->clientFlowLoginController = new ClientFlowLoginController(
|
$this->clientFlowLoginController = new ClientFlowLoginController(
|
||||||
'core',
|
'core',
|
||||||
|
@ -392,7 +392,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
->willReturn('');
|
->willReturn('');
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||||
|
@ -488,7 +488,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
->willReturn($client);
|
->willReturn($client);
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse($redirectUrl);
|
$expected = new Http\RedirectResponse($redirectUrl);
|
||||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier'));
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier'));
|
||||||
|
@ -563,7 +563,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
->willReturn('');
|
->willReturn('');
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||||
|
@ -694,7 +694,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
||||||
->willReturnMap($headers);
|
->willReturnMap($headers);
|
||||||
|
|
||||||
$this->eventDispatcher->expects($this->once())
|
$this->eventDispatcher->expects($this->once())
|
||||||
->method('dispatchTyped');
|
->method('dispatch');
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken');
|
$expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||||
|
|
Loading…
Reference in New Issue