public function testValidateSessionNoPassword() { $userManager = $this->getMock('\\OCP\\IUserManager'); $session = $this->getMock('\\OCP\\ISession'); $timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory'); $tokenProvider = $this->getMock('\\OC\\Authentication\\Token\\IProvider'); $userSession = $this->getMockBuilder('\\OC\\User\\Session')->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config])->setMethods(['logout'])->getMock(); $user = $this->getMock('\\OCP\\IUser'); $token = new \OC\Authentication\Token\DefaultToken(); $token->setLastCheck(20); $session->expects($this->once())->method('get')->with('app_password')->will($this->returnValue('APP-PASSWORD')); $tokenProvider->expects($this->once())->method('getToken')->with('APP-PASSWORD')->will($this->returnValue($token)); $timeFactory->expects($this->once())->method('getTime')->will($this->returnValue(1000)); // more than 5min since last check $tokenProvider->expects($this->once())->method('getPassword')->with($token, 'APP-PASSWORD')->will($this->throwException(new \OC\Authentication\Exceptions\PasswordlessTokenException())); $tokenProvider->expects($this->once())->method('updateToken')->with($token); $this->invokePrivate($userSession, 'validateSession', [$user]); $this->assertEquals(1000, $token->getLastCheck()); }