@Test public void updateIdentityGroupByNameSuccess(){ String token = "Adadsadasdasd"; String responseJson = "{\"data\":{\"id\": \"canonicalID\"}}"; Response responsemock = getMockResponse(HttpStatus.OK, true, "canonicalID"); OIDCIdentityGroupRequest oidcIdentityGroupRequest = new OIDCIdentityGroupRequest(); oidcIdentityGroupRequest.setName("name"); List<String> policies = new ArrayList<>(); policies.add("safeadmin"); oidcIdentityGroupRequest.setPolicies(policies); Response rsResponse = getMockResponse(HttpStatus.OK, true, responseJson); String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); when(reqProcessor.process("/identity/group/name/update", jsonStr, token)).thenReturn(rsResponse); String canonicalId = oidcUtil.updateIdentityGroupByName(token, oidcIdentityGroupRequest); assertEquals(responsemock.getResponse(), canonicalId); }
public String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest) { String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); Response response = reqProcessor.process("/identity/group/name/update", jsonStr, token); if (HttpStatus.OK.equals(response.getHttpstatus())) { Map<String, String> metaDataParams = null; JsonParser jsonParser = new JsonParser(); JsonObject data = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); if (data != null) { JsonObject object = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String canonicalId = ""; for (Map.Entry m : metaDataParams.entrySet()) { if ("id".equals(m.getKey())) { canonicalId = m.getValue().toString(); break; } } return canonicalId; } } return null; }
OIDCUtil { public String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest) { String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); Response response = reqProcessor.process("/identity/group/name/update", jsonStr, token); if (HttpStatus.OK.equals(response.getHttpstatus())) { Map<String, String> metaDataParams = null; JsonParser jsonParser = new JsonParser(); JsonObject data = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); if (data != null) { JsonObject object = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String canonicalId = ""; for (Map.Entry m : metaDataParams.entrySet()) { if ("id".equals(m.getKey())) { canonicalId = m.getValue().toString(); break; } } return canonicalId; } } return null; } }
OIDCUtil { public String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest) { String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); Response response = reqProcessor.process("/identity/group/name/update", jsonStr, token); if (HttpStatus.OK.equals(response.getHttpstatus())) { Map<String, String> metaDataParams = null; JsonParser jsonParser = new JsonParser(); JsonObject data = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); if (data != null) { JsonObject object = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String canonicalId = ""; for (Map.Entry m : metaDataParams.entrySet()) { if ("id".equals(m.getKey())) { canonicalId = m.getValue().toString(); break; } } return canonicalId; } } return null; } OIDCUtil(); }
OIDCUtil { public String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest) { String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); Response response = reqProcessor.process("/identity/group/name/update", jsonStr, token); if (HttpStatus.OK.equals(response.getHttpstatus())) { Map<String, String> metaDataParams = null; JsonParser jsonParser = new JsonParser(); JsonObject data = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); if (data != null) { JsonObject object = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String canonicalId = ""; for (Map.Entry m : metaDataParams.entrySet()) { if ("id".equals(m.getKey())) { canonicalId = m.getValue().toString(); break; } } return canonicalId; } } 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 String updateIdentityGroupByName(String token, OIDCIdentityGroupRequest oidcIdentityGroupRequest) { String jsonStr = JSONUtil.getJSON(oidcIdentityGroupRequest); Response response = reqProcessor.process("/identity/group/name/update", jsonStr, token); if (HttpStatus.OK.equals(response.getHttpstatus())) { Map<String, String> metaDataParams = null; JsonParser jsonParser = new JsonParser(); JsonObject data = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); if (data != null) { JsonObject object = ((JsonObject) jsonParser.parse(response.getResponse())).getAsJsonObject("data"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String canonicalId = ""; for (Map.Entry m : metaDataParams.entrySet()) { if ("id".equals(m.getKey())) { canonicalId = m.getValue().toString(); break; } } return canonicalId; } } 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; }