@Test public void test_getAuthUrl_failed() { OidcRequest oidcRequest = new OidcRequest("default", "http: String jsonStr = "{ \"role\": \"default\", \"redirect_uri\": \"http: String responseJson = "{\"errors\":[\"Failed to get OIDC auth url\"]}"; Response response = getMockResponse(HttpStatus.BAD_REQUEST, true, responseJson); when(JSONUtil.getJSON(any(OidcRequest.class))).thenReturn(jsonStr); when(reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr,"")).thenReturn(response); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(responseJson); ResponseEntity<String> responseEntity = oidcAuthService.getAuthUrl(oidcRequest); assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
public ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest) { String jsonStr = JSONUtil.getJSON(oidcRequest); Response response = reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr, ""); if(HttpStatus.OK.equals(response.getHttpstatus())){ log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, "Successfully retrieved OIDC auth url"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, String.format ("Failed to get OIDC auth url [%s]", response.getResponse())). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Failed to get OIDC auth url\"]}"); } }
OIDCAuthService { public ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest) { String jsonStr = JSONUtil.getJSON(oidcRequest); Response response = reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr, ""); if(HttpStatus.OK.equals(response.getHttpstatus())){ log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, "Successfully retrieved OIDC auth url"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, String.format ("Failed to get OIDC auth url [%s]", response.getResponse())). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Failed to get OIDC auth url\"]}"); } } }
OIDCAuthService { public ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest) { String jsonStr = JSONUtil.getJSON(oidcRequest); Response response = reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr, ""); if(HttpStatus.OK.equals(response.getHttpstatus())){ log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, "Successfully retrieved OIDC auth url"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, String.format ("Failed to get OIDC auth url [%s]", response.getResponse())). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Failed to get OIDC auth url\"]}"); } }  }
OIDCAuthService { public ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest) { String jsonStr = JSONUtil.getJSON(oidcRequest); Response response = reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr, ""); if(HttpStatus.OK.equals(response.getHttpstatus())){ log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, "Successfully retrieved OIDC auth url"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, String.format ("Failed to get OIDC auth url [%s]", response.getResponse())). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Failed to get OIDC auth url\"]}"); } }  ResponseEntity<String> getAuthenticationMounts(String token); ResponseEntity<OIDCEntityResponse> entityLookUp(String token,
			OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> groupEntityLookUp(String token, OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> readEntityAliasById(String token, String id); ResponseEntity<String> readEntityByName(String token, String entityName); ResponseEntity<String> updateEntityByName(String token, OIDCEntityRequest oidcEntityRequest); ResponseEntity<String> updateIdentityGroupByName(String token,
                                                            OIDCIdentityGroupRequest oidcIdentityGroupRequest); ResponseEntity<String> readGroupAliasById(String token, String id); ResponseEntity<String> deleteGroupByName(String token, String name); ResponseEntity<String> deleteGroupAliasByID(String token, String id); ResponseEntity<String> createGroupAlias(String token, GroupAliasRequest groupAliasRequest); ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest); ResponseEntity<String> processOIDCCallback(String state, String code); ResponseEntity<String> getGroupObjectIdFromAzure(String groupName); ResponseEntity<String> getIdentityGroupDetails(String groupName, String token); ResponseEntity<String> getUserName(UserDetails userDetails); ResponseEntity<DirectoryObjects> searchGroupInAzureAD(String groupName); }
OIDCAuthService { public ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest) { String jsonStr = JSONUtil.getJSON(oidcRequest); Response response = reqProcessor.process("/auth/oidc/oidc/auth_url",jsonStr, ""); if(HttpStatus.OK.equals(response.getHttpstatus())){ log.info(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, "Successfully retrieved OIDC auth url"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }else{ log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getAuthUrl"). put(LogMessage.MESSAGE, String.format ("Failed to get OIDC auth url [%s]", response.getResponse())). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"errors\":[\"Failed to get OIDC auth url\"]}"); } }  ResponseEntity<String> getAuthenticationMounts(String token); ResponseEntity<OIDCEntityResponse> entityLookUp(String token,
			OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> groupEntityLookUp(String token, OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> readEntityAliasById(String token, String id); ResponseEntity<String> readEntityByName(String token, String entityName); ResponseEntity<String> updateEntityByName(String token, OIDCEntityRequest oidcEntityRequest); ResponseEntity<String> updateIdentityGroupByName(String token,
                                                            OIDCIdentityGroupRequest oidcIdentityGroupRequest); ResponseEntity<String> readGroupAliasById(String token, String id); ResponseEntity<String> deleteGroupByName(String token, String name); ResponseEntity<String> deleteGroupAliasByID(String token, String id); ResponseEntity<String> createGroupAlias(String token, GroupAliasRequest groupAliasRequest); ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest); ResponseEntity<String> processOIDCCallback(String state, String code); ResponseEntity<String> getGroupObjectIdFromAzure(String groupName); ResponseEntity<String> getIdentityGroupDetails(String groupName, String token); ResponseEntity<String> getUserName(UserDetails userDetails); ResponseEntity<DirectoryObjects> searchGroupInAzureAD(String groupName);  }