@Test public void shouldInitiateAuthenticationViaGET() throws AuthLoginException, L10NMessageImpl, JSONException, IOException { HttpHeaders headers = mock(HttpHeaders.class); HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse httpResponse = mock(HttpServletResponse.class); String authIndexType = null; String indexValue = null; String sessionUpgradeSSOTokenId = null; SSOTokenID ssoTokenID = mock(SSOTokenID.class); given(ssoTokenID.toString()).willReturn("SSO_TOKEN_ID"); SSOToken ssoToken = mock(SSOToken.class); given(ssoToken.getTokenID()).willReturn(ssoTokenID); AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class); given(authContextLocalWrapper.getSSOToken()).willReturn(ssoToken); LoginProcess loginProcess = mock(LoginProcess.class); given(loginProcess.getLoginStage()).willReturn(LoginStage.COMPLETE); given(loginProcess.isSuccessful()).willReturn(true); given(loginProcess.getAuthContext()).willReturn(authContextLocalWrapper); given(loginAuthenticator.getLoginProcess(Matchers.<LoginConfiguration>anyObject())).willReturn(loginProcess); Response response = restAuthenticationHandler.initiateAuthentication(headers, request, httpResponse, authIndexType, indexValue, sessionUpgradeSSOTokenId); assertEquals(response.getStatus(), 200); ObjectMapper objectMapper = new ObjectMapper(); JsonValue jsonValue = new JsonValue(objectMapper.readValue((String) response.getEntity(), Map.class)); assertEquals(jsonValue.size(), 2); assertEquals(jsonValue.get("tokenId").asString(), "SSO_TOKEN_ID"); assertTrue(jsonValue.isDefined("successUrl")); ArgumentCaptor<LoginConfiguration> argumentCaptor = ArgumentCaptor.forClass(LoginConfiguration.class); verify(loginAuthenticator).getLoginProcess(argumentCaptor.capture()); LoginConfiguration loginConfiguration = argumentCaptor.getValue(); assertEquals(loginConfiguration.getHttpRequest(), request); assertEquals(loginConfiguration.getIndexType(), AuthIndexType.NONE); assertEquals(loginConfiguration.getIndexValue(), null); assertEquals(loginConfiguration.getSessionId(), ""); assertEquals(loginConfiguration.getSSOTokenId(), ""); }
public Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) { return authenticate(headers, request, response, null, authIndexType, indexValue, sessionUpgradeSSOTokenId); }
RestAuthenticationHandler { public Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) { return authenticate(headers, request, response, null, authIndexType, indexValue, sessionUpgradeSSOTokenId); } }
RestAuthenticationHandler { public Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) { return authenticate(headers, request, response, null, authIndexType, indexValue, sessionUpgradeSSOTokenId); } @Inject  RestAuthenticationHandler(LoginAuthenticator loginAuthenticator,
            RestAuthCallbackHandlerManager restAuthCallbackHandlerManager,
            AMAuthErrorCodeResponseStatusMapping amAuthErrorCodeResponseStatusMapping, AuthIdHelper authIdHelper); }
RestAuthenticationHandler { public Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) { return authenticate(headers, request, response, null, authIndexType, indexValue, sessionUpgradeSSOTokenId); } @Inject  RestAuthenticationHandler(LoginAuthenticator loginAuthenticator,
            RestAuthCallbackHandlerManager restAuthCallbackHandlerManager,
            AMAuthErrorCodeResponseStatusMapping amAuthErrorCodeResponseStatusMapping, AuthIdHelper authIdHelper); Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId); Response continueAuthentication(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, JsonValue postBody, String sessionUpgradeSSOTokenId); }
RestAuthenticationHandler { public Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) { return authenticate(headers, request, response, null, authIndexType, indexValue, sessionUpgradeSSOTokenId); } @Inject  RestAuthenticationHandler(LoginAuthenticator loginAuthenticator,
            RestAuthCallbackHandlerManager restAuthCallbackHandlerManager,
            AMAuthErrorCodeResponseStatusMapping amAuthErrorCodeResponseStatusMapping, AuthIdHelper authIdHelper); Response initiateAuthentication(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId); Response continueAuthentication(HttpHeaders headers, HttpServletRequest request,
            HttpServletResponse response, JsonValue postBody, String sessionUpgradeSSOTokenId);  }