OIDCUtil { public String fetchMountAccessorForOidc(String token) { Response response = reqProcessor.process("/sys/list", "{}", 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") .getAsJsonObject(TVaultConstants.OIDC + "/"); metaDataParams = new Gson().fromJson(object.toString(), Map.class); String accessor = ""; for (Map.Entry m : metaDataParams.entrySet()) { if (m.getKey().equals(TVaultConstants.ALIAS_MOUNT_ACCESSOR)) { accessor = m.getValue().toString(); break; } } return accessor; } } 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; }
@Test public void test_fetchMountAccessorForOidc() { String token = "7QPMPIGiyDFlJkrK3jFykUqa"; String dataOutput = "{\"data\":{\"oidc/\":{\"accessor\":\"auth_oidc_8b51f292\",\"config\":{\"default_lease_ttl\":0,\"force_no_cache\":false,\"max_lease_ttl\":0,\"token_type\":\"default-service\"},\"description\":\"\",\"external_entropy_access\":false,\"local\":false,\"options\":null,\"seal_wrap\":false,\"type\":\"oidc\",\"uuid\":\"fbd45cc4-d6b6-8b49-6d1a-d4d931345df9\"}}}"; Response responsemock = getMockResponse(HttpStatus.OK, true, dataOutput); when(reqProcessor.process(eq("/sys/list"),Mockito.any(),eq(token))).thenReturn(responsemock); String mountAccessor = oidcUtil.fetchMountAccessorForOidc(token); assertEquals("auth_oidc_8b51f292", mountAccessor); }