@Test public void test_getIdentityGroupDetails_failed() { String group = "group1"; String token = "test4ig8L3EpsJZSLAMg"; Response responsemock = getMockResponse(HttpStatus.NOT_FOUND, true, ""); when(reqProcessor.process("/identity/group/name", "{\"group\":\""+group+"\"}", token)).thenReturn(responsemock); OIDCGroup oidcGroup = oidcUtil.getIdentityGroupDetails(group, token); assertEquals(null, oidcGroup); }
public OIDCGroup getIdentityGroupDetails(String groupName, String token) { Response response = reqProcessor.process("/identity/group/name", "{\"group\":\""+groupName+"\"}", token); if(HttpStatus.OK.equals(response.getHttpstatus())) { String responseJson = response.getResponse(); ObjectMapper objMapper = new ObjectMapper(); List<String> policies = new ArrayList<>(); try { OIDCGroup oidcGroup = new OIDCGroup(); oidcGroup.setId(objMapper.readTree(responseJson).get("id").asText()); JsonNode policiesArry = objMapper.readTree(responseJson).get("policies"); for (JsonNode policyNode : policiesArry) { policies.add(policyNode.asText()); } oidcGroup.setPolicies(policies); return oidcGroup; }catch (IOException e) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getIdentityGroupDetails"). put(LogMessage.MESSAGE, String.format ("Failed to get identity group details for [%s]", groupName)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); } } return null; }
OIDCUtil { public OIDCGroup getIdentityGroupDetails(String groupName, String token) { Response response = reqProcessor.process("/identity/group/name", "{\"group\":\""+groupName+"\"}", token); if(HttpStatus.OK.equals(response.getHttpstatus())) { String responseJson = response.getResponse(); ObjectMapper objMapper = new ObjectMapper(); List<String> policies = new ArrayList<>(); try { OIDCGroup oidcGroup = new OIDCGroup(); oidcGroup.setId(objMapper.readTree(responseJson).get("id").asText()); JsonNode policiesArry = objMapper.readTree(responseJson).get("policies"); for (JsonNode policyNode : policiesArry) { policies.add(policyNode.asText()); } oidcGroup.setPolicies(policies); return oidcGroup; }catch (IOException e) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getIdentityGroupDetails"). put(LogMessage.MESSAGE, String.format ("Failed to get identity group details for [%s]", groupName)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); } } return null; } }
OIDCUtil { public OIDCGroup getIdentityGroupDetails(String groupName, String token) { Response response = reqProcessor.process("/identity/group/name", "{\"group\":\""+groupName+"\"}", token); if(HttpStatus.OK.equals(response.getHttpstatus())) { String responseJson = response.getResponse(); ObjectMapper objMapper = new ObjectMapper(); List<String> policies = new ArrayList<>(); try { OIDCGroup oidcGroup = new OIDCGroup(); oidcGroup.setId(objMapper.readTree(responseJson).get("id").asText()); JsonNode policiesArry = objMapper.readTree(responseJson).get("policies"); for (JsonNode policyNode : policiesArry) { policies.add(policyNode.asText()); } oidcGroup.setPolicies(policies); return oidcGroup; }catch (IOException e) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getIdentityGroupDetails"). put(LogMessage.MESSAGE, String.format ("Failed to get identity group details for [%s]", groupName)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); } } return null; } OIDCUtil(); }
OIDCUtil { public OIDCGroup getIdentityGroupDetails(String groupName, String token) { Response response = reqProcessor.process("/identity/group/name", "{\"group\":\""+groupName+"\"}", token); if(HttpStatus.OK.equals(response.getHttpstatus())) { String responseJson = response.getResponse(); ObjectMapper objMapper = new ObjectMapper(); List<String> policies = new ArrayList<>(); try { OIDCGroup oidcGroup = new OIDCGroup(); oidcGroup.setId(objMapper.readTree(responseJson).get("id").asText()); JsonNode policiesArry = objMapper.readTree(responseJson).get("policies"); for (JsonNode policyNode : policiesArry) { policies.add(policyNode.asText()); } oidcGroup.setPolicies(policies); return oidcGroup; }catch (IOException e) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getIdentityGroupDetails"). put(LogMessage.MESSAGE, String.format ("Failed to get identity group details for [%s]", groupName)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); } } return null; } OIDCUtil(); String fetchMountAccessorForOidc(String token); OIDCEntityResponse getEntityLookUpResponse(String authMountResponse); Response updateGroupPolicies(String token, String groupName, List<String> policies,
			List<String> currentPolicies, String id); Response deleteGroupByName(String token, String name); OIDCGroup getIdentityGroupDetails(String groupName, String token); String getSSOToken(); String getGroupObjectResponse(String ssoToken, String groupName); String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest); Response createGroupAlias(String token, GroupAliasRequest groupAliasRequest); ResponseEntity<OIDCEntityResponse> oidcFetchEntityDetails(String token, String username, UserDetails userDetails); ResponseEntity<OIDCEntityResponse> entityLookUp(String token,
			OIDCLookupEntityRequest oidcLookupEntityRequest); Response deleteGroupAliasByID(String token, String id); Response updateOIDCEntity(List<String> policies, String entityName); Response updateEntityByName(String token, OIDCEntityRequest oidcEntityRequest); void renewUserToken(String token); List<String> getPoliciedFromTokenLookUp(String authMountResponse); List<String> tokenLookUp(String token); Response createEntityAlias(String token, OidcEntityAliasRequest oidcEntityAliasRequest); String getUserName(String email); List<DirectoryGroup> getGroupsFromAAD(String ssoToken, String groupName); String getIdOfTheUser(String accessToken, String userEmail); List<String> getSelfServiceGroupsFromAADById(String accessToken, String userAADId, String userName); }
OIDCUtil { public OIDCGroup getIdentityGroupDetails(String groupName, String token) { Response response = reqProcessor.process("/identity/group/name", "{\"group\":\""+groupName+"\"}", token); if(HttpStatus.OK.equals(response.getHttpstatus())) { String responseJson = response.getResponse(); ObjectMapper objMapper = new ObjectMapper(); List<String> policies = new ArrayList<>(); try { OIDCGroup oidcGroup = new OIDCGroup(); oidcGroup.setId(objMapper.readTree(responseJson).get("id").asText()); JsonNode policiesArry = objMapper.readTree(responseJson).get("policies"); for (JsonNode policyNode : policiesArry) { policies.add(policyNode.asText()); } oidcGroup.setPolicies(policies); return oidcGroup; }catch (IOException e) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getIdentityGroupDetails"). put(LogMessage.MESSAGE, String.format ("Failed to get identity group details for [%s]", groupName)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); } } return null; } OIDCUtil(); String fetchMountAccessorForOidc(String token); OIDCEntityResponse getEntityLookUpResponse(String authMountResponse); Response updateGroupPolicies(String token, String groupName, List<String> policies,
			List<String> currentPolicies, String id); Response deleteGroupByName(String token, String name); OIDCGroup getIdentityGroupDetails(String groupName, String token); String getSSOToken(); String getGroupObjectResponse(String ssoToken, String groupName); String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest); Response createGroupAlias(String token, GroupAliasRequest groupAliasRequest); ResponseEntity<OIDCEntityResponse> oidcFetchEntityDetails(String token, String username, UserDetails userDetails); ResponseEntity<OIDCEntityResponse> entityLookUp(String token,
			OIDCLookupEntityRequest oidcLookupEntityRequest); Response deleteGroupAliasByID(String token, String id); Response updateOIDCEntity(List<String> policies, String entityName); Response updateEntityByName(String token, OIDCEntityRequest oidcEntityRequest); void renewUserToken(String token); List<String> getPoliciedFromTokenLookUp(String authMountResponse); List<String> tokenLookUp(String token); Response createEntityAlias(String token, OidcEntityAliasRequest oidcEntityAliasRequest); String getUserName(String email); List<DirectoryGroup> getGroupsFromAAD(String ssoToken, String groupName); String getIdOfTheUser(String accessToken, String userEmail); List<String> getSelfServiceGroupsFromAADById(String accessToken, String userAADId, String userName); static final Logger log; }