Skip to content

Commit

Permalink
[MOSIP-23086] Updated getPartnerDetails API to remove IDOR
Browse files Browse the repository at this point in the history
Signed-off-by: Balaji <[email protected]>
  • Loading branch information
balaji-alluru committed Jan 24, 2024
1 parent 58aed32 commit 391511e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import io.mosip.pms.partner.dto.PartnerPolicyMappingResponseDto;
import io.mosip.pms.partner.dto.UploadCertificateRequestDto;
import io.mosip.pms.partner.exception.PartnerServiceException;
import io.mosip.pms.partner.manager.exception.PartnerManagerServiceException;
import io.mosip.pms.partner.request.dto.AddContactRequestDto;
import io.mosip.pms.partner.request.dto.CACertificateRequestDto;
import io.mosip.pms.partner.request.dto.ExtractorDto;
Expand Down Expand Up @@ -447,6 +448,7 @@ private boolean validateMobileNumeber(String contactNumber) {

@Override
public RetrievePartnerDetailsResponse getPartnerDetails(String partnerId) {
validateLoggedInUserAuthorization(partnerId);
RetrievePartnerDetailsResponse response = new RetrievePartnerDetailsResponse();
Partner partner = getValidPartner(partnerId, true);
response.setPartnerID(partner.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import io.mosip.pms.partner.constant.PartnerServiceAuditEnum;
import io.mosip.pms.partner.dto.MosipUserDto;
import io.mosip.pms.partner.exception.PartnerServiceException;
import io.mosip.pms.partner.manager.exception.PartnerManagerServiceException;
import io.mosip.pms.partner.request.dto.AddContactRequestDto;
import io.mosip.pms.partner.request.dto.ExtractorDto;
import io.mosip.pms.partner.request.dto.ExtractorProviderDto;
Expand Down Expand Up @@ -324,6 +325,7 @@ public void apiKeyRequestFilterTest() {
}

@Test
@WithMockUser(roles = {"PARTNER"})
public void getPartnerDetailsWithName_Test(){
RetrievePartnerDetailsResponse response = new RetrievePartnerDetailsResponse();
Optional<Partner> partner = Optional.of(createPartner(Boolean.TRUE));
Expand All @@ -345,6 +347,7 @@ public void getPartnerDetailsWithName_Test(){
}

@Test (expected = PartnerServiceException.class)
@WithMockUser(roles = {"PARTNER"})
public void getPartnerDetailsWithName_Test01(){
RetrievePartnerDetailsResponse response = new RetrievePartnerDetailsResponse();
Optional<Partner> partner = Optional.of(createPartner(Boolean.TRUE));
Expand Down Expand Up @@ -523,6 +526,7 @@ public void throwExceptionWhenPartnerNameAlreadyRegisteredTest() {
}

@Test
@WithMockUser(roles = {"PARTNER"})
public void getPartnerDetailsTest() {
Optional<Partner> partner = Optional.of(createPartner(Boolean.TRUE));
Optional<PolicyGroup> policyGroup = Optional.of(createPolicyGroup(Boolean.TRUE));
Expand All @@ -536,6 +540,7 @@ public void getPartnerDetailsTest() {
}

@Test(expected = PartnerServiceException.class)
@WithMockUser(roles = {"PARTNER"})
public void throwExceptionWhenPartnerDetailsIsEmptyTest() {
Optional<Partner> partner = Optional.empty();
Mockito.when(partnerRepository.findById(Mockito.anyString())).thenReturn(partner);
Expand Down

0 comments on commit 391511e

Please sign in to comment.