diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java index 9f5688ef1..4718f3b1e 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java @@ -315,12 +315,8 @@ public Optional retrieveGeoTaxonomies(String code) { @Override public Institution updateInstitution(String institutionId, InstitutionUpdate institutionUpdate, String userId) { - if (userService.checkIfInstitutionUser(userId, institutionId)) { - List geographicTaxonomies = retrieveGeographicTaxonomies(institutionUpdate); - return institutionConnector.findAndUpdate(institutionId, null, geographicTaxonomies, institutionUpdate); - } else { - throw new ResourceForbiddenException(String.format(CustomError.RELATIONSHIP_NOT_FOUND.getMessage(), institutionId, userId, "admin roles"), CustomError.RELATIONSHIP_NOT_FOUND.getCode()); - } + List geographicTaxonomies = retrieveGeographicTaxonomies(institutionUpdate); + return institutionConnector.findAndUpdate(institutionId, null, geographicTaxonomies, institutionUpdate); } @Override diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java index e2ac72b3c..110c02671 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java @@ -589,8 +589,6 @@ void updateInstitution_shouldThrowExceptionIfGeotaxNotFound() { when(partyRegistryProxyConnector.getExtByCode(any())) .thenThrow(new ResourceNotFoundException("An error occurred", "Code")); - when(userService.checkIfInstitutionUser(any(), any())).thenReturn(true); - ArrayList institutionGeographicTaxonomiesList = new ArrayList<>(); institutionGeographicTaxonomiesList .add(new InstitutionGeographicTaxonomies("Code", "The characteristics of someone or something")); @@ -616,41 +614,6 @@ void updateInstitution_shouldThrowExceptionIfGeotaxNotFound() { assertThrows(MsCoreException.class, () -> institutionServiceImpl.updateInstitution("42", institutionUpdate, "42")); verify(partyRegistryProxyConnector).getExtByCode(any()); - verify(userService).checkIfInstitutionUser(any(), any()); - } - - /** - * Method under test: {@link InstitutionServiceImpl#updateInstitution(String, InstitutionUpdate, String)} - */ - @Test - void testUpdateInstitution7() { - when(userService.checkIfInstitutionUser(any(), any())).thenReturn(false); - - ArrayList institutionGeographicTaxonomiesList = new ArrayList<>(); - institutionGeographicTaxonomiesList - .add(new InstitutionGeographicTaxonomies("Code", "The characteristics of someone or something")); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate - .setDataProtectionOfficer(new DataProtectionOfficer("42 Main St", "jane.doe@example.org", "Pec")); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(institutionGeographicTaxonomiesList); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate - .setPaymentServiceProvider(new PaymentServiceProvider("Abi Code", "42", "Legal Register Name", "42", true)); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("6625550144"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - assertThrows(ResourceForbiddenException.class, - () -> institutionServiceImpl.updateInstitution("42", institutionUpdate, "42")); - verify(userService).checkIfInstitutionUser(any(), any()); } /** @@ -1303,17 +1266,10 @@ void testRetrieveInstitutionsWithFilter6() { @Test void testUpdateInstitutionDescription() { - when(userService.checkIfInstitutionUser(any(), any())).thenReturn(true); when(institutionConnector.findAndUpdate(any(), any(), any(), any())).thenReturn(new Institution()); assertDoesNotThrow(() -> institutionServiceImpl.updateInstitution("42", new InstitutionUpdate(), "userId")); } - @Test - void testUpdateInstitutionDescriptionException() { - when(userService.checkIfInstitutionUser(any(), any())).thenReturn(false); - assertThrows(ResourceForbiddenException.class, () -> institutionServiceImpl.updateInstitution("42", new InstitutionUpdate(), "userId")); - } - @Test void updateCreatedAt() { // Given