|
|
|
|
@ -41,15 +41,17 @@ class TokenControllerTest extends TestCase { |
|
|
|
|
protected function setUp() { |
|
|
|
|
parent::setUp(); |
|
|
|
|
|
|
|
|
|
$this->request = $this->getMock('\OCP\IRequest'); |
|
|
|
|
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock(); |
|
|
|
|
$this->userManager = $this->getMockBuilder('\OC\User\Manager') |
|
|
|
|
->disableOriginalConstructor() |
|
|
|
|
->getMock(); |
|
|
|
|
$this->tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider'); |
|
|
|
|
$this->tokenProvider = $this->getMockBuilder('\OC\Authentication\Token\IProvider') |
|
|
|
|
->getMock(); |
|
|
|
|
$this->twoFactorAuthManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager') |
|
|
|
|
->disableOriginalConstructor() |
|
|
|
|
->getMock(); |
|
|
|
|
$this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom'); |
|
|
|
|
$this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom') |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider, $this->twoFactorAuthManager, $this->secureRandom); |
|
|
|
|
} |
|
|
|
|
@ -77,7 +79,7 @@ class TokenControllerTest extends TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testWithValidCredentials() { |
|
|
|
|
$user = $this->getMock('\OCP\IUser'); |
|
|
|
|
$user = $this->getMockBuilder('\OCP\IUser')->getMock(); |
|
|
|
|
$this->userManager->expects($this->once()) |
|
|
|
|
->method('checkPassword') |
|
|
|
|
->with('john', '123456') |
|
|
|
|
@ -96,9 +98,9 @@ class TokenControllerTest extends TestCase { |
|
|
|
|
$this->tokenProvider->expects($this->once()) |
|
|
|
|
->method('generateToken') |
|
|
|
|
->with('verysecurerandomtoken', 'john', 'john', '123456', 'unknown client', IToken::PERMANENT_TOKEN); |
|
|
|
|
$expected = [ |
|
|
|
|
$expected = new JSONResponse([ |
|
|
|
|
'token' => 'verysecurerandomtoken' |
|
|
|
|
]; |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$actual = $this->tokenController->generateToken('john', '123456'); |
|
|
|
|
|
|
|
|
|
@ -106,7 +108,7 @@ class TokenControllerTest extends TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testWithValidCredentialsBut2faEnabled() { |
|
|
|
|
$user = $this->getMock('\OCP\IUser'); |
|
|
|
|
$user = $this->getMockBuilder('\OCP\IUser')->getMock(); |
|
|
|
|
$this->userManager->expects($this->once()) |
|
|
|
|
->method('checkPassword') |
|
|
|
|
->with('john', '123456') |
|
|
|
|
|