|
|
|
|
@ -41,6 +41,7 @@ use OCP\IUserSession; |
|
|
|
|
use OCP\Security\ICrypto; |
|
|
|
|
use OCP\Security\ISecureRandom; |
|
|
|
|
use OCP\Session\Exceptions\SessionNotAvailableException; |
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
|
|
|
use Test\TestCase; |
|
|
|
|
|
|
|
|
|
class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
@ -66,6 +67,9 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
private $accessTokenMapper; |
|
|
|
|
/** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */ |
|
|
|
|
private $crypto; |
|
|
|
|
/** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ |
|
|
|
|
private $eventDispatcher; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var ClientFlowLoginController */ |
|
|
|
|
private $clientFlowLoginController; |
|
|
|
|
@ -90,6 +94,7 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
$this->clientMapper = $this->createMock(ClientMapper::class); |
|
|
|
|
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class); |
|
|
|
|
$this->crypto = $this->createMock(ICrypto::class); |
|
|
|
|
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); |
|
|
|
|
|
|
|
|
|
$this->clientFlowLoginController = new ClientFlowLoginController( |
|
|
|
|
'core', |
|
|
|
|
@ -103,7 +108,8 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
$this->urlGenerator, |
|
|
|
|
$this->clientMapper, |
|
|
|
|
$this->accessTokenMapper, |
|
|
|
|
$this->crypto |
|
|
|
|
$this->crypto, |
|
|
|
|
$this->eventDispatcher |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -378,6 +384,9 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
->method('getHeader') |
|
|
|
|
->willReturn(''); |
|
|
|
|
|
|
|
|
|
$this->eventDispatcher->expects($this->once()) |
|
|
|
|
->method('dispatch'); |
|
|
|
|
|
|
|
|
|
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); |
|
|
|
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); |
|
|
|
|
} |
|
|
|
|
@ -462,6 +471,9 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
->with('MyClientIdentifier') |
|
|
|
|
->willReturn($client); |
|
|
|
|
|
|
|
|
|
$this->eventDispatcher->expects($this->once()) |
|
|
|
|
->method('dispatch'); |
|
|
|
|
|
|
|
|
|
$expected = new Http\RedirectResponse('https://example.com/redirect.php?state=MyOauthState&code=MyAccessCode'); |
|
|
|
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier')); |
|
|
|
|
} |
|
|
|
|
@ -534,6 +546,9 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
->method('getHeader') |
|
|
|
|
->willReturn(''); |
|
|
|
|
|
|
|
|
|
$this->eventDispatcher->expects($this->once()) |
|
|
|
|
->method('dispatch'); |
|
|
|
|
|
|
|
|
|
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); |
|
|
|
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); |
|
|
|
|
} |
|
|
|
|
@ -662,6 +677,9 @@ class ClientFlowLoginControllerTest extends TestCase { |
|
|
|
|
->method('getHeader') |
|
|
|
|
->willReturnMap($headers); |
|
|
|
|
|
|
|
|
|
$this->eventDispatcher->expects($this->once()) |
|
|
|
|
->method('dispatch'); |
|
|
|
|
|
|
|
|
|
$expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); |
|
|
|
|
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); |
|
|
|
|
} |
|
|
|
|
|