Commit 3cb10909 authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Rostislav Dublin (EPAM)
Browse files

Fixed response message and group unique constaint (GONRG-2989, GONRG-3003, GONRG-2988)

parent 915840b1
...@@ -231,6 +231,7 @@ The following software have components provided under the terms of this license: ...@@ -231,6 +231,7 @@ The following software have components provided under the terms of this license:
- Spring Beans (from https://github.com/spring-projects/spring-framework) - Spring Beans (from https://github.com/spring-projects/spring-framework)
- Spring Boot Log4j 2 Starter (from http://projects.spring.io/spring-boot/) - Spring Boot Log4j 2 Starter (from http://projects.spring.io/spring-boot/)
- Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) - Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat)
- Spring Boot Undertow Starter (from http://projects.spring.io/spring-boot/)
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
- Spring Context (from https://github.com/spring-projects/spring-framework) - Spring Context (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework) - Spring Core (from https://github.com/spring-projects/spring-framework)
...@@ -318,13 +319,13 @@ The following software have components provided under the terms of this license: ...@@ -318,13 +319,13 @@ The following software have components provided under the terms of this license:
- proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) - proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1)
- requests (from https://requests.readthedocs.io) - requests (from https://requests.readthedocs.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://github.com/resilience4j/resilience4j)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://github.com/resilience4j/resilience4j)
- resilience4j (from https://github.com/resilience4j/resilience4j)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io)
- rxjava (from https://github.com/ReactiveX/RxJava) - rxjava (from https://github.com/ReactiveX/RxJava)
...@@ -343,7 +344,6 @@ The following software have components provided under the terms of this license: ...@@ -343,7 +344,6 @@ The following software have components provided under the terms of this license:
- spring-boot-starter-logging (from https://spring.io/projects/spring-boot) - spring-boot-starter-logging (from https://spring.io/projects/spring-boot)
- spring-boot-starter-security (from https://spring.io/projects/spring-boot) - spring-boot-starter-security (from https://spring.io/projects/spring-boot)
- spring-boot-starter-test (from https://spring.io/projects/spring-boot) - spring-boot-starter-test (from https://spring.io/projects/spring-boot)
- spring-boot-starter-undertow (from https://spring.io/projects/spring-boot)
- spring-boot-starter-validation (from https://spring.io/projects/spring-boot) - spring-boot-starter-validation (from https://spring.io/projects/spring-boot)
- spring-boot-starter-web (from https://spring.io/projects/spring-boot) - spring-boot-starter-web (from https://spring.io/projects/spring-boot)
- spring-boot-test (from https://spring.io/projects/spring-boot) - spring-boot-test (from https://spring.io/projects/spring-boot)
......
...@@ -44,7 +44,10 @@ public class RemoveMemberService { ...@@ -44,7 +44,10 @@ public class RemoveMemberService {
} }
EntityNode memberNode = retrieveGroupRepo.getMemberNodeForRemovalFromGroup(memberEmail, partitionId); EntityNode memberNode = retrieveGroupRepo.getMemberNodeForRemovalFromGroup(memberEmail, partitionId);
removeMemberServiceDto.setChildrenReference(memberNode.getDirectChildReference(retrieveGroupRepo, existingGroupEntityNode).orElseThrow( removeMemberServiceDto.setChildrenReference(memberNode.getDirectChildReference(retrieveGroupRepo, existingGroupEntityNode).orElseThrow(
() -> new AppException(HttpStatus.NOT_FOUND.value(), HttpStatus.NOT_FOUND.getReasonPhrase(), String.format("Group %s does not have %s as a child/member", groupEmail, memberEmail)) () -> new AppException(HttpStatus.NOT_FOUND.value(),
HttpStatus.NOT_FOUND.getReasonPhrase(), String.format("Group %s does not have"
+ " %s as a direct child/member. Please check the group hierarchy for an "
+ "explicit member declaration.", groupEmail, memberEmail))
)); ));
if (serviceAccountsConfigurationService.isMemberProtectedServiceAccount(memberNode, existingGroupEntityNode)) { if (serviceAccountsConfigurationService.isMemberProtectedServiceAccount(memberNode, existingGroupEntityNode)) {
......
...@@ -12,7 +12,11 @@ public class ApiInputValidation { ...@@ -12,7 +12,11 @@ public class ApiInputValidation {
public static void validateEmailAndBelongsToPartition(String groupEmail, String partitionDomain) { public static void validateEmailAndBelongsToPartition(String groupEmail, String partitionDomain) {
validateEmail(groupEmail); validateEmail(groupEmail);
if (!groupEmail.endsWith("@" + partitionDomain)) { if (!groupEmail.endsWith("@" + partitionDomain)) {
throw new AppException(HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), "Data Partition Id does not match with the group"); throw new AppException(
HttpStatus.BAD_REQUEST.value(),
HttpStatus.BAD_REQUEST.getReasonPhrase(),
"Wrong partition domain for email: 'DataPartitionId.Domain' pattern should be used. "
+ "Data Partition Id should match with the group.");
} }
} }
......
...@@ -12,7 +12,8 @@ public class ApiInputValidationTest { ...@@ -12,7 +12,8 @@ public class ApiInputValidationTest {
ApiInputValidation.validateEmailAndBelongsToPartition("data.x.viewers@common.contoso.com", "common2.contoso.com"); ApiInputValidation.validateEmailAndBelongsToPartition("data.x.viewers@common.contoso.com", "common2.contoso.com");
Assert.fail(); Assert.fail();
} catch (AppException e) { } catch (AppException e) {
Assert.assertEquals("Data Partition Id does not match with the group", e.getError().getMessage()); Assert.assertEquals("Wrong partition domain for email: 'DataPartitionId.Domain' "
+ "pattern should be used. Data Partition Id should match with the group.", e.getError().getMessage());
Assert.assertEquals(400, e.getError().getCode()); Assert.assertEquals(400, e.getError().getCode());
Assert.assertEquals("Bad Request", e.getError().getReason()); Assert.assertEquals("Bad Request", e.getError().getReason());
} }
......
...@@ -13,7 +13,7 @@ email character varying COLLATE pg_catalog."default", ...@@ -13,7 +13,7 @@ email character varying COLLATE pg_catalog."default",
partition_id character varying COLLATE pg_catalog."default", partition_id character varying COLLATE pg_catalog."default",
CONSTRAINT group_pkey PRIMARY KEY (id), CONSTRAINT group_pkey PRIMARY KEY (id),
CONSTRAINT group_email_key UNIQUE (email), CONSTRAINT group_email_key UNIQUE (email),
CONSTRAINT group_name_key UNIQUE (name) CONSTRAINT group_name_partition_id_key UNIQUE (name, partition_id)
) )
TABLESPACE pg_default; TABLESPACE pg_default;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment