OIDCAuthService { public ResponseEntity<String> getIdentityGroupDetails(String groupName, String token) { OIDCGroup oidcGroup = oidcUtil.getIdentityGroupDetails(groupName, token); if (oidcGroup != null) { return ResponseEntity.status(HttpStatus.OK).body(JSONUtil.getJSON(oidcGroup)); } else { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"errors\":[\"Group not found\"]}"); } }  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);  }
@Test public void test_getIdentityGroupDetails_success() throws Exception { String group = "group1"; String token = "test4ig8L3EpsJZSLAMg"; List<String> policies = new ArrayList<>(); policies.add("r_users_safe1"); policies.add("r_users_safe2"); OIDCGroup oidcGroup = new OIDCGroup("123-123-123", policies); when(OIDCUtil.getIdentityGroupDetails(group, token)).thenReturn(oidcGroup); ResponseEntity<String> expectedResponseEntity = ResponseEntity.status(HttpStatus.OK).body(JSONUtil.getJSON(oidcGroup)); ResponseEntity<String> actualResponse = oidcAuthService.getIdentityGroupDetails(group, token); assertEquals(expectedResponseEntity.getStatusCode(), actualResponse.getStatusCode()); assertEquals(expectedResponseEntity.getBody(), actualResponse.getBody()); }
@Test public void test_getIdentityGroupDetails_failed() throws Exception { String group = "group1"; String token = "test4ig8L3EpsJZSLAMg"; when(OIDCUtil.getIdentityGroupDetails(group, token)).thenReturn(null); ResponseEntity<String> expectedResponseEntity = ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"errors\":[\"Group not found\"]}"); ResponseEntity<String> actualResponse = oidcAuthService.getIdentityGroupDetails(group, token); assertEquals(expectedResponseEntity.getStatusCode(), actualResponse.getStatusCode()); assertEquals(expectedResponseEntity.getBody(), actualResponse.getBody()); }