@Test
public void test_addUserToServiceAccount_oidc_success() {

erDetails userDetails = getMockUser(true);
	String token = userDetails.getClientToken();
	ServiceAccountUser serviceAccountUser = new ServiceAccountUser("testacc02", "testacc01", "read");
    Response userResponse = getMockResponse(HttpStatus.OK, true, "{\"data\":{\"bound_cidrs\":[],\"max_ttl\":0,\"policies\":[\"default\"],\"ttl\":0,\"groups\":\"admin\"}}");
    Response responseNoContent = getMockResponse(HttpStatus.NO_CONTENT, true, "{\"policies\":null}");
    when(reqProcessor.process("/auth/ldap/users","{\"username\":\"testacc01\"}",token)).thenReturn(userResponse);
    try {
        List<String> resList = new ArrayList<>();
        resList.add("default");
        when(ControllerUtil.getPoliciesAsListFromJson(any(), any())).thenReturn(resList);
    } catch (IOException e) {
        e.printStackTrace();
    }
    when(ControllerUtil.configureLDAPUser(eq("testacc01"),any(),any(),eq(token))).thenReturn(responseNoContent);
    when(ControllerUtil.updateMetadata(any(),any())).thenReturn(responseNoContent);
    // System under test
	String expectedResponse = "{\"messages\":[\"Successfully added user to the Service Account\"]}";
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(expectedResponse);
    when(reqProcessor.process(eq("/sdb"),Mockito.any(),eq(token))).thenReturn(getMockResponse(HttpStatus.OK, true, "{\"data\":{\"initialPasswordReset\":true,\"managedBy\":\"smohan11\",\"name\":\"svc_vault_test5\",\"users\":{\"smohan11\":\"sudo\"}}}"));
    String[] latestPolicies = {"o_svcacct_testacc02"};
    when(policyUtils.getCurrentPolicies(userDetails.getSelfSupportToken(), userDetails.getUsername(), userDetails)).thenReturn(latestPolicies);
    
  //oidc test cases
    ReflectionTestUtils.setField(serviceAccountsService, "vaultAuthMethod", "oidc");
    String mountAccessor = "auth_oidc";
    DirectoryUser directoryUser = new DirectoryUser();
    directoryUser.setDisplayName("testUser");
    directoryUser.setGivenName("testUser");
    directoryUser.setUserEmail("testUser@t-mobile.com");
    directoryUser.setUserId("testuser01");
    directoryUser.setUserName("testUser");
    List<DirectoryUser> persons = new ArrayList<>();
    persons.add(directoryUser);
    
    DirectoryObjects users = new DirectoryObjects();
    DirectoryObjectsList usersList = new DirectoryObjectsList();
    usersList.setValues(persons.toArray(new DirectoryUser[persons.size()]));
    users.setData(usersList);
    
		OIDCLookupEntityRequest oidcLookupEntityRequest = new OIDCLookupEntityRequest();
		oidcLookupEntityRequest.setId(null);
		oidcLookupEntityRequest.setAlias_id(null);
		oidcLookupEntityRequest.setName(null);
		oidcLookupEntityRequest.setAlias_name(directoryUser.getUserEmail());
		oidcLookupEntityRequest.setAlias_mount_accessor(mountAccessor);
		OIDCEntityResponse oidcEntityResponse = new OIDCEntityResponse();
		oidcEntityResponse.setEntityName("entity");
		List<String> policies = new ArrayList<>();
		policies.add("safeadmin");
		oidcEntityResponse.setPolicies(policies);
		ResponseEntity<DirectoryObjects> responseEntity1 = ResponseEntity.status(HttpStatus.OK).body(users);
		when(OIDCUtil.fetchMountAccessorForOidc(token)).thenReturn(mountAccessor);
		ResponseEntity<OIDCEntityResponse> responseEntity2 = ResponseEntity.status(HttpStatus.OK)
				.body(oidcEntityResponse);
		when(tokenUtils.getSelfServiceTokenWithAppRole()).thenReturn(token);
		String entityName = "entity";
		
		Response responseEntity3 = getMockResponse(HttpStatus.NO_CONTENT, true, "{\"data\": [\"safeadmin\",\"vaultadmin\"]]");
		when(OIDCUtil.updateOIDCEntity(any(), any()))
				.thenReturn(responseEntity3);
             when(OIDCUtil.oidcFetchEntityDetails(any(), any(), any())).thenReturn(responseEntity2);
    
    ResponseEntity<String> responseEntity = serviceAccountsService.addUserToServiceAccount(token, serviceAccountUser, userDetails, false);
    assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
    assertEquals(responseEntityExpected, responseEntity);
}