public function testShowLoginFormForUserNamedNull() { $this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(false); $this->config->expects($this->once())->method('getSystemValue')->with('lost_password_link')->willReturn(false); $user = $this->getMock('\\OCP\\IUser'); $user->expects($this->once())->method('canChangePassword')->willReturn(false); $this->userManager->expects($this->once())->method('get')->with('0')->willReturn($user); $expectedResponse = new TemplateResponse('core', 'login', ['messages' => [], 'loginName' => '0', 'user_autofocus' => false, 'canResetPassword' => false, 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0], 'guest'); $this->assertEquals($expectedResponse, $this->loginController->showLoginForm('0', '', '')); }
public function testToNotLeakLoginName() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ $user = $this->getMock('\\OCP\\IUser'); $user->expects($this->any())->method('getUID')->will($this->returnValue('john')); $this->userManager->expects($this->exactly(2))->method('checkPassword')->withConsecutive(['*****@*****.**', 'just wrong'], ['john', 'just wrong'])->willReturn(false); $this->userManager->expects($this->once())->method('getByEmail')->with('*****@*****.**')->willReturn([$user]); $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('core.login.showLoginForm', ['user' => '*****@*****.**'])->will($this->returnValue('')); $expected = new RedirectResponse(''); $this->assertEquals($expected, $this->loginController->tryLogin('*****@*****.**', 'just wrong', null)); }