TotpMfaEndpoint implements ApplicationEventPublisherAware { @RequestMapping(value = {"/verify"}, method = RequestMethod.GET) public ModelAndView totpAuthorize(Model model) throws UaaPrincipalIsNotInSession { UaaPrincipal uaaPrincipal = getSessionAuthPrincipal(); return renderEnterCodePage(model, uaaPrincipal); } TotpMfaEndpoint(
            final UserGoogleMfaCredentialsProvisioning mfaCredentialsProvisioning,
            final MfaProviderProvisioning mfaProviderProvisioning,
            final @Qualifier("mfaCompleteUrl") String mfaCompleteUrl,
            final UaaUserDatabase userDatabase,
            final @Qualifier("mfaGlobalUserLoginPolicy") CommonLoginPolicy mfaPolicy); @ModelAttribute("uaaMfaCredentials") UserGoogleMfaCredentials getUaaMfaCredentials(); @RequestMapping(value = {"/register"}, method = RequestMethod.GET) String generateQrUrl(Model model,
                                @ModelAttribute("uaaMfaCredentials") UserGoogleMfaCredentials credentials); @RequestMapping(value = {"/manual"}, method = RequestMethod.GET) String manualRegistration(
      Model model,
      @ModelAttribute("uaaMfaCredentials") UserGoogleMfaCredentials credentials
    ); @RequestMapping(value = {"/verify"}, method = RequestMethod.GET) ModelAndView totpAuthorize(Model model); @RequestMapping(value = {"/verify.do"}, method = RequestMethod.POST) ModelAndView validateCode(Model model,
                                     @RequestParam("code") String code,
                                     @ModelAttribute("uaaMfaCredentials") UserGoogleMfaCredentials credentials,
                                     HttpServletRequest request,
                                     SessionStatus sessionStatus); @ExceptionHandler(UaaPrincipalIsNotInSession.class) ModelAndView handleUaaPrincipalIsNotInSession(); @ExceptionHandler(AuthenticationPolicyRejectionException.class) ModelAndView handleMFALockedOut(); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher);  }
@Test(expected = TotpMfaEndpoint.UaaPrincipalIsNotInSession.class) public void testTotpAuthorizePageNoAuthentication() throws Exception{ when(uaaAuthentication.getPrincipal()).thenReturn(null); endpoint.totpAuthorize(mock(Model.class)); }
@Test public void testTotpAuthorizePage() throws Exception{ when(uaaAuthentication.getPrincipal()).thenReturn(new UaaPrincipal(userId, "Marissa", null, null, null, null), null, null); ModelAndView returnView = endpoint.totpAuthorize(mock(Model.class)); assertEquals("mfa/enter_code", returnView.getViewName()); }