Commit a4a209ea authored by Jason's avatar Jason
Browse files

Merge branch 'delete_member_api' into 'master'

Add delete member API

See merge request !29
parents 5b2c3adc 50074d32
Pipeline #28484 passed with stages
in 14 minutes and 52 seconds
package org.opengroup.osdu.entitlements.v2.api;
import lombok.RequiredArgsConstructor;
import org.opengroup.osdu.core.common.model.http.RequestInfo;
import org.opengroup.osdu.entitlements.v2.model.deletemember.DeleteMemberDto;
import org.opengroup.osdu.entitlements.v2.service.DeleteMemberService;
import org.opengroup.osdu.entitlements.v2.util.RequestInfoUtilService;
import org.opengroup.osdu.entitlements.v2.validation.PartitionHeaderValidationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
public class DeleteMemberApi {
private final RequestInfo requestInfo;
private final DeleteMemberService deleteMemberService;
private final RequestInfoUtilService requestInfoUtilService;
private final PartitionHeaderValidationService partitionHeaderValidationService;
@DeleteMapping("/members/{member_email}")
@PreAuthorize("@authorizationFilter.hasAnyPermission()")
public ResponseEntity<Void> deleteMember(@PathVariable("member_email") String memberEmail) {
String partitionId = requestInfo.getHeaders().getPartitionId();
partitionHeaderValidationService.validateSinglePartitionProvided(partitionId);
deleteMemberService.deleteMember(buildDeleteMemberDto(memberEmail, partitionId));
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
private DeleteMemberDto buildDeleteMemberDto(String memberEmail, String partitionId) {
return DeleteMemberDto.builder()
.memberEmail(memberEmail.toLowerCase())
.requesterId(requestInfoUtilService.getUserId(requestInfo.getHeaders()))
.partitionId(partitionId)
.build();
}
}
package org.opengroup.osdu.entitlements.v2.model.deletemember;
import lombok.Builder;
import lombok.Data;
import lombok.Generated;
@Data
@Builder
@Generated
public class DeleteMemberDto {
private String memberEmail;
private String requesterId;
private String partitionId;
}
\ No newline at end of file
package org.opengroup.osdu.entitlements.v2.service;
import lombok.RequiredArgsConstructor;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.entitlements.v2.model.ParentReference;
import org.opengroup.osdu.entitlements.v2.model.deletemember.DeleteMemberDto;
import org.opengroup.osdu.entitlements.v2.model.removemember.RemoveMemberServiceDto;
import org.opengroup.osdu.entitlements.v2.spi.retrievegroup.RetrieveGroupRepo;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class DeleteMemberService {
private final JaxRsDpsLog log;
private final RetrieveGroupRepo retrieveGroup;
private final RemoveMemberService removeMemberService;
public void deleteMember(DeleteMemberDto deleteMemberDto) {
log.info(String.format("Remove member %s from all groups", deleteMemberDto.getMemberEmail()));
createRemoveMemberServiceDtos(deleteMemberDto).forEach(this::removeMemberFromGroup);
}
private List<RemoveMemberServiceDto> createRemoveMemberServiceDtos(DeleteMemberDto deleteMemberDto) {
return loadDirectParentsEmails(deleteMemberDto).stream()
.map(groupEmail -> buildRemoveMemberServiceDto(groupEmail, deleteMemberDto))
.collect(Collectors.toList());
}
private RemoveMemberServiceDto buildRemoveMemberServiceDto(String groupEmail, DeleteMemberDto deleteMemberDto) {
return RemoveMemberServiceDto.builder()
.groupEmail(groupEmail)
.memberEmail(deleteMemberDto.getMemberEmail())
.requesterId(deleteMemberDto.getRequesterId())
.partitionId(deleteMemberDto.getPartitionId())
.build();
}
private Set<String> loadDirectParentsEmails(DeleteMemberDto deleteMemberDto) {
List<ParentReference> directParents = retrieveGroup.loadDirectParents(
deleteMemberDto.getPartitionId(), deleteMemberDto.getMemberEmail());
return directParents.stream()
.map(ParentReference::getId)
.collect(Collectors.toSet());
}
private void removeMemberFromGroup(RemoveMemberServiceDto removeMemberServiceDto) {
try {
removeMemberService.removeMember(removeMemberServiceDto);
} catch (AppException e) {
log.warning("Not handling AppException");
throw e;
} catch (Exception e) {
log.error(String.format("Error when removing member: %s from group: %s, reason: %s",
removeMemberServiceDto.getMemberEmail(), removeMemberServiceDto.getGroupEmail(), e.getMessage()));
throw new AppException(
HttpStatus.INTERNAL_SERVER_ERROR.value(),
HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),
"Error while removing member", e);
}
}
}
package org.opengroup.osdu.entitlements.v2.api;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.entitlements.v2.auth.AuthorizationFilter;
import org.opengroup.osdu.entitlements.v2.model.deletemember.DeleteMemberDto;
import org.opengroup.osdu.entitlements.v2.service.DeleteMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@WebMvcTest(DeleteMemberApi.class)
@ComponentScan("org.opengroup.osdu.entitlements.v2")
public class DeleteMemberApiTest {
private static final String TOKEN = "ew0KICAidHlwIjogIkpXVCIsDQogICJhbGciOiAiUlMyNTYiLA0KICAia2lkIjogIk1UVTVNRFUx" +
"TkRrNU9BPT0iDQp9.ew0KICAic3ViIjogImFAYi5jb20iLA0KICAiaXNzIjogInByZXZpZXcuY29tIiwNCiAgImF1ZCI6ICJ0ZXN0LmN" +
"vbSIsDQogICJpYXQiOiAxNTkwNjAwODI0LA0KICAiZXhwIjogMTU5MDY4NzIyNCwNCiAgInByb3ZpZGVyIjogImEuY29tIiwNCiAgImN" +
"saWVudCI6ICJ0ZXN0LmNvbSIsDQogICJ1c2VyaWQiOiAiYUBiLmNvbSIsDQogICJlbWFpbCI6ICJhQGIuY29tIiwNCiAgImF1dGh6Ijo" +
"gIiIsDQogICJsYXN0bmFtZSI6ICJCIiwNCiAgImZpcnN0bmFtZSI6ICJBIiwNCiAgImNvdW50cnkiOiAiIiwNCiAgImNvbXBhbnkiOiA" +
"iIiwNCiAgImpvYnRpdGxlIjogIiIsDQogICJzdWJpZCI6ICJ1NUxTTkp1aFVmYUgweFAzdVlUbkl4Vk9BSjR4NkRKdWNXc3BzNWdEb28" +
"0IiwNCiAgImlkcCI6ICJvMzY1IiwNCiAgImhkIjogInNsYi5jb20iLA0KICAiZGVzaWQiOiAiYUBkZXNpZC5jb20iLA0KICAiY29udGF" +
"jdF9lbWFpbCI6ICJhQGIuY29tIiwNCiAgInJ0X2hhc2giOiAieVMxcHY3a0NvaTZHVld2c3c4S3F5QSINCn0.tvE00W8cZZOZZDc83Sn" +
"4nKPBlw3boJEjJaTvOyvMXmNSTB4BN7kdLnhXy_CLQ4FZy0Y-PMboMGCH9gfKT1bYcQHllUTLnjtzd0iBJWY-I0ahoMEIa1PkksCytBz" +
"5qBGunrwr28PqW_t6GN99pUn0zxFn2022C17fnDHGdS1G2Tlag0Jpadl2PgdN_V9u2BndHgkKCFlmS2ZmX59KWQCOJmwnTd1k8vXCpUg" +
"DVjBK5CzCb9aFp8pjdy0mdMeV-7hYE2acyIrTPVZwAMAgHFdA";
private static final String DATA_PARTITION_ID = "common";
@Autowired
private MockMvc mockMvc;
@MockBean
private JaxRsDpsLog log;
@MockBean
private TenantInfo tenantInfo;
@MockBean
private ITenantFactory tenantFactory;
@MockBean
private AuthorizationFilter authorizationFilter;
@MockBean
private DeleteMemberService deleteMemberService;
@Before
public void setup() {
TenantInfo tenantInfo = new TenantInfo();
tenantInfo.setDataPartitionId(DATA_PARTITION_ID);
tenantInfo.setServiceAccount("internal-service-account");
when(tenantFactory.listTenantInfo()).thenReturn(Collections.singletonList(tenantInfo));
when(tenantFactory.getTenantInfo(DATA_PARTITION_ID)).thenReturn(tenantInfo);
when(authorizationFilter.hasAnyPermission(any())).thenReturn(true);
}
@Test
public void shouldMatchExpectedHttpRequest() throws Exception {
performRequest("xxx@common.contoso.com")
.andExpect(status().isNoContent());
}
@Test
public void shouldValidatePartitionId() throws Exception {
performRequest("xxx@common.contoso.com", "common1,common2")
.andExpect(status().isUnauthorized());
}
@Test
public void shouldInvokeDeleteMemberServiceWithExpectedArg() throws Exception {
ArgumentCaptor<DeleteMemberDto> captor = ArgumentCaptor.forClass(DeleteMemberDto.class);
performRequest("XXX@common.contoso.com")
.andExpect(status().isNoContent());
verify(deleteMemberService, times(1)).deleteMember(captor.capture());
assertThat(captor.getValue().getMemberEmail()).isEqualTo("xxx@common.contoso.com");
assertThat(captor.getValue().getRequesterId()).isEqualTo("a@b.com");
assertThat(captor.getValue().getPartitionId()).isEqualTo(DATA_PARTITION_ID);
}
private ResultActions performRequest(String memberEmail) throws Exception {
return performRequest(memberEmail, DATA_PARTITION_ID);
}
private ResultActions performRequest(String memberEmail, String partitionId) throws Exception {
return mockMvc.perform(delete("/members/{member_email}", memberEmail)
.contentType(MediaType.APPLICATION_JSON)
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + TOKEN)
.header(DpsHeaders.DATA_PARTITION_ID, partitionId))
.andDo(print());
}
}
\ No newline at end of file
package org.opengroup.osdu.entitlements.v2.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.entitlements.v2.model.ParentReference;
import org.opengroup.osdu.entitlements.v2.model.deletemember.DeleteMemberDto;
import org.opengroup.osdu.entitlements.v2.model.removemember.RemoveMemberServiceDto;
import org.opengroup.osdu.entitlements.v2.spi.retrievegroup.RetrieveGroupRepo;
import java.util.Arrays;
import java.util.List;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class DeleteMemberServiceTest {
private static final String DATA_PARTITION_ID = "common";
private static final String MEMBER_EMAIL = "member@xxx.com";
private static final String REQUEST_ID = "test-requester-id";
@Mock
private JaxRsDpsLog log;
@Mock
private RetrieveGroupRepo retrieveGroupRepo;
@Mock
private RemoveMemberService removeMemberService;
@InjectMocks
private DeleteMemberService deleteMemberService;
@Test
public void shouldSuccessfullyRemoveExistingMember() {
String domain = "common.contoso.com";
String groupName1 = "data.x1";
String groupEmail1 = groupName1 + "@" + domain;
String groupName2 = "data.x2";
String groupEmail2 = groupName2 + "@" + domain;
List<ParentReference> directParents = Arrays.asList(
ParentReference.builder()
.id(groupEmail1)
.name(groupName1)
.dataPartitionId(DATA_PARTITION_ID)
.build(),
ParentReference.builder()
.id(groupEmail2)
.name(groupName2)
.dataPartitionId(DATA_PARTITION_ID)
.build()
);
when(retrieveGroupRepo.loadDirectParents(DATA_PARTITION_ID, MEMBER_EMAIL)).thenReturn(directParents);
DeleteMemberDto deleteMemberDto = DeleteMemberDto.builder()
.memberEmail(MEMBER_EMAIL)
.partitionId(DATA_PARTITION_ID)
.requesterId(REQUEST_ID)
.build();
deleteMemberService.deleteMember(deleteMemberDto);
verify(retrieveGroupRepo, times(1)).loadDirectParents(DATA_PARTITION_ID, MEMBER_EMAIL);
verify(removeMemberService, times(1)).removeMember(buildRemoveMemberServiceDto(groupEmail1));
verify(removeMemberService, times(1)).removeMember(buildRemoveMemberServiceDto(groupEmail2));
}
private RemoveMemberServiceDto buildRemoveMemberServiceDto(String groupEmail) {
return RemoveMemberServiceDto.builder()
.groupEmail(groupEmail)
.memberEmail(MEMBER_EMAIL)
.requesterId(REQUEST_ID)
.partitionId(DATA_PARTITION_ID)
.build();
}
}
\ No newline at end of file
package org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.tinkerpop.gremlin.driver.Client;
import org.apache.tinkerpop.gremlin.driver.Cluster;
import org.apache.tinkerpop.gremlin.driver.Result;
import org.apache.tinkerpop.gremlin.driver.ResultSet;
import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
import org.apache.tinkerpop.gremlin.driver.ser.Serializers;
import org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource;
......@@ -34,8 +37,10 @@ public class ClusterGremlinConnector implements GremlinConnector {
private static final int MAX_CONTENT_LENGTH = 65536;
private static final long KEEP_ALIVE_TIME = 30000;
private static final int MAX_IN_PROCESS = 16;
private static final String NOT_FOUND_EXCEPTION_TYPE = "NotFoundException";
private static final String TRAVERSAL_SUBMIT_ERROR_MESSAGE = "Error submitting traversal";
private static final String RETRIEVING_RESULT_SET_ERROR_MESSAGE = "Error retrieving ResultSet object";
private static final String RESOURCE_NOT_FOUND_ERROR_MESSAGE = "Resource Not Found";
private static final String HTTPS_SCHEME = "https://";
private static final String ENDPOINT_PORT = ":443/";
/**
......@@ -157,6 +162,12 @@ public class ClusterGremlinConnector implements GremlinConnector {
resultList = completableFutureResults.get();
validateRequestSuccessful(completableFutureStatusAttributes.get());
} catch (ExecutionException e) {
if (isResourceNotFoundException(e)) {
throw new AppException(
HttpStatus.NOT_FOUND.value(),
HttpStatus.NOT_FOUND.getReasonPhrase(),
RESOURCE_NOT_FOUND_ERROR_MESSAGE, e);
}
throw new AppException(
HttpStatus.INTERNAL_SERVER_ERROR.value(),
HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),
......@@ -171,6 +182,16 @@ public class ClusterGremlinConnector implements GremlinConnector {
return resultList;
}
private boolean isResourceNotFoundException(ExecutionException e) {
if (e.getCause() instanceof ResponseException) {
ResponseException responseException = (ResponseException) e.getCause();
if (ResponseStatusCode.SERVER_ERROR.equals(responseException.getResponseStatusCode())) {
return StringUtils.contains(responseException.getMessage(), NOT_FOUND_EXCEPTION_TYPE);
}
}
return false;
}
private void validateRequestSuccessful(Map<String, Object> statusAttributes) {
if ((Integer) statusAttributes.get("x-ms-status-code") != 200) {
throw new AppException(
......
......@@ -15,6 +15,7 @@ import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.entitlements.v2.api.CreateGroupApi;
import org.opengroup.osdu.entitlements.v2.api.DeleteGroupApi;
import org.opengroup.osdu.entitlements.v2.api.DeleteMemberApi;
import org.opengroup.osdu.entitlements.v2.auth.AuthorizationService;
import org.opengroup.osdu.entitlements.v2.azure.AzureAppProperties;
import org.opengroup.osdu.entitlements.v2.logging.AuditLogger;
......@@ -48,6 +49,7 @@ import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
......@@ -58,7 +60,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@ComponentScan("org.opengroup.osdu.entitlements.v2")
@WebMvcTest(controllers = {CreateGroupApi.class, DeleteGroupApi.class})
@WebMvcTest(controllers = {CreateGroupApi.class, DeleteGroupApi.class, DeleteMemberApi.class})
public class CreateMembershipsWorkflowSinglePartitionTest {
/**
* JWT token of service principal
......@@ -91,10 +93,15 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
"MjQyODA4OCwiZXhwIjoxNjA0NDI5OTM2LCJhdWQiOiJ0ZXN0LmNvbSIsInN1YiI6InVzZXIzQGIuY29tIiwibGFzdG5hbWUiOiJKb2hu" +
"bnkiLCJmaXJzdCI6IlJvY2tldCIsImVtYWlsIjoidXNlcjNAZGVzaWQuY29tIiwiZGVzaWQiOiJ1c2VyM0BkZXNpZC5jb20iLCJqdGki" +
"OiJjZDI1MDRlZC1hNDA1LTRlYmItYjNlNS01NDExOGNhYTdkMDgifQ.1lLN3kg88ncki3bWk9aYz2obN8cXgtfKU5JSzvqOeiM";
public static final String JWT_FOR_MEMBER_DELETION = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSl" +
"dUIEJ1aWxkZXIiLCJpYXQiOjE1OTk2NzE0NTEsImV4cCI6MTYzMTIwNzQ1MSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoidX" +
"Nlci1mb3ItZGVsZXRpb25AZGVzaWQuY29tIiwiZW1haWwiOiJ1c2VyLWZvci1kZWxldGlvbkBkZXNpZC5jb20iLCJkZXNpZCI6InVzZX" +
"ItZm9yLWRlbGV0aW9uQGRlc2lkLmNvbSJ9.JkDGIlylJUDwaZcAiYGd4VDpFZOgrabYB31DrxjLCpw";
private static final String userA = "user1@desid.com";
private static final String userB = "user2@desid.com";
private static final String userC = "user3@desid.com";
private static final String USER_FOR_DELETION = "user-for-deletion@desid.com";
@Autowired
private MockMvc mockMvc;
......@@ -223,6 +230,8 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
"data.default.viewers@common.contoso.com"}, performListGroupRequest(jwtC));
testGroupUpdateApi();
testDeleteMemberApi();
}
private void removeDataGroup1FromDataGroup2(String dataGroup1, String dataGroup2) {
......@@ -564,6 +573,29 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
"users@common.contoso.com"}, performListGroupRequest(jwtA));
}
private void testDeleteMemberApi() throws Exception {
String rootUserGroup = "users@common.contoso.com";
String permissionGroupName = "users.test.editors";
String permissionGroup = permissionGroupName + "@common.contoso.com";
performCreateGroupRequest(permissionGroupName, SERVICE_P_JWT);
assertTrue(performListGroupRequest(JWT_FOR_MEMBER_DELETION).getGroups().isEmpty());
performAddMemberRequest(new AddMemberDto(USER_FOR_DELETION, Role.MEMBER), rootUserGroup, SERVICE_P_JWT);
performAddMemberRequest(new AddMemberDto(USER_FOR_DELETION, Role.MEMBER), permissionGroup, SERVICE_P_JWT);
assertGroupsEquals(new String[]{
rootUserGroup,
permissionGroup,
"data.default.owners@common.contoso.com",
"data.default.viewers@common.contoso.com"
}, performListGroupRequest(JWT_FOR_MEMBER_DELETION));
performDeleteMemberRequest(USER_FOR_DELETION, SERVICE_P_JWT);
assertTrue(performListGroupRequest(JWT_FOR_MEMBER_DELETION).getGroups().isEmpty());
performDeleteGroupRequest(permissionGroup, SERVICE_P_JWT);
}
private void performCreateGroupRequest(String groupName, String jwt) {
try {
CreateGroupDto dto = new CreateGroupDto(groupName, groupName + ": description");
......@@ -663,6 +695,15 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
.andExpect(status().isOk());
}
private void performDeleteMemberRequest(String memberEmail, String jwt) throws Exception {
mockMvc.perform(delete("/members/{member_email}", memberEmail)
.contentType(MediaType.APPLICATION_JSON)
.characterEncoding(StandardCharsets.UTF_8.name())
.header(DpsHeaders.AUTHORIZATION, "Bearer " + jwt)
.header(DpsHeaders.DATA_PARTITION_ID, "common"))
.andExpect(status().isNoContent());
}
private void assertGroupsEquals(String[] expectedGroupEmails, ListGroupResponseDto dto) {
Set<String> actualGroups = new HashSet<>(
Lists.transform(new ArrayList<>(dto.getGroups()), ParentReference::getId));
......
package org.opengroup.osdu.entitlements.v2.azure.acceptance;
import org.opengroup.osdu.entitlements.v2.acceptance.DeleteMemberTest;
import org.opengroup.osdu.entitlements.v2.util.AzureConfigurationService;
import org.opengroup.osdu.entitlements.v2.util.AzureTokenService;
public class DeleteMemberAzureTest extends DeleteMemberTest {
public DeleteMemberAzureTest() {
super(new AzureConfigurationService(), new AzureTokenService());
}
}
package org.opengroup.osdu.entitlements.v2.acceptance;
import com.sun.jersey.api.client.ClientResponse;
import org.junit.Test;
import org.opengroup.osdu.entitlements.v2.acceptance.model.GroupItem;
import org.opengroup.osdu.entitlements.v2.acceptance.model.Token;
import org.opengroup.osdu.entitlements.v2.acceptance.model.request.AddMemberRequestData;
import org.opengroup.osdu.entitlements.v2.acceptance.model.request.RequestData;
import org.opengroup.osdu.entitlements.v2.acceptance.util.ConfigurationService;
import org.opengroup.osdu.entitlements.v2.acceptance.util.TokenService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public abstract class DeleteMemberTest extends AcceptanceBaseTest {
private final List<String> groupsForFurtherDeletion;
private final Token token;
public DeleteMemberTest(ConfigurationService configurationService, TokenService tokenService) {
super(configurationService, tokenService);
groupsForFurtherDeletion = new ArrayList<>();
token = tokenService.getToken();
}
@Override
protected void cleanup() throws Exception {
for (String groupName : groupsForFurtherDeletion) {
entitlementsV2Service.deleteGroup(groupName, token.getValue());
}
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
return RequestData.builder()
.method("DELETE")
.relativePath("members/member@test.com")
.dataPartitionId(configurationService.getTenantId())
.token(tokenService.getNoDataAccessToken().getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
.method("DELETE")
.relativePath("members/member@test.com")
.dataPartitionId(configurationService.getTenantId())