From 5cc277db68604d91218311f11f9120857f7c9237 Mon Sep 17 00:00:00 2001 From: Gregory <32060161+ggmaleva@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:00:46 +0300 Subject: [PATCH] add requestId in logs + check invitation email ignore case (#48) * add requestId in logs + check invitation email ignore case * fix test Co-authored-by: ggmaleva --- .../dev/vality/orgmanager/controller/UserController.java | 9 +++++---- .../vality/orgmanager/service/OrganizationService.java | 2 +- src/test/java/dev/vality/orgmanager/util/TestData.java | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/dev/vality/orgmanager/controller/UserController.java b/src/main/java/dev/vality/orgmanager/controller/UserController.java index b672a56..c4c2e24 100644 --- a/src/main/java/dev/vality/orgmanager/controller/UserController.java +++ b/src/main/java/dev/vality/orgmanager/controller/UserController.java @@ -27,7 +27,7 @@ public class UserController implements UserApi { public ResponseEntity cancelOrgMembership( String requestId, String orgId) { - log.info("Cancel org membership: orgId={}", orgId); + log.info("Cancel org membership: requestId={}, orgId={}", requestId, orgId); ResourceDto resource = ResourceDto.builder() .orgId(orgId) .build(); @@ -40,7 +40,7 @@ public class UserController implements UserApi { public ResponseEntity inquireOrgMembership( String requestId, String orgId) { - log.info("Inquire org membership: orgId={}", orgId); + log.info("Inquire org membership: requestId={}, orgId={}", requestId, orgId); ResourceDto resource = ResourceDto.builder() .orgId(orgId) .build(); @@ -53,7 +53,7 @@ public class UserController implements UserApi { public ResponseEntity joinOrg( String requestId, OrganizationJoinRequest body) { - log.info("Join organization: body={}", body); + log.info("Join organization: requestId={}, body ={}", requestId, body); ResourceDto resource = ResourceDto.builder() .invitationToken(body.getInvitation()) .build(); @@ -67,7 +67,8 @@ public class UserController implements UserApi { public ResponseEntity listOrgMembership(String requestId, Integer limit, String continuationToken) { - log.info("List org membership: limit={}, continuationToken={}", limit, continuationToken); + log.info("List org membership: requestId={}, limit={}, continuationToken={}", + requestId, limit, continuationToken); resourceAccessService.checkRights(); AccessToken accessToken = keycloakService.getAccessToken(); OrganizationSearchResult organizationSearchResult = diff --git a/src/main/java/dev/vality/orgmanager/service/OrganizationService.java b/src/main/java/dev/vality/orgmanager/service/OrganizationService.java index bf94c66..533acb0 100644 --- a/src/main/java/dev/vality/orgmanager/service/OrganizationService.java +++ b/src/main/java/dev/vality/orgmanager/service/OrganizationService.java @@ -236,7 +236,7 @@ public class OrganizationService { @Transactional public OrganizationMembership joinOrganization(String token, String userId, String userEmail) { InvitationEntity invitationEntity = invitationService.findByToken(token); - if (!userEmail.equals(invitationEntity.getInviteeContactEmail())) { + if (!userEmail.equalsIgnoreCase(invitationEntity.getInviteeContactEmail())) { log.error("joinOrganization() - error: user email = {} doesn't equals invitee email = {}", userEmail, invitationEntity.getInviteeContactEmail()); throw new AccessDeniedException( diff --git a/src/test/java/dev/vality/orgmanager/util/TestData.java b/src/test/java/dev/vality/orgmanager/util/TestData.java index e4a0e84..27e1e6e 100644 --- a/src/test/java/dev/vality/orgmanager/util/TestData.java +++ b/src/test/java/dev/vality/orgmanager/util/TestData.java @@ -1,5 +1,6 @@ package dev.vality.orgmanager.util; +import dev.vality.orgmanager.TestObjectFactory; import dev.vality.orgmanager.entity.InvitationEntity; import dev.vality.orgmanager.entity.MemberEntity; import dev.vality.orgmanager.entity.MemberRoleEntity; @@ -35,7 +36,7 @@ public class TestData { .createdAt(LocalDateTime.now()) .name("name") .owner("owner") - .party("party") + .party(TestObjectFactory.randomString()) .members(Set.of(member)) .build(); }