2017-05-18 20:09:59 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2017-05-18 20:09:59 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-05-18 20:09:59 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\OAuth2\Tests\Controller;
|
|
|
|
|
2018-10-30 15:18:41 +03:00
|
|
|
use OC\Authentication\Exceptions\ExpiredTokenException;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OC\Authentication\Exceptions\InvalidTokenException;
|
2017-05-18 20:09:59 +03:00
|
|
|
use OC\Authentication\Token\DefaultToken;
|
2018-05-16 21:40:46 +03:00
|
|
|
use OC\Authentication\Token\IProvider as TokenProvider;
|
2018-10-30 00:12:18 +03:00
|
|
|
use OC\Security\Bruteforce\Throttler;
|
2017-05-18 20:09:59 +03:00
|
|
|
use OCA\OAuth2\Controller\OauthApiController;
|
|
|
|
use OCA\OAuth2\Db\AccessToken;
|
|
|
|
use OCA\OAuth2\Db\AccessTokenMapper;
|
2018-05-16 21:40:46 +03:00
|
|
|
use OCA\OAuth2\Db\Client;
|
|
|
|
use OCA\OAuth2\Db\ClientMapper;
|
|
|
|
use OCA\OAuth2\Exceptions\AccessTokenNotFoundException;
|
|
|
|
use OCA\OAuth2\Exceptions\ClientNotFoundException;
|
|
|
|
use OCP\AppFramework\Http;
|
2017-05-18 20:09:59 +03:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
2018-05-16 21:40:46 +03:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
2017-05-18 20:09:59 +03:00
|
|
|
use OCP\IRequest;
|
|
|
|
use OCP\Security\ICrypto;
|
|
|
|
use OCP\Security\ISecureRandom;
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class OauthApiControllerTest extends TestCase {
|
|
|
|
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $request;
|
|
|
|
/** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $crypto;
|
|
|
|
/** @var AccessTokenMapper|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $accessTokenMapper;
|
2018-05-16 21:40:46 +03:00
|
|
|
/** @var ClientMapper|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $clientMapper;
|
|
|
|
/** @var TokenProvider|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $tokenProvider;
|
2017-05-18 20:09:59 +03:00
|
|
|
/** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $secureRandom;
|
2018-05-16 21:40:46 +03:00
|
|
|
/** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $time;
|
2018-10-30 00:12:18 +03:00
|
|
|
/** @var Throttler|\PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $throttler;
|
2017-05-18 20:09:59 +03:00
|
|
|
/** @var OauthApiController */
|
|
|
|
private $oauthApiController;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2017-05-18 20:09:59 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->request = $this->createMock(IRequest::class);
|
|
|
|
$this->crypto = $this->createMock(ICrypto::class);
|
|
|
|
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
|
2018-05-16 21:40:46 +03:00
|
|
|
$this->clientMapper = $this->createMock(ClientMapper::class);
|
|
|
|
$this->tokenProvider = $this->createMock(TokenProvider::class);
|
2017-05-18 20:09:59 +03:00
|
|
|
$this->secureRandom = $this->createMock(ISecureRandom::class);
|
2018-05-16 21:40:46 +03:00
|
|
|
$this->time = $this->createMock(ITimeFactory::class);
|
2018-10-30 00:12:18 +03:00
|
|
|
$this->throttler = $this->createMock(Throttler::class);
|
2017-05-18 20:09:59 +03:00
|
|
|
|
|
|
|
$this->oauthApiController = new OauthApiController(
|
|
|
|
'oauth2',
|
|
|
|
$this->request,
|
|
|
|
$this->crypto,
|
|
|
|
$this->accessTokenMapper,
|
2018-05-16 21:40:46 +03:00
|
|
|
$this->clientMapper,
|
|
|
|
$this->tokenProvider,
|
|
|
|
$this->secureRandom,
|
2018-10-30 00:12:18 +03:00
|
|
|
$this->time,
|
|
|
|
$this->throttler
|
2017-05-18 20:09:59 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-05-16 21:40:46 +03:00
|
|
|
public function testGetTokenInvalidGrantType() {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_grant',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('foo', null, null, null, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTokenInvalidCode() {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_request',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('invalidcode')
|
|
|
|
->willThrowException(new AccessTokenNotFoundException());
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('authorization_code', 'invalidcode', null, null, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTokenInvalidRefreshToken() {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_request',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('invalidrefresh')
|
|
|
|
->willThrowException(new AccessTokenNotFoundException());
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'invalidrefresh', null, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTokenClientDoesNotExist() {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_request',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
2017-05-18 20:09:59 +03:00
|
|
|
$accessToken = new AccessToken();
|
2018-05-16 21:40:46 +03:00
|
|
|
$accessToken->setClientId(42);
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
2017-05-18 20:09:59 +03:00
|
|
|
->willReturn($accessToken);
|
2018-05-16 21:40:46 +03:00
|
|
|
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willThrowException(new ClientNotFoundException());
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', null, null));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function invalidClientProvider() {
|
|
|
|
return [
|
|
|
|
['invalidClientId', 'invalidClientSecret'],
|
|
|
|
['clientId', 'invalidClientSecret'],
|
|
|
|
['invalidClientId', 'clientSecret'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider invalidClientProvider
|
|
|
|
*
|
|
|
|
* @param string $clientId
|
|
|
|
* @param string $clientSecret
|
|
|
|
*/
|
|
|
|
public function testGetTokenInvalidClient($clientId, $clientSecret) {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_client',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
|
|
|
$accessToken = new AccessToken();
|
|
|
|
$accessToken->setClientId(42);
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
|
|
|
->willReturn($accessToken);
|
|
|
|
|
|
|
|
$client = new Client();
|
|
|
|
$client->setClientIdentifier('clientId');
|
|
|
|
$client->setSecret('clientSecret');
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', $clientId, $clientSecret));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTokenInvalidAppToken() {
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'error' => 'invalid_request',
|
|
|
|
], Http::STATUS_BAD_REQUEST);
|
|
|
|
|
|
|
|
$accessToken = new AccessToken();
|
|
|
|
$accessToken->setClientId(42);
|
|
|
|
$accessToken->setTokenId(1337);
|
|
|
|
$accessToken->setEncryptedToken('encryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
|
|
|
->willReturn($accessToken);
|
|
|
|
|
|
|
|
$client = new Client();
|
|
|
|
$client->setClientIdentifier('clientId');
|
|
|
|
$client->setSecret('clientSecret');
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$this->crypto->method('decrypt')
|
|
|
|
->with(
|
|
|
|
'encryptedToken',
|
|
|
|
'validrefresh'
|
|
|
|
)->willReturn('decryptedToken');
|
|
|
|
|
|
|
|
$this->tokenProvider->method('getTokenById')
|
|
|
|
->with(1337)
|
|
|
|
->willThrowException(new InvalidTokenException());
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->once())
|
|
|
|
->method('delete')
|
|
|
|
->with($accessToken);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', 'clientId', 'clientSecret'));
|
2017-05-18 20:09:59 +03:00
|
|
|
}
|
|
|
|
|
2018-05-16 21:40:46 +03:00
|
|
|
public function testGetTokenValidAppToken() {
|
|
|
|
$accessToken = new AccessToken();
|
|
|
|
$accessToken->setClientId(42);
|
|
|
|
$accessToken->setTokenId(1337);
|
|
|
|
$accessToken->setEncryptedToken('encryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
|
|
|
->willReturn($accessToken);
|
|
|
|
|
|
|
|
$client = new Client();
|
|
|
|
$client->setClientIdentifier('clientId');
|
|
|
|
$client->setSecret('clientSecret');
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$this->crypto->method('decrypt')
|
|
|
|
->with(
|
|
|
|
'encryptedToken',
|
|
|
|
'validrefresh'
|
|
|
|
)->willReturn('decryptedToken');
|
|
|
|
|
|
|
|
$appToken = new DefaultToken();
|
|
|
|
$appToken->setUid('userId');
|
|
|
|
$this->tokenProvider->method('getTokenById')
|
|
|
|
->with(1337)
|
|
|
|
->willThrowException(new ExpiredTokenException($appToken));
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->never())
|
|
|
|
->method('delete')
|
|
|
|
->with($accessToken);
|
|
|
|
|
|
|
|
$this->secureRandom->method('generate')
|
|
|
|
->will($this->returnCallback(function ($len) {
|
|
|
|
return 'random'.$len;
|
|
|
|
}));
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('rotate')
|
|
|
|
->with(
|
|
|
|
$appToken,
|
|
|
|
'decryptedToken',
|
|
|
|
'random72'
|
|
|
|
)->willReturn($appToken);
|
|
|
|
|
|
|
|
$this->time->method('getTime')
|
|
|
|
->willReturn(1000);
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('updateToken')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (DefaultToken $token) {
|
|
|
|
return $token->getExpires() === 4600;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->crypto->method('encrypt')
|
|
|
|
->with('random72', 'random128')
|
|
|
|
->willReturn('newEncryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->once())
|
|
|
|
->method('update')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (AccessToken $token) {
|
|
|
|
return $token->getHashedCode() === hash('sha512', 'random128') &&
|
|
|
|
$token->getEncryptedToken() === 'newEncryptedToken';
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'access_token' => 'random72',
|
|
|
|
'token_type' => 'Bearer',
|
|
|
|
'expires_in' => 3600,
|
|
|
|
'refresh_token' => 'random128',
|
|
|
|
'user_id' => 'userId',
|
|
|
|
]);
|
|
|
|
|
2018-10-30 00:12:18 +03:00
|
|
|
$this->request->method('getRemoteAddress')
|
|
|
|
->willReturn('1.2.3.4');
|
|
|
|
|
|
|
|
$this->throttler->expects($this->once())
|
|
|
|
->method('resetDelay')
|
|
|
|
->with(
|
|
|
|
'1.2.3.4',
|
|
|
|
'login',
|
|
|
|
['user' => 'userId']
|
|
|
|
);
|
|
|
|
|
2018-05-16 21:40:46 +03:00
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', 'clientId', 'clientSecret'));
|
|
|
|
}
|
|
|
|
|
2018-05-29 16:13:43 +03:00
|
|
|
public function testGetTokenValidAppTokenBasicAuth() {
|
|
|
|
$accessToken = new AccessToken();
|
|
|
|
$accessToken->setClientId(42);
|
|
|
|
$accessToken->setTokenId(1337);
|
|
|
|
$accessToken->setEncryptedToken('encryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
|
|
|
->willReturn($accessToken);
|
|
|
|
|
|
|
|
$client = new Client();
|
|
|
|
$client->setClientIdentifier('clientId');
|
|
|
|
$client->setSecret('clientSecret');
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$this->crypto->method('decrypt')
|
|
|
|
->with(
|
|
|
|
'encryptedToken',
|
|
|
|
'validrefresh'
|
|
|
|
)->willReturn('decryptedToken');
|
|
|
|
|
|
|
|
$appToken = new DefaultToken();
|
|
|
|
$appToken->setUid('userId');
|
|
|
|
$this->tokenProvider->method('getTokenById')
|
|
|
|
->with(1337)
|
|
|
|
->willThrowException(new ExpiredTokenException($appToken));
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->never())
|
|
|
|
->method('delete')
|
|
|
|
->with($accessToken);
|
|
|
|
|
|
|
|
$this->secureRandom->method('generate')
|
|
|
|
->will($this->returnCallback(function ($len) {
|
|
|
|
return 'random'.$len;
|
|
|
|
}));
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('rotate')
|
|
|
|
->with(
|
|
|
|
$appToken,
|
|
|
|
'decryptedToken',
|
|
|
|
'random72'
|
|
|
|
)->willReturn($appToken);
|
|
|
|
|
|
|
|
$this->time->method('getTime')
|
|
|
|
->willReturn(1000);
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('updateToken')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (DefaultToken $token) {
|
|
|
|
return $token->getExpires() === 4600;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->crypto->method('encrypt')
|
|
|
|
->with('random72', 'random128')
|
|
|
|
->willReturn('newEncryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->once())
|
|
|
|
->method('update')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (AccessToken $token) {
|
|
|
|
return $token->getHashedCode() === hash('sha512', 'random128') &&
|
|
|
|
$token->getEncryptedToken() === 'newEncryptedToken';
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'access_token' => 'random72',
|
|
|
|
'token_type' => 'Bearer',
|
|
|
|
'expires_in' => 3600,
|
|
|
|
'refresh_token' => 'random128',
|
|
|
|
'user_id' => 'userId',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->request->server['PHP_AUTH_USER'] = 'clientId';
|
|
|
|
$this->request->server['PHP_AUTH_PW'] = 'clientSecret';
|
|
|
|
|
2018-10-30 00:12:18 +03:00
|
|
|
$this->request->method('getRemoteAddress')
|
|
|
|
->willReturn('1.2.3.4');
|
|
|
|
|
|
|
|
$this->throttler->expects($this->once())
|
|
|
|
->method('resetDelay')
|
|
|
|
->with(
|
|
|
|
'1.2.3.4',
|
|
|
|
'login',
|
|
|
|
['user' => 'userId']
|
|
|
|
);
|
|
|
|
|
2018-05-29 16:13:43 +03:00
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', null, null));
|
|
|
|
}
|
|
|
|
|
2018-05-16 21:40:46 +03:00
|
|
|
public function testGetTokenExpiredAppToken() {
|
|
|
|
$accessToken = new AccessToken();
|
|
|
|
$accessToken->setClientId(42);
|
|
|
|
$accessToken->setTokenId(1337);
|
|
|
|
$accessToken->setEncryptedToken('encryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->method('getByCode')
|
|
|
|
->with('validrefresh')
|
|
|
|
->willReturn($accessToken);
|
|
|
|
|
|
|
|
$client = new Client();
|
|
|
|
$client->setClientIdentifier('clientId');
|
|
|
|
$client->setSecret('clientSecret');
|
|
|
|
$this->clientMapper->method('getByUid')
|
|
|
|
->with(42)
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$this->crypto->method('decrypt')
|
|
|
|
->with(
|
|
|
|
'encryptedToken',
|
|
|
|
'validrefresh'
|
|
|
|
)->willReturn('decryptedToken');
|
|
|
|
|
|
|
|
$appToken = new DefaultToken();
|
|
|
|
$appToken->setUid('userId');
|
|
|
|
$this->tokenProvider->method('getTokenById')
|
|
|
|
->with(1337)
|
|
|
|
->willReturn($appToken);
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->never())
|
|
|
|
->method('delete')
|
|
|
|
->with($accessToken);
|
|
|
|
|
|
|
|
$this->secureRandom->method('generate')
|
|
|
|
->will($this->returnCallback(function ($len) {
|
|
|
|
return 'random'.$len;
|
|
|
|
}));
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('rotate')
|
|
|
|
->with(
|
|
|
|
$appToken,
|
|
|
|
'decryptedToken',
|
|
|
|
'random72'
|
|
|
|
)->willReturn($appToken);
|
|
|
|
|
|
|
|
$this->time->method('getTime')
|
|
|
|
->willReturn(1000);
|
|
|
|
|
|
|
|
$this->tokenProvider->expects($this->once())
|
|
|
|
->method('updateToken')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (DefaultToken $token) {
|
|
|
|
return $token->getExpires() === 4600;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->crypto->method('encrypt')
|
|
|
|
->with('random72', 'random128')
|
|
|
|
->willReturn('newEncryptedToken');
|
|
|
|
|
|
|
|
$this->accessTokenMapper->expects($this->once())
|
|
|
|
->method('update')
|
|
|
|
->with(
|
|
|
|
$this->callback(function (AccessToken $token) {
|
|
|
|
return $token->getHashedCode() === hash('sha512', 'random128') &&
|
|
|
|
$token->getEncryptedToken() === 'newEncryptedToken';
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = new JSONResponse([
|
|
|
|
'access_token' => 'random72',
|
|
|
|
'token_type' => 'Bearer',
|
|
|
|
'expires_in' => 3600,
|
|
|
|
'refresh_token' => 'random128',
|
|
|
|
'user_id' => 'userId',
|
|
|
|
]);
|
|
|
|
|
2018-10-30 00:12:18 +03:00
|
|
|
$this->request->method('getRemoteAddress')
|
|
|
|
->willReturn('1.2.3.4');
|
|
|
|
|
|
|
|
$this->throttler->expects($this->once())
|
|
|
|
->method('resetDelay')
|
|
|
|
->with(
|
|
|
|
'1.2.3.4',
|
|
|
|
'login',
|
|
|
|
['user' => 'userId']
|
|
|
|
);
|
|
|
|
|
2018-05-16 21:40:46 +03:00
|
|
|
$this->assertEquals($expected, $this->oauthApiController->getToken('refresh_token', null, 'validrefresh', 'clientId', 'clientSecret'));
|
|
|
|
}
|
2017-05-18 20:09:59 +03:00
|
|
|
}
|