示例#1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Could not load two-factor auth provider \OCA\MyFaulty2faApp\DoesNotExist
  */
 public function testFailHardIfProviderCanNotBeLoaded()
 {
     $this->appManager->expects($this->once())->method('getEnabledAppsForUser')->with($this->user)->will($this->returnValue(['faulty2faapp']));
     $this->manager->expects($this->once())->method('loadTwoFactorApp')->with('faulty2faapp');
     $this->appManager->expects($this->once())->method('getAppInfo')->with('faulty2faapp')->will($this->returnValue(['two-factor-providers' => ['\\OCA\\MyFaulty2faApp\\DoesNotExist']]));
     $this->manager->getProviders($this->user);
 }
示例#2
0
 /**
  * @expectedException \Sabre\DAV\Exception\NotAuthenticated
  * @expectedExceptionMessage 2FA challenge not passed.
  */
 public function testAuthenticateAlreadyLoggedInWithoutTwoFactorChallengePassed()
 {
     $request = $this->getMockBuilder('Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
     $this->request->expects($this->any())->method('getMethod')->willReturn('PROPFIND');
     $this->request->expects($this->any())->method('isUserAgent')->with(['/^Mozilla\\/5\\.0 \\([A-Za-z ]+\\) (mirall|csyncoC)\\/.*$/', '/^Mozilla\\/5\\.0 \\(Android\\) ownCloud\\-android.*$/', '/^Mozilla\\/5\\.0 \\(iOS\\) ownCloud\\-iOS.*$/'])->willReturn(false);
     $this->session->expects($this->any())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue('LoggedInUser'));
     $user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
     $user->expects($this->any())->method('getUID')->will($this->returnValue('LoggedInUser'));
     $this->userSession->expects($this->any())->method('getUser')->will($this->returnValue($user));
     $this->request->expects($this->once())->method('passesCSRFCheck')->willReturn(true);
     $this->twoFactorManager->expects($this->once())->method('needsSecondFactor')->will($this->returnValue(true));
     $this->auth->check($request, $response);
 }