diff --git a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasInternalService.java b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasInternalService.java index e846b3ce037132d8ae9b25e34ef8a7a1e865bdf8..e650a4b5159f2820d073f1cf7ce6b842f65d60b0 100644 --- a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasInternalService.java +++ b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasInternalService.java @@ -98,7 +98,9 @@ import lombok.Setter; @Setter public class CasInternalService { - private static final String _ID = "_id"; + private static final String USER_NOT_FOUND_MESSAGE = "User not found: "; + + private static final String ID = "_id"; private static final String NB_FAILED_ATTEMPTS = "nbFailedAttempts"; @@ -167,7 +169,7 @@ public class CasInternalService { final Customer customer = optCustomer.orElseThrow(() -> new ApplicationServerException("Unable to update password : customer not found")); final List<String> oldPasswords = user.getOldPasswords(); - if (oldPasswords != null && oldPasswords.size() > 0) { + if (oldPasswords != null && !oldPasswords.isEmpty()) { for (final String oldPassword : oldPasswords) { if (passwordEncoder.matches(rawPassword, oldPassword)) { throw new ConflictException("The given password has already been used in the past"); @@ -181,7 +183,7 @@ public class CasInternalService { final String existingPassword = user.getPassword(); user.setPassword(encodedPassword); - final OffsetDateTime nowPlusPasswordRevocationDelay = OffsetDateTime.now().plusDays(customer.getPasswordRevocationDelay()); + final OffsetDateTime nowPlusPasswordRevocationDelay = OffsetDateTime.now().plusMonths(customer.getPasswordRevocationDelay()); user.setPasswordExpirationDate(nowPlusPasswordRevocationDelay); userRepository.save(user); @@ -197,7 +199,7 @@ public class CasInternalService { @Transactional public void updateNbFailedAttempsPlusLastConnectionAndStatus(final User user, final int nbFailedAttempts, final UserStatusEnum oldStatus) { final UserStatusEnum newStatus = user.getStatus(); - final Query query = new Query(Criteria.where(_ID).is(user.getId())); + final Query query = new Query(Criteria.where(ID).is(user.getId())); final Update update = Update.update(NB_FAILED_ATTEMPTS, nbFailedAttempts).set(LAST_CONNECTION, OffsetDateTime.now()).set(STATUS, newStatus); mongoTemplate.updateFirst(query, update, MongoDbCollections.USERS); @@ -213,7 +215,7 @@ public class CasInternalService { private User checkUserInformations(final String email) { final User user = userRepository.findByEmail(email); if (user == null) { - throw new NotFoundException("User not found: " + email); + throw new NotFoundException(USER_NOT_FOUND_MESSAGE + email); } else if (UserTypeEnum.NOMINATIVE != user.getType()) { throw new InvalidAuthenticationException("User unavailable: " + email); @@ -250,7 +252,7 @@ public class CasInternalService { final UserDto userDto = internalUserService.findUserByEmail(email); if (userDto == null) { - throw new NotFoundException("User not found: " + email); + throw new NotFoundException(USER_NOT_FOUND_MESSAGE + email); } checkStatus(userDto.getStatus(), userDto.getEmail()); if (loadFullProfile) { @@ -314,7 +316,7 @@ public class CasInternalService { user.setLastConnection(OffsetDateTime.now()); user.setAuthToken(token.getId()); // update user last connection info. This is used for example for users with external provider. - final Query query = new Query(Criteria.where(_ID).is(user.getId())); + final Query query = new Query(Criteria.where(ID).is(user.getId())); final Update update = Update.update(LAST_CONNECTION, user.getLastConnection()); mongoTemplate.updateFirst(query, update, MongoDbCollections.USERS); } @@ -322,7 +324,7 @@ public class CasInternalService { public UserDto getUserProfileById(final String id) { final UserDto user = internalUserService.getOne(id, Optional.empty()); if (user == null) { - throw new NotFoundException("User not found: " + id); + throw new NotFoundException(USER_NOT_FOUND_MESSAGE + id); } checkStatus(user.getStatus(), user.getEmail()); diff --git a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalService.java b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalService.java index 31874d109480a6ac06294255d9726041f3456b2c..464614a1f15c3747b3ee2d4ea0751f76b18a1560 100644 --- a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalService.java +++ b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalService.java @@ -647,6 +647,10 @@ public class UserInternalService extends VitamUICrudService<UserDto, User> { } private void checkOtp(final UserDto userDto) { + if (UserTypeEnum.GENERIC == userDto.getType() && !userDto.isOtp()) { + // do not check OTP informations for generic admin or support accounts when otp is disabled + return; + } checkOtp(userDto.isOtp(), userDto.getEmail(), userDto.getMobile(), userDto.getCustomerId()); } diff --git a/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasServiceIntegrationTest.java b/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasServiceIntegrationTest.java index 9ac1b3ceddc4e75b9726aad211b6ccf2da053df8..d2e494c522a3a11018c751dd3cf69cf0f060434f 100644 --- a/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasServiceIntegrationTest.java +++ b/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/cas/service/CasServiceIntegrationTest.java @@ -1,7 +1,10 @@ package fr.gouv.vitamui.iam.internal.server.cas.service; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import java.time.OffsetDateTime; import java.util.Collection; import java.util.Optional; @@ -55,10 +58,11 @@ import fr.gouv.vitamui.iam.internal.server.user.domain.User; import fr.gouv.vitamui.iam.internal.server.user.service.UserInternalService; @RunWith(SpringRunner.class) -@EnableMongoRepositories(basePackageClasses = { CustomSequenceRepository.class, - TokenRepository.class }, repositoryBaseClass = VitamUIRepositoryImpl.class) +@EnableMongoRepositories(basePackageClasses = { CustomSequenceRepository.class, TokenRepository.class }, repositoryBaseClass = VitamUIRepositoryImpl.class) public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { + private static final int PASSWORD_EXPIRATION_DELAY = 42; + private static final String EMAIL = "surrogate@vitamui.com"; private static final String PASSWORD = "passwd"; @@ -125,10 +129,9 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { casService.setTimeIntervalForLoginAttempts(20); casService.setPasswordEncoder(passwordEncoder); Mockito.when(internalSecurityService.getHttpContext()).thenReturn(internalHttpContext); - Tenant tenant = new Tenant(); + final Tenant tenant = new Tenant(); tenant.setIdentifier(10); - Mockito.when(tenantRepository.findOne(ArgumentMatchers.any(Query.class))) - .thenReturn(Optional.ofNullable(tenant)); + Mockito.when(tenantRepository.findOne(ArgumentMatchers.any(Query.class))).thenReturn(Optional.ofNullable(tenant)); ServerIdentityConfigurationBuilder.setup("identityName", "identityRole", 1, 0); tokenRepository.deleteAll(); @@ -144,13 +147,13 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { subro.setSuperUserCustomerId("superUserCustomerId"); subro.setSurrogate(surrogate); subro.setSurrogateCustomerId("surrogateCustomerId"); - Mockito.when(subrogationRepository.findBySuperUserAndSurrogate(ArgumentMatchers.anyString(), - ArgumentMatchers.anyString())).thenReturn(Optional.of(subro)); + Mockito.when(subrogationRepository.findBySuperUserAndSurrogate(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())) + .thenReturn(Optional.of(subro)); Mockito.when(userRepository.findByEmail(ArgumentMatchers.anyString())).thenReturn(new User()); casService.deleteSubrogationBySuperUserAndSurrogate(superUser, surrogate); - final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq") - .is(MongoDbCollections.SUBROGATIONS).and("evType").is(EventType.EXT_VITAMUI_LOGOUT_SURROGATE); + final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq").is(MongoDbCollections.SUBROGATIONS).and("evType") + .is(EventType.EXT_VITAMUI_LOGOUT_SURROGATE); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); } @@ -163,8 +166,8 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { user.setEmail(EMAIL); final Subrogation subro = getUsersByEmail(user); - final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq") - .is(MongoDbCollections.SUBROGATIONS).and("evType").is(EventType.EXT_VITAMUI_START_SURROGATE_GENERIC); + final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq").is(MongoDbCollections.SUBROGATIONS).and("evType") + .is(EventType.EXT_VITAMUI_START_SURROGATE_GENERIC); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); } @@ -177,8 +180,8 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { user.setEmail(EMAIL); final Subrogation subro = getUsersByEmail(user); - final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq") - .is(MongoDbCollections.SUBROGATIONS).and("evType").is(EventType.EXT_VITAMUI_START_SURROGATE_USER); + final Criteria criteria = Criteria.where("obId").is(subro.getId()).and("obIdReq").is(MongoDbCollections.SUBROGATIONS).and("evType") + .is(EventType.EXT_VITAMUI_START_SURROGATE_USER); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); } @@ -194,8 +197,7 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { Mockito.when(internalUserService.loadGroupAndProfiles(ArgumentMatchers.any())).thenReturn(authUser); Mockito.when(subrogationRepository.findOneBySurrogate(ArgumentMatchers.anyString())).thenReturn(subro); Mockito.when(userRepository.findByEmail(ArgumentMatchers.anyString())).thenReturn(new User()); - casService.getUserByEmail(email, - Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER + "," + CommonConstants.SURROGATION_PARAMETER)); + casService.getUserByEmail(email, Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER + "," + CommonConstants.SURROGATION_PARAMETER)); return subro; } @@ -212,7 +214,7 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { Mockito.when(userRepository.findByEmail(EMAIL)).thenReturn(user); final Customer customer = new Customer(); customer.setId(CUSTOMER_ID); - customer.setPasswordRevocationDelay(42); + customer.setPasswordRevocationDelay(PASSWORD_EXPIRATION_DELAY); Mockito.when(customerRepository.findById(CUSTOMER_ID)).thenReturn(Optional.of(customer)); return user; @@ -225,8 +227,8 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { casService.updatePassword(EMAIL, PASSWORD); - final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq") - .is(MongoDbCollections.USERS).and("evType").is(EventType.EXT_VITAMUI_PASSWORD_INIT); + final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq").is(MongoDbCollections.USERS).and("evType") + .is(EventType.EXT_VITAMUI_PASSWORD_INIT); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); } @@ -235,13 +237,16 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { public void testPasswordUpdate() { final User user = prepareUserPwd("oldPassword"); - + final String oldPassword = user.getPassword(); + final OffsetDateTime passwordExpirationDate = OffsetDateTime.now().plusMonths(PASSWORD_EXPIRATION_DELAY); casService.updatePassword(EMAIL, PASSWORD); - final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq") - .is(MongoDbCollections.USERS).and("evType").is(EventType.EXT_VITAMUI_PASSWORD_CHANGE); + final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq").is(MongoDbCollections.USERS).and("evType") + .is(EventType.EXT_VITAMUI_PASSWORD_CHANGE); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); + assertNotEquals("Password should not be the same", oldPassword, user.getPassword()); + assertTrue("Password Expiration date is not correct", user.getPasswordExpirationDate().isAfter(passwordExpirationDate)); } @Test(expected = ConflictException.class) @@ -262,12 +267,11 @@ public class CasServiceIntegrationTest extends AbstractLogbookIntegrationTest { casService.updateNbFailedAttempsPlusLastConnectionAndStatus(user, 4, UserStatusEnum.ENABLED); - final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq") - .is(MongoDbCollections.USERS).and("evType").is(EventType.EXT_VITAMUI_BLOCK_USER); + final Criteria criteria = Criteria.where("obId").is(user.getIdentifier()).and("obIdReq").is(MongoDbCollections.USERS).and("evType") + .is(EventType.EXT_VITAMUI_BLOCK_USER); final Collection<Event> events = eventRepository.findAll(Query.query(criteria)); assertThat(events).hasSize(1); final Event event = events.iterator().next(); - assertThat(event.getEvDetData()).isEqualTo( - "{\"diff\":{\"-Statut\":\"ENABLED\"," + "\"+Statut\":\"BLOCKED\"},\"Durée du blocage\":\"PT20M\"}"); + assertThat(event.getEvDetData()).isEqualTo("{\"diff\":{\"-Statut\":\"ENABLED\"," + "\"+Statut\":\"BLOCKED\"},\"Durée du blocage\":\"PT20M\"}"); } } diff --git a/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalServiceIntegTest.java b/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalServiceIntegTest.java index b7711ab8ecf93f6e5ad74f1c2b3b9e93baaa62ef..ca6223e82b8d1c55b483d6a2b8b19796f42048b7 100644 --- a/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalServiceIntegTest.java +++ b/api/api-iam/iam-internal/src/test/java/fr/gouv/vitamui/iam/internal/server/user/service/UserInternalServiceIntegTest.java @@ -47,7 +47,9 @@ import fr.gouv.vitamui.commons.security.client.dto.AuthUserDto; import fr.gouv.vitamui.commons.test.utils.ServerIdentityConfigurationBuilder; import fr.gouv.vitamui.commons.test.utils.TestUtils; import fr.gouv.vitamui.commons.utils.VitamUIUtils; +import fr.gouv.vitamui.iam.common.enums.OtpEnum; import fr.gouv.vitamui.iam.commons.utils.IamDtoBuilder; +import fr.gouv.vitamui.commons.api.enums.UserTypeEnum; import fr.gouv.vitamui.iam.internal.server.common.ApiIamInternalConstants; import fr.gouv.vitamui.iam.internal.server.common.domain.Address; import fr.gouv.vitamui.iam.internal.server.common.domain.MongoDbCollections; @@ -259,6 +261,33 @@ public final class UserInternalServiceIntegTest extends AbstractLogbookIntegrati internalUserService.create(userAdminFr); } + @Test + public void testCreateAGenericUser() { + final UserDto userAdminFr = IamServerUtilsTest.buildUserDto(null, "support@vitamui.com", GROUP_ID, CUSTOMER_ID); + userAdminFr.setIdentifier(null); + userAdminFr.setMobile(null); + userAdminFr.setType(UserTypeEnum.GENERIC); + userAdminFr.setOtp(false); + + final Customer customer = new Customer(); + final String customerId = "customerId"; + customer.setId(customerId); + customer.setEnabled(true); + customer.setOtp(OtpEnum.MANDATORY); + customer.setPasswordRevocationDelay(20); + final GroupDto group = new GroupDto(); + group.setEnabled(true); + group.setCustomerId(customerId); + Mockito.when(customerRepository.findById(any())).thenReturn(Optional.of(customer)); + Mockito.when(groupInternalService.getOne(any(), any(), any())).thenReturn(group); + Mockito.when(internalSecurityService.isLevelAllowed(any())).thenReturn(true); + Mockito.when(groupInternalService.getOneByPassSecurity(any(), any())).thenReturn(buildGroupDto()); + Mockito.when(internalSecurityService.getHttpContext()).thenReturn(internalHttpContext); + + final UserDto userAdminFrDto = internalUserService.create(userAdminFr); + assertThat(userAdminFrDto.getIdentifier()).isNotBlank(); + } + private UserDto createUser() { return createUser(null); } diff --git a/cas/cas-server/src/main/config/cas-server-application-dev.yml b/cas/cas-server/src/main/config/cas-server-application-dev.yml index fecfdb87092f5f17b45675f549e77edf11f7db51..debd006aac39b17a61c3784654bbd2e1f07664e4 100644 --- a/cas/cas-server/src/main/config/cas-server-application-dev.yml +++ b/cas/cas-server/src/main/config/cas-server-application-dev.yml @@ -7,7 +7,7 @@ server: port: 8080 -vitamui.cas.tenant.identifier: 11 +vitamui.cas.tenant.identifier: -1 vitamui.cas.identity: cas iam-client: server-host: localhost diff --git a/deployment/environments/group_vars/all/vitamui_vars.yml b/deployment/environments/group_vars/all/vitamui_vars.yml index 35560373836729ab853fe0ce928c7871ecd715f0..146a699b72a6dcd44c3fbcc7000811192173fdde 100755 --- a/deployment/environments/group_vars/all/vitamui_vars.yml +++ b/deployment/environments/group_vars/all/vitamui_vars.yml @@ -177,7 +177,7 @@ vitamui_platform_informations: city: change-it country: change-it proof_tenant: 3 - cas_tenant: 4 + cas_tenant: -1 first_customer_tenant: 9 mongodb_vitamuiScripts_version: diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/IamCommonSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/IamCommonSteps.java index 08cf044f87700707040de8e99b5ed3d4e5dbdf90..f01fe811c75a2b28addf58de25d0cdce4a7c2327 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/IamCommonSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/IamCommonSteps.java @@ -91,7 +91,7 @@ public class IamCommonSteps extends CommonSteps { public void un_utilisateur_décline_la_subrogation() { try { getSubrogationRestClient() - .decline(getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : TestConstants.SYSTEM_TENANT_IDENTIFIER, + .decline(getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : proofTenantIdentifier, testContext.authUserDto.getAuthToken()), testContext.savedSubrogationDto.getId()); } catch (final RuntimeException e) { @@ -105,8 +105,8 @@ public class IamCommonSteps extends CommonSteps { deleteAllSubrogations(subrogationDto); subrogationDto = getSubrogationRestClient().create(getSystemTenantUserAdminContext(), subrogationDto); testContext.savedSubrogationDto = subrogationDto; - testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), subrogationDto.getSurrogate(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } @@ -122,7 +122,7 @@ public class IamCommonSteps extends CommonSteps { @Given("^un tenant et customer system$") public void un_tenant_et_customer_system() throws Exception { - testContext.mainTenant = TestConstants.SYSTEM_TENANT_IDENTIFIER; + testContext.mainTenant = proofTenantIdentifier; testContext.customerId = TestConstants.SYSTEM_CUSTOMER_ID; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/SecuritySteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/SecuritySteps.java index 66d8d50f827cb6f557e4e039e6888ee8fd69b669..7a28cc6fbd9fdcc3c9199947d550a223e349aae6 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/SecuritySteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/common/SecuritySteps.java @@ -13,10 +13,6 @@ import fr.gouv.vitamui.cucumber.common.CommonSteps; public class SecuritySteps extends CommonSteps { - private static final String PARAM_WITH = "avec"; - - private static final String PARAM_WITHOUT = "sans"; - @Before public void cleanTestContext() { testContext.reset(); @@ -231,24 +227,4 @@ public class SecuritySteps extends CommonSteps { testContext.fullAccess = fullAccess; } - /** - * Allow to mutualise steps depending on parameter "avec"/"sans" : return the - * given role (avec) or the default role (sans) - * - * @param avecOuSans - * parameter "avec" or "sans" wrote in the Scenario Step - * @param role - * the role required to operate the action to test - * @return - */ - private String getRoleOrDefault(final String avecOuSans, final String role) { - switch (avecOuSans) { - case PARAM_WITH : - return role; - case PARAM_WITHOUT : - return testContext.defaultRole; - default : - throw new IllegalArgumentException("Le paramètre " + avecOuSans + " ne correspond pas à un mot accepté"); - } - } } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/application/ApiIamExternalApplicationGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/application/ApiIamExternalApplicationGetSteps.java index 8f7d913b01c27b112e1065fe5b1d47e4858dfa4b..40d76f7d2166fd295e1bd5876e09d4416a2d6b2e 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/application/ApiIamExternalApplicationGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/application/ApiIamExternalApplicationGetSteps.java @@ -28,10 +28,6 @@ public class ApiIamExternalApplicationGetSteps extends CommonSteps { private List<ApplicationDto> applicationDtos; - private ApplicationDto applicationDto; - - private static final String WRONG_LEVEL = "WRONGLEVEL"; - @When("^un utilisateur récupère toutes les applications dans un tenant auquel il est autorisé en utilisant un certificat full access$") public void un_utilisateur_récupère_tous_les_applications_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access() { applicationDtos = getApplicationRestClient().getAll(getSystemTenantUserAdminContext()); diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasChangePasswordSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasChangePasswordSteps.java index a2d0e469da92590f7136a190f9dca42ab4783dc3..04f2dcc762be999bacb07a919b38f80d562ee69f 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasChangePasswordSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasChangePasswordSteps.java @@ -31,15 +31,15 @@ public class ApiIamExternalCasChangePasswordSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_CAS_CHANGE_PASSWORD_change_le_mot_de_passe_d_un_utilisateur_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_CHANGE_PASSWORD() { createBasicUser(); pwdExpirationDate = testContext.authUserDto.getPasswordExpirationDate(); - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }).changePassword( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }).changePassword( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD); } @Then("^le mot de passe a été changé car l'utilisateur peut s'authentifier avec son nouveau mot de passe$") public void le_mot_de_passe_a_été_changé_car_l_utilisateur_peut_s_authentifier_avec_son_nouveau_mot_de_passe() { testContext.authUserDto = new AuthUserDto( - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD, null, + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD, null, null)); assertThat(testContext.authUserDto.getPasswordExpirationDate().isEqual(pwdExpirationDate)).isFalse(); } @@ -50,8 +50,8 @@ public class ApiIamExternalCasChangePasswordSteps extends CommonSteps { basicUserDto.setType(UserTypeEnum.GENERIC); testContext.authUserDto = new AuthUserDto(getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto)); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) - .changePassword(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) + .changePassword(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD); } catch (final RuntimeException e) { @@ -65,8 +65,8 @@ public class ApiIamExternalCasChangePasswordSteps extends CommonSteps { basicUserDto.setStatus(UserStatusEnum.ANONYM); testContext.authUserDto = new AuthUserDto(getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto)); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) - .changePassword(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) + .changePassword(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), NEW_PASSWORD); } catch (final RuntimeException e) { @@ -77,8 +77,8 @@ public class ApiIamExternalCasChangePasswordSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_CHANGE_PASSWORD change le mot de passe d'un utilisateur inexistant dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_CHANGE_PASSWORD$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_CHANGE_PASSWORD_change_le_mot_de_passe_d_un_utilisateur_inexistant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_CHANGE_PASSWORD() { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) - .changePassword(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN, NEW_PASSWORD); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }) + .changePassword(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN, NEW_PASSWORD); } catch (final RuntimeException e) { testContext.exception = e; @@ -87,8 +87,8 @@ public class ApiIamExternalCasChangePasswordSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour le changement de mot de passe$") public void deux_tenants_et_un_rôle_par_défaut_pour_le_changement_de_mot_de_passe() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasFindUserSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasFindUserSteps.java index 76d8475b3e73cec0f6964815f16a1a3af35a1b33..81cb5bd6b8cf0075ff7a06ced26b3a5930403bd9 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasFindUserSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasFindUserSteps.java @@ -27,8 +27,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_USERS cherche un utilisateur par son email en demandant un token d'authentification dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_USERS_cherche_un_utilisateur_par_son_email_en_demandant_un_token_d_authentification_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_USERS() { - testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.SYSTEM_USER_PREFIX_EMAIL + CommonConstants.EMAIL_SEPARATOR + defaultEmailDomain, Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } @@ -40,8 +40,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto); testContext.authUserDto = new AuthUserDto(basicUserDto); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } catch (final RuntimeException e) { @@ -64,8 +64,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_USERS cherche un utilisateur inexistant par son email dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_USERS_cherche_un_utilisateur_inexistant_par_son_email_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_USERS() { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_USERS }) - .getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), BAD_LOGIN, Optional.empty()); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }) + .getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), BAD_LOGIN, Optional.empty()); } catch (final RuntimeException e) { testContext.exception = e; @@ -74,8 +74,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la recherche d'un utilisateur par email$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_recherche_d_un_utilisateur_par_email() { - setMainTenant(TestConstants.CAS_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); + setMainTenant(casTenantIdentifier); + setSecondTenant(proofTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -93,8 +93,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_USERS cherche un utilisateur par son identifiant dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_USERS_cherche_un_utilisateur_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_USERS() { - final UserDto basicUserDto = getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserById(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + final UserDto basicUserDto = getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserById(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), SYSTEM_USER_ID); testContext.authUserDto = new AuthUserDto(basicUserDto); } @@ -102,8 +102,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_USERS cherche un utilisateur inexistant par son identifiant dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_USERS_cherche_un_utilisateur_inexistant_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_USERS() { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_USERS }) - .getUserById(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), BAD_LOGIN); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }) + .getUserById(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), BAD_LOGIN); } catch (final RuntimeException e) { testContext.exception = e; @@ -117,8 +117,8 @@ public class ApiIamExternalCasFindUserSteps extends CommonSteps { basicUserDto = getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto); testContext.authUserDto = new AuthUserDto(basicUserDto); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_USERS }) - .getUserById(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getId()); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }) + .getUserById(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getId()); } catch (final RuntimeException e) { testContext.exception = e; diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLoginSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLoginSteps.java index b9b5a831a7863845c888b17ded43254f3c755fc3..35aa848adc83367ada6b28e6f993ead8ddf82e68 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLoginSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLoginSteps.java @@ -30,8 +30,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_LOGIN authentifie un utilisateur dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_LOGIN$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_LOGIN_authentifie_un_utilisateur_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_LOGIN() { testContext.authUserDto = new AuthUserDto( - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.SYSTEM_USER_PREFIX_EMAIL + CommonConstants.EMAIL_SEPARATOR + defaultEmailDomain, adminPassword, null, null)); } @@ -43,8 +43,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour authentifier un utilisateur$") public void deux_tenants_et_un_rôle_par_défaut_pour_authentifier_un_utilisateur() { - setMainTenant(TestConstants.CAS_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); + setMainTenant(casTenantIdentifier); + setSecondTenant(proofTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -64,8 +64,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_CAS_LOGIN_authentifie_un_utilisateur_avec_un_mauvais_mot_de_passe_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_LOGIN() { createUserAndSetPassword(); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), BAD_PASSWORD, null, + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), BAD_PASSWORD, null, null); } catch (final RuntimeException e) { @@ -75,8 +75,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { private void createUserAndSetPassword() { createBasicUser(); - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }).changePassword( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), adminPassword); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_CHANGE_PASSWORD }).changePassword( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), adminPassword); } @Then("^le serveur retourne une erreur bad credentials") @@ -94,8 +94,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { testContext.authUserDto = new AuthUserDto(getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto)); final String login = testContext.authUserDto.getEmail(); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }) - .login(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), login, adminPassword, null, null); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }) + .login(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), login, adminPassword, null, null); } catch (final RuntimeException e) { testContext.exception = e; @@ -105,11 +105,11 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_LOGIN authentifie un utilisateur avec un mauvais mot de passe trop de fois dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_LOGIN$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_LOGIN_authentifie_un_utilisateur_avec_un_mauvais_mot_de_passe_trop_de_fois_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_LOGIN() { createUserAndSetPassword(); - final ExternalHttpContext context = getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS); + final ExternalHttpContext context = getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS); final String login = testContext.authUserDto.getEmail(); for (int i = 0; i < 4; i++) { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login(context, + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login(context, login, BAD_PASSWORD, null, null); } catch (final RuntimeException e) { @@ -117,7 +117,7 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { } } try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login(context, login, + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login(context, login, BAD_PASSWORD, null, null); } catch (final RuntimeException e) { @@ -135,8 +135,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { @Then("^l'utilisateur est bloqué$") public void l_utilisateur_est_bloqué() { - final ExternalHttpContext context = getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS); - final UserDto basicUserDto = getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, + final ExternalHttpContext context = getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS); + final UserDto basicUserDto = getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(context, testContext.authUserDto.getEmail(), Optional.empty()); assertThat(basicUserDto.getStatus()).isEqualTo(UserStatusEnum.BLOCKED); } @@ -147,8 +147,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { basicUserDto.setStatus(UserStatusEnum.DISABLED); testContext.authUserDto = new AuthUserDto(getUserRestClient().create(getSystemTenantUserAdminContext(), basicUserDto)); try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( - getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), adminPassword, null, + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }).login( + getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), testContext.authUserDto.getEmail(), adminPassword, null, null); } catch (final RuntimeException e) { @@ -159,8 +159,8 @@ public class ApiIamExternalCasLoginSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_LOGIN authentifie un utilisateur inexistant dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_LOGIN$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_LOGIN_authentifie_un_utilisateur_inexistant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_LOGIN() { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGIN }) - .login(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN, adminPassword, null, null); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGIN }) + .login(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN, adminPassword, null, null); } catch (final RuntimeException e) { testContext.exception = e; diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLogoutSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLogoutSteps.java index d97f8cb2414f7ff55152c1c6b34367dcfeaf719a..b2e8d7211b272c66f4d5ad6c7eb65ce8afb792cb 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLogoutSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasLogoutSteps.java @@ -27,11 +27,11 @@ public class ApiIamExternalCasLogoutSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_LOGOUT fait un logout dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_LOGOUT$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_LOGOUT_fait_un_logout_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_LOGOUT() { createSubrogationByUserStatus(false); - surrogateUser = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + surrogateUser = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), surrogateUser.getEmail(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_LOGOUT }) - .logout(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), surrogateUser.getAuthToken(), superUser.getEmail()); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_LOGOUT }) + .logout(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), surrogateUser.getAuthToken(), superUser.getEmail()); } @Then("^la subrogation a bien été supprimée$") @@ -47,22 +47,22 @@ public class ApiIamExternalCasLogoutSteps extends CommonSteps { @Then("^le token d'authentification a bien été supprimé$") public void le_token_d_authentification_a_bien_été_supprimé() { final Document authTokenId = new Document("_id", surrogateUser.getAuthToken()); - final long nb = getTokensCollection().count(authTokenId); + final long nb = getTokensCollection().countDocuments(authTokenId); assertThat(nb).isEqualTo(0); } @Given("^deux tenants et un rôle par défaut pour faire un logout$") public void deux_tenants_et_un_rôle_par_défaut_pour_faire_un_logout() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @When("^cet utilisateur fait un logout$") public void cet_utilisateur_fait_un_logout() { createSubrogationByUserStatus(false); - surrogateUser = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + surrogateUser = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), surrogateUser.getEmail(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); try { getCasRestClient(testContext.fullAccess, testContext.certificateTenants, testContext.certificateRoles) diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasSubrogationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasSubrogationSteps.java index a13382a413b61c983cbb6830b670ae94c80aa1c5..9326369b4ad1d74b89eb6f784f0530f3f8563e8f 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasSubrogationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/cas/ApiIamExternalCasSubrogationSteps.java @@ -26,8 +26,8 @@ public class ApiIamExternalCasSubrogationSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_CAS_SUBROGATIONS_cherche_une_subrogation_par_l_email_de_son_superuser_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_SUBROGATIONS() { // Get or Initialize defaultSubrogation before requesting superUser getOrInitializeDefaultSubrogationId(); - subrogationDtos = getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }) - .getSubrogationsBySuperUserEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + subrogationDtos = getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }) + .getSubrogationsBySuperUserEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.JULIEN_USER_PREFIX_EMAIL + CommonConstants.EMAIL_SEPARATOR + defaultEmailDomain); } @@ -40,8 +40,8 @@ public class ApiIamExternalCasSubrogationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour chercher une subrogation par l'email de son superuser$") public void deux_tenants_et_un_rôle_par_défaut_pour_chercher_une_subrogation_par_l_email_de_son_superuser() { - setMainTenant(TestConstants.CAS_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); + setMainTenant(casTenantIdentifier); + setSecondTenant(proofTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -59,12 +59,12 @@ public class ApiIamExternalCasSubrogationSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_SUBROGATIONS cherche une subrogation par l'identifiant de son superuser dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_SUBROGATIONS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_SUBROGATIONS_cherche_une_subrogation_par_l_identifiant_de_son_superuser_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_SUBROGATIONS() { - final Integer[] tenants = new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }; + final Integer[] tenants = new Integer[] { casTenantIdentifier }; final String[] roles = new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }; // Get or Initialize defaultSubrogation before requesting superUser getOrInitializeDefaultSubrogationId(); subrogationDtos = getCasRestClient(false, tenants, roles) - .getSubrogationsBySuperUserId(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), TestConstants.JULIEN_USER_ID); + .getSubrogationsBySuperUserId(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.JULIEN_USER_ID); } @Given("^deux tenants et un rôle par défaut pour chercher une subrogation par l'identifiant de son superuser$") @@ -86,8 +86,8 @@ public class ApiIamExternalCasSubrogationSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_SUBROGATIONS cherche une subrogation avec un mauvais identifiant de superuser dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_SUBROGATIONS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_SUBROGATIONS_cherche_une_subrogation_avec_un_mauvais_identifiant_de_superuser_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_SUBROGATIONS() { try { - getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }) - .getSubrogationsBySuperUserId(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN); + getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }) + .getSubrogationsBySuperUserId(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), TestConstants.BAD_LOGIN); } catch (final RuntimeException e) { testContext.exception = e; @@ -102,9 +102,9 @@ public class ApiIamExternalCasSubrogationSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CAS_SUBROGATIONS cherche une subrogation par l'identifiant d'un superuser désactivé dans un tenant auquel il est autorisé en utilisant un certificat sur le tenant et avec le rôle ROLE_CAS_SUBROGATIONS$") public void un_utilisateur_avec_le_rôle_ROLE_CAS_SUBROGATIONS_cherche_une_subrogation_par_l_identifiant_d_un_superuser_désactivé_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_sur_le_tenant_et_avec_le_rôle_ROLE_CAS_SUBROGATIONS() { createSubrogationByUserStatus(true); - final Integer[] tenants = new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }; + final Integer[] tenants = new Integer[] { casTenantIdentifier }; final String[] roles = new String[] { ServicesData.ROLE_CAS_SUBROGATIONS }; subrogationDtos = getCasRestClient(false, tenants, roles) - .getSubrogationsBySuperUserId(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), superUser.getId()); + .getSubrogationsBySuperUserId(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), superUser.getId()); } } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCheckSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCheckSteps.java index 73505066f905fef45189c678d75599667de57d81..f2852bb7363499d002695f243a3751559a2e81e4 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCheckSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCheckSteps.java @@ -38,8 +38,8 @@ public class ApiIamExternalCustomerCheckSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la vérification de l'existence d'un client par son code et domain$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_vérification_de_l_existence_d_un_client_par_son_code_et_domain() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCreationSteps.java index f050491913058138b179ce1a289f0001e678597b..22ec716e36af11bf4f76e3009ce3e3669123aed3 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerCreationSteps.java @@ -128,8 +128,8 @@ public class ApiIamExternalCustomerCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour l'ajout d'un client") public void deux_tenants_et_un_rôle_par_défaut_pour_l_ajout_d_un_client() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerGetSteps.java index cd8edb4f1432a02d738b258228410f88eb7da52b..050704bce1af0c681a8b8945dc85763d891cd9af 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerGetSteps.java @@ -38,8 +38,8 @@ public class ApiIamExternalCustomerGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération de clients$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_de_clients() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -75,7 +75,7 @@ public class ApiIamExternalCustomerGetSteps extends CommonSteps { @When("^un utilisateur sans le rôle ROLE_GET_CUSTOMERS récupère son client dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_GET_CUSTOMERS$") public void un_utilisateur_sans_le_rôle_ROLE_GET_CUSTOMERS_récupère_son_client_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_CUSTOMERS() { - testContext.basicCustomerDto = getCustomerRestClient().getMyCustomer(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS)); + testContext.basicCustomerDto = getCustomerRestClient().getMyCustomer(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS)); } @Then("^le serveur retourne le client de l'utilisateur courant$") diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerUpdateSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerUpdateSteps.java index 184dbd23072b5095b6bd4d8c8594987cb62f99a1..9c4fa0989bada01b8ee6c92bf95dc49c69f679ed 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerUpdateSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/customer/ApiIamExternalCustomerUpdateSteps.java @@ -107,8 +107,8 @@ public class ApiIamExternalCustomerUpdateSteps extends CommonSteps { public void les_utilisateurs_du_client_ont_leur_OTP_désactivé() { final String adminEmail = "admin@" + testContext.basicCustomerDto.getDefaultEmailDomain(); final AuthUserDto adminUser = (AuthUserDto) getCasRestClient(false, - new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, new String[] { ServicesData.ROLE_CAS_USERS }) - .getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }) + .getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), adminEmail, Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); QueryDto criteria = QueryDto.criteria("name", @@ -134,8 +134,8 @@ public class ApiIamExternalCustomerUpdateSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour d'un client$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_d_un_client() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCheckSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCheckSteps.java index f2bfcd5a9cb25e907c90c5dbd3996b28846e0573..00c25e6f1d849dc1c209ceaaf7c1ddb5d3473038 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCheckSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCheckSteps.java @@ -1,10 +1,8 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.group; -import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_GROUPS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; +import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import cucumber.api.java.en.Given; import cucumber.api.java.en.When; @@ -43,17 +41,17 @@ public class ApiIamExternalGroupCheckSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_GET_GROUPS_sans_le_bon_niveau_vérifie_l_existence_d_un_groupe_par_son_nom_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_GROUPS() { QueryDto criteria = QueryDto.criteria("name", TestConstants.ADMIN_GROUP_NAME, CriterionOperator.EQUALS); - testContext.bResponse = getGroupRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, + testContext.bResponse = getGroupRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_GROUPS }).checkExist( - getContext(SYSTEM_TENANT_IDENTIFIER, tokenUserTest(new String[] { ROLE_GET_GROUPS }, - SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), + getContext(proofTenantIdentifier, tokenUserTest(new String[] { ROLE_GET_GROUPS }, + proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), criteria.toJson()); } @Given("^deux tenants et un rôle par défaut pour la vérification de l'existence d'un groupe par son nom$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_vérification_de_l_existence_d_un_groupe_par_son_nom() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCreationSteps.java index 7c426e17719621c5e70a5a4163ca49b9834346d5..90c99d567a85611d0aefe4ecec174187128b35c4 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupCreationSteps.java @@ -3,10 +3,7 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.group; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_CREATE_GROUPS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.utils.TestConstants.ADMIN_GROUP_NAME; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_TENANT_IDENTIFIER; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; @@ -81,8 +78,8 @@ public class ApiIamExternalGroupCreationSteps extends CommonSteps { testContext.level = ""; try { groupDto = getGroupRestClient(true, null, new String[] { ROLE_CREATE_GROUPS }).create( - getContext(CLIENT1_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_CREATE_GROUPS }, CLIENT1_TENANT_IDENTIFIER, CLIENT1_CUSTOMER_ID, testContext.level)), + getContext(client1TenantIdentifier, + tokenUserTest(new String[] { ROLE_CREATE_GROUPS }, client1TenantIdentifier, CLIENT1_CUSTOMER_ID, testContext.level)), savedGroupDto); } catch (final RuntimeException e) { @@ -193,8 +190,8 @@ public class ApiIamExternalGroupCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour l'ajout d'un groupe$") public void deux_tenants_et_un_rôle_par_défaut_pour_l_ajout_d_un_groupe() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupGetSteps.java index e60c70d21d05ba4419f13e83d757fd9d098cb87e..a5edca0f3843b6b9349d9c5136657f1d8846c6d8 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupGetSteps.java @@ -3,9 +3,7 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.group; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_GROUPS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.utils.TestConstants.ADMIN_GROUP_ID; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_USER_PROFILE_ID; import static org.assertj.core.api.Assertions.assertThat; @@ -61,7 +59,7 @@ public class ApiIamExternalGroupGetSteps extends CommonSteps { } private GroupExternalRestClient getGoodClient() { - return getGroupRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_GROUPS }); + return getGroupRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_GROUPS }); } private ExternalHttpContext getGoodContextWithWrongLevel() { @@ -69,7 +67,7 @@ public class ApiIamExternalGroupGetSteps extends CommonSteps { user.setLevel(WRONG_LEVEL); user.setGroupId(TestConstants.TESTS_GROUP_ID); testContext.authUserDto = new AuthUserDto(user); - return getContext(SYSTEM_TENANT_IDENTIFIER, tokenUserTest(new String[] { ROLE_GET_GROUPS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, WRONG_LEVEL)); + return getContext(proofTenantIdentifier, tokenUserTest(new String[] { ROLE_GET_GROUPS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, WRONG_LEVEL)); } @Then("^le serveur ne retourne aucun groupe$") @@ -94,8 +92,8 @@ public class ApiIamExternalGroupGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération de groupes$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_de_groupes() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupPatchSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupPatchSteps.java index ce45b2598251b39d62cef5a685f6cbc36bda16d5..60a6838ee042576edaf5f7b028e4e52645b3ecee 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupPatchSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/group/ApiIamExternalGroupPatchSteps.java @@ -3,11 +3,8 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.group; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_UPDATE_GROUPS; import static fr.gouv.vitamui.utils.TestConstants.ADMIN_GROUP_NAME; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.UPDATED; import static org.assertj.core.api.Assertions.assertThat; @@ -82,8 +79,8 @@ public class ApiIamExternalGroupPatchSteps extends CommonSteps { dto.put("customerId", CLIENT1_CUSTOMER_ID); testContext.level = ""; try { - getGroupRestClient(true, null, new String[] { ROLE_UPDATE_GROUPS }).patch(getContext(CLIENT1_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_UPDATE_GROUPS }, CLIENT1_TENANT_IDENTIFIER, CLIENT1_CUSTOMER_ID, testContext.level)), dto); + getGroupRestClient(true, null, new String[] { ROLE_UPDATE_GROUPS }).patch(getContext(client1TenantIdentifier, + tokenUserTest(new String[] { ROLE_UPDATE_GROUPS }, client1TenantIdentifier, CLIENT1_CUSTOMER_ID, testContext.level)), dto); } catch (final RuntimeException e) { testContext.exception = e; @@ -121,8 +118,8 @@ public class ApiIamExternalGroupPatchSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_GROUPS_sans_le_bon_niveau_met_à _jour_partiellement_un_groupe_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_GROUPS() { final Map<String, Object> dto = buildGroupToPatch(); try { - getGroupRestClient(true, null, new String[] { ROLE_UPDATE_GROUPS }).patch(getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_UPDATE_GROUPS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), dto); + getGroupRestClient(true, null, new String[] { ROLE_UPDATE_GROUPS }).patch(getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_UPDATE_GROUPS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), dto); } catch (final RuntimeException e) { testContext.exception = e; @@ -179,8 +176,8 @@ public class ApiIamExternalGroupPatchSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour partielle d'un groupe$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_partielle_d_un_groupe() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCheckSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCheckSteps.java index 71c659289e1d5c853c8517d93802bcf7924113e3..cb69d578e22d11ecf283473f4eb179b734da4b61 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCheckSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCheckSteps.java @@ -34,8 +34,8 @@ public class ApiIamExternalOwnerCheckSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la vérification de l'existence d'un propriétaire par son code$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_vérification_de_l_existence_d_un_propriétaire_par_son_code() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCreationSteps.java index c3bc772146ed5121814a91060db7efe1a112441b..60a628b0fa0decca42a94b41c1ea42cfc3ff0c40 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerCreationSteps.java @@ -31,8 +31,8 @@ public class ApiIamExternalOwnerCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la création d'un propriétaire$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_création_d_un_propriétaire() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerGetSteps.java index 7b6944b25312654f0035b1178443f794b69d42e1..7f10fa7b5f1684a23130cdecef2f7dcb54cee802 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerGetSteps.java @@ -40,8 +40,8 @@ public class ApiIamExternalOwnerGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération d'un propriétaire par son identifant$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_d_un_propriétaire_par_son_identifant() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerUpdateSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerUpdateSteps.java index 5d2eb9c6a14b81d02fcb864aacc5ac7b8008cfc3..78fec266a95b48d2ab58c66ad8b2c456b110b328 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerUpdateSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/owner/ApiIamExternalOwnerUpdateSteps.java @@ -74,8 +74,8 @@ public class ApiIamExternalOwnerUpdateSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour d'un propriétaire$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_d_un_propriétaire() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCheckSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCheckSteps.java index 04b2661e8fadad001bbaeef86ad0d8aedf96a725..743da77cbf297e718ec17a3ed0d31805f8dd31cd 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCheckSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCheckSteps.java @@ -2,9 +2,7 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.profile; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_PROFILES; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import cucumber.api.java.en.Given; import cucumber.api.java.en.When; @@ -42,10 +40,10 @@ public class ApiIamExternalProfileCheckSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_GET_PROFILES_sans_le_bon_niveau_vérifie_l_existence_d_un_profil_par_son_nom_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_PROFILES() { QueryDto criteria = QueryDto.criteria("name", TestConstants.SYSTEM_USER_PROFILE_NAME, CriterionOperator.EQUALS); - testContext.bResponse = getProfileRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, + testContext.bResponse = getProfileRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_PROFILES }).checkExist( - getContext(SYSTEM_TENANT_IDENTIFIER, tokenUserTest(new String[] { ROLE_GET_PROFILES }, - SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), + getContext(proofTenantIdentifier, tokenUserTest(new String[] { ROLE_GET_PROFILES }, + proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), criteria.toJson()); } @@ -62,8 +60,8 @@ public class ApiIamExternalProfileCheckSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la vérification de l'existence d'un profil par son nom$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_vérification_de_l_existence_d_un_profil_par_son_nom() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCreationSteps.java index 886bb7cb43a51c5a7c7eea587f7d8a33c4b8014e..42221be6f15f0cc65f5770446f1a6a58f17d5e2b 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileCreationSteps.java @@ -2,10 +2,7 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.profile; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_CREATE_PROFILES; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_TENANT_IDENTIFIER; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_USER_PROFILE_NAME; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +80,7 @@ public class ApiIamExternalProfileCreationSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CREATE_PROFILES ajoute un profil mais avec un mauvais tenant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_PROFILES$") public void un_utilisateur_avec_le_rôle_ROLE_CREATE_PROFILES_ajoute_un_profil_mais_avec_un_mauvais_tenant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_CREATE_PROFILES() { testContext.profileDto = FactoryDto.buildDto(ProfileDto.class); - testContext.profileDto.setTenantIdentifier(CLIENT1_TENANT_IDENTIFIER); + testContext.profileDto.setTenantIdentifier(client1TenantIdentifier); try { getProfileRestClient(true, null, new String[] { ROLE_CREATE_PROFILES }).create(getSystemTenantUserAdminContext(), testContext.profileDto); } @@ -97,7 +94,7 @@ public class ApiIamExternalProfileCreationSteps extends CommonSteps { assertThat(testContext.exception).isNotNull(); assertThat(testContext.exception.toString()) .isEqualTo("fr.gouv.vitamui.commons.api.exception.InvalidFormatException: Unable to create profile: tenantIdentifier " - + CLIENT1_TENANT_IDENTIFIER + " is not allowed"); + + client1TenantIdentifier + " is not allowed"); } @When("^un utilisateur avec le rôle ROLE_CREATE_PROFILES ajoute un profil avec un nom existant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_PROFILES$") @@ -148,8 +145,8 @@ public class ApiIamExternalProfileCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour l'ajout d'un profil$") public void deux_tenants_et_un_rôle_par_défaut_pour_l_ajout_d_un_profil() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileGetSteps.java index 076fa7af1a943844eb7c927db3834ef90d1d2889..54df43d054a72c5e76260ca8a4d174f31376141a 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfileGetSteps.java @@ -2,9 +2,7 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.profile; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_PROFILES; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_USER_PROFILE_ID; import static org.assertj.core.api.Assertions.assertThat; @@ -60,7 +58,7 @@ public class ApiIamExternalProfileGetSteps extends CommonSteps { } private ProfileExternalRestClient getGoodClient() { - return getProfileRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_PROFILES }); + return getProfileRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_PROFILES }); } private ExternalHttpContext getGoodContextWithWrongLevel() { @@ -68,8 +66,8 @@ public class ApiIamExternalProfileGetSteps extends CommonSteps { user.setLevel(WRONG_LEVEL); user.setGroupId(TestConstants.TESTS_GROUP_ID); testContext.authUserDto = new AuthUserDto(user); - return getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_GET_PROFILES }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, WRONG_LEVEL)); + return getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_GET_PROFILES }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, WRONG_LEVEL)); } @Then("^le serveur ne retourne aucun profil$") @@ -94,8 +92,8 @@ public class ApiIamExternalProfileGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération de profils$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_de_profils() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfilePatchSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfilePatchSteps.java index d668881a08adeda73df8d755ad981ecf700befc0..f2e56a16d496cf1e285afd9ec7648b075a47a66b 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfilePatchSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/profile/ApiIamExternalProfilePatchSteps.java @@ -2,11 +2,8 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.profile; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_UPDATE_PROFILES; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_USER_PROFILE_NAME; import static fr.gouv.vitamui.utils.TestConstants.UPDATED; import static org.assertj.core.api.Assertions.assertThat; @@ -84,15 +81,14 @@ public class ApiIamExternalProfilePatchSteps extends CommonSteps { @Then("^le serveur refuse la mise à jour partielle du profil à cause du mauvais client$") public void le_serveur_refuse_la_mise_à _jour_partielle_du_profil_à _cause_du_mauvais_client() { assertThat(testContext.exception).isNotNull(); - assertThat(testContext.exception.toString()) - .isEqualTo("fr.gouv.vitamui.commons.api.exception.InvalidFormatException: Unable to patch profile: customerId " + CLIENT1_CUSTOMER_ID - + " is not allowed"); + assertThat(testContext.exception.toString()).isEqualTo( + "fr.gouv.vitamui.commons.api.exception.InvalidFormatException: Unable to patch profile: customerId " + CLIENT1_CUSTOMER_ID + " is not allowed"); } @When("^un utilisateur avec le rôle ROLE_UPDATE_PROFILES met à jour partiellement un profil mais avec un mauvais tenant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_UPDATE_PROFILES$") public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_PROFILES_met_à _jour_partiellement_un_profil_mais_avec_un_mauvais_tenant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_PROFILES() { final Map<String, Object> dto = buildProfileToPatch(); - dto.put("tenantIdentifiant", CLIENT1_TENANT_IDENTIFIER); + dto.put("tenantIdentifiant", client1TenantIdentifier); testContext.level = ""; try { getProfileRestClient().patch(getSystemTenantUserAdminContext(), dto); @@ -132,8 +128,8 @@ public class ApiIamExternalProfilePatchSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_PROFILES_sans_le_bon_niveau_met_à _jour_partiellement_un_profil_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_PROFILES() { final Map<String, Object> dto = buildProfileToPatch(); try { - getProfileRestClient(true, null, new String[] { ROLE_UPDATE_PROFILES }).patch(getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_UPDATE_PROFILES }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), dto); + getProfileRestClient(true, null, new String[] { ROLE_UPDATE_PROFILES }).patch(getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_UPDATE_PROFILES }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), dto); } catch (final RuntimeException e) { testContext.exception = e; @@ -189,8 +185,8 @@ public class ApiIamExternalProfilePatchSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour partielle d'un profil$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_partielle_d_un_profil() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderCreationSteps.java index 90d61c31c9cc87e2ba1e0b4eb9decef84777c426..313866396eeb1029a5ffdadb4dbd0a71edb6663e 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderCreationSteps.java @@ -9,7 +9,6 @@ import fr.gouv.vitamui.commons.api.domain.ServicesData; import fr.gouv.vitamui.cucumber.common.CommonSteps; import fr.gouv.vitamui.iam.common.dto.IdentityProviderDto; import fr.gouv.vitamui.utils.FactoryDto; -import fr.gouv.vitamui.utils.TestConstants; /** * Teste l'API Identity providers dans IAM admin : opérations de création. @@ -32,8 +31,8 @@ public class ApiIamExternalIdentityPoviderCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la création d'un provider$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_création_d_un_provider() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderGetSteps.java index 855c33e488f50cebaef28a0f88e9ff043463c324..3380ceec7507ce91b694b2bbd0b64c4de3e367c2 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderGetSteps.java @@ -41,8 +41,8 @@ public class ApiIamExternalIdentityPoviderGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération de providers$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_de_providers() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderUpdateSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderUpdateSteps.java index 2829b77cd96307f964aec8e8eca951b8a45243f8..fcade80581f587bfa3bc04e0b601bd584f18e491 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderUpdateSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/provider/ApiIamExternalIdentityPoviderUpdateSteps.java @@ -87,8 +87,8 @@ public class ApiIamExternalIdentityPoviderUpdateSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour partielle d'un provider$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_partielle_d_un_provider() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationCreationSteps.java index 73f324c98e68d8dbb7ec218f55a38dd921ecb053..f1046a778b97df3941f73b231ec3c70488d3e378 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationCreationSteps.java @@ -38,7 +38,7 @@ public class ApiIamExternalSubrogationCreationSteps extends CommonSteps { public void deux_tenants_et_un_rôle_par_défaut_pour_la_création_d_une_subrogation() { subrogationDto = buildGoodSubrogation(); setMainTenant(testContext.tenantDto.getIdentifier()); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationDeleteSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationDeleteSteps.java index 7d1663378f16a23aca3831361987bae58901ab2a..d665ef91828efaad7b80caf77fe5daac9796772a 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationDeleteSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationDeleteSteps.java @@ -12,7 +12,6 @@ import fr.gouv.vitamui.commons.api.domain.ServicesData; import fr.gouv.vitamui.commons.api.enums.UserStatusEnum; import fr.gouv.vitamui.commons.api.exception.NotFoundException; import fr.gouv.vitamui.cucumber.common.CommonSteps; -import fr.gouv.vitamui.utils.TestConstants; /** * Teste l'API subrogations dans IAM admin : opérations de suppression. @@ -41,7 +40,7 @@ public class ApiIamExternalSubrogationDeleteSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la suppression d'une subrogation$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_suppression_d_une_subrogation() { setMainTenant(testContext.tenantDto.getIdentifier()); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationGetSteps.java index 777d063b639de9afd80088007fdc2f142ecb1e0f..b3c293fa326881f06b101451ad158b68cc40233f 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/subrogation/ApiIamExternalSubrogationGetSteps.java @@ -46,8 +46,8 @@ public class ApiIamExternalSubrogationGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération d'une subrogation par son identifiant$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_d_une_subrogation_par_son_identifiant() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -67,15 +67,15 @@ public class ApiIamExternalSubrogationGetSteps extends CommonSteps { subrogationDto = buildGoodSubrogation(); deleteAllSubrogations(subrogationDto); testContext.savedSubrogationDto = getSubrogationRestClient().create(getSystemTenantUserAdminContext(), subrogationDto); - testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), subrogationDto.getSurrogate(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } @When("^je demande ma subrogation courante en tant que subrogé$") public void je_demande_ma_subrogation_courante_en_tant_que_subrogé() { subrogationDto = getSubrogationRestClient().getMySubrogationAsSurrogate( - getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : TestConstants.SYSTEM_TENANT_IDENTIFIER, + getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : proofTenantIdentifier, testContext.authUserDto.getAuthToken())); } @@ -88,15 +88,15 @@ public class ApiIamExternalSubrogationGetSteps extends CommonSteps { public void une_subrogation_existe_pour_moi_en_tant_que_subrogateur() { buildSubrogation(true, true, null, UserStatusEnum.ENABLED); testContext.savedSubrogationDto = subrogationDto; - testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), subrogationDto.getSuperUser(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } @When("^je demande ma subrogation courante en tant que subrogateur$") public void je_demande_ma_subrogation_courante_en_tant_que_subrogateur() { subrogationDto = getSubrogationRestClient().getMySubrogationAsSuperuser( - getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : TestConstants.SYSTEM_TENANT_IDENTIFIER, + getContext(testContext.tenantDto != null ? testContext.tenantDto.getIdentifier() : proofTenantIdentifier, testContext.authUserDto.getAuthToken())); } @@ -110,8 +110,8 @@ public class ApiIamExternalSubrogationGetSteps extends CommonSteps { UserDto user = FactoryDto.buildDto(UserDto.class); user.setCustomerId(TestConstants.SYSTEM_CUSTOMER_ID); user = getUserRestClient().create(getSystemTenantUserAdminContext(), user); - testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + testContext.authUserDto = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), user.getEmail(), Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantCreationSteps.java index 6a6d53abcf20d477032c32d327fda58303c99728..fcc34d44f107f77a9f64eabaefc5ead55cedd950 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantCreationSteps.java @@ -28,11 +28,11 @@ public class ApiIamExternalTenantCreationSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_CREATE_TENANTS ajoute un nouveau tenant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_TENANTS$") public void un_utilisateur_avec_le_rôle_ROLE_CREATE_TENANTS_ajoute_un_nouveau_tenant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_CREATE_TENANTS() { testContext.level = ""; - testContext.tenantDto = getTenantRestClient(true, new Integer[] { TestConstants.SYSTEM_TENANT_IDENTIFIER }, + testContext.tenantDto = getTenantRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ServicesData.ROLE_CREATE_TENANTS }) - .create(getContext(TestConstants.SYSTEM_TENANT_IDENTIFIER, + .create(getContext(proofTenantIdentifier, tokenUserTest(new String[] { ServicesData.ROLE_CREATE_TENANTS }, - TestConstants.SYSTEM_TENANT_IDENTIFIER, TestConstants.SYSTEM_CUSTOMER_ID, + proofTenantIdentifier, TestConstants.SYSTEM_CUSTOMER_ID, testContext.level)), createOwnerAndBuildTenant()); } @@ -46,11 +46,11 @@ public class ApiIamExternalTenantCreationSteps extends CommonSteps { final OwnerDto rownerDto = getOwnerRestClient().create(getSystemTenantUserAdminContext(), ownerDto); final TenantDto tenantDto = IamDtoBuilder.buildTenantDto(null, testContext.tenantDto.getName(), null, rownerDto.getId(), SYSTEM_CUSTOMER_ID); - getTenantRestClient(true, new Integer[] { TestConstants.SYSTEM_TENANT_IDENTIFIER }, + getTenantRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ServicesData.ROLE_CREATE_TENANTS }) - .create(getContext(TestConstants.SYSTEM_TENANT_IDENTIFIER, + .create(getContext(proofTenantIdentifier, tokenUserTest(new String[] { ServicesData.ROLE_CREATE_TENANTS }, - TestConstants.SYSTEM_TENANT_IDENTIFIER, TestConstants.SYSTEM_CUSTOMER_ID, + proofTenantIdentifier, TestConstants.SYSTEM_CUSTOMER_ID, testContext.level)), tenantDto); } @@ -87,8 +87,8 @@ public class ApiIamExternalTenantCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour l'ajout d'un tenant$") public void deux_tenants_et_un_rôle_par_défaut_pour_l_ajout_d_un_tenant() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantGetSteps.java index 92a23b52d13609b641888b9d12fe471694643701..edc22f3862ff79997fefe534e07cf119fd9cc7b4 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantGetSteps.java @@ -52,8 +52,8 @@ public class ApiIamExternalTenantGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération d'un tenant par son identifiant$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_d_un_tenant_par_son_identifiant() { - setMainTenant(TestConstants.SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(TestConstants.CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ServicesData.ROLE_LOGBOOKS; } @@ -70,14 +70,14 @@ public class ApiIamExternalTenantGetSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_GET_TENANTS récupère un tenant par son identifiant dans un tenant auquel il est autorisé et identique au tenant récupéré en utilisant un certificat full access avec le rôle ROLE_GET_ALL_TENANTS$") public void un_utilisateur_avec_le_rôle_ROLE_GET_TENANTS_récupère_un_tenant_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_et_identique_au_tenant_récupéré_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_ALL_TENANTS() { - testContext.tenantDto = getTenantRestClient().getOne(getContext(TestConstants.SYSTEM_TENANT_IDENTIFIER, tokenUserTestTenantSystem()), + testContext.tenantDto = getTenantRestClient().getOne(getContext(proofTenantIdentifier, tokenUserTestTenantSystem()), TestConstants.SYSTEM_TENANT_ID, Optional.empty()); } @When("^un utilisateur avec le rôle ROLE_GET_TENANTS récupère un tenant par son identifiant dans un tenant auquel il est autorisé mais différent du tenant récupéré en utilisant un certificat full access avec le rôle ROLE_GET_ALL_TENANTS$") public void un_utilisateur_avec_le_rôle_ROLE_GET_TENANTS_récupère_un_tenant_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_mais_différent_du_tenant_récupéré_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_ALL_TENANTS() { try { - testContext.tenantDto = getTenantRestClient().getOne(getContext(TestConstants.SYSTEM_TENANT_IDENTIFIER, tokenUserTestTenantSystem()), + testContext.tenantDto = getTenantRestClient().getOne(getContext(proofTenantIdentifier, tokenUserTestTenantSystem()), TestConstants.CAS_TENANT_ID, Optional.empty()); } catch (final RuntimeException e) { @@ -110,7 +110,7 @@ public class ApiIamExternalTenantGetSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_GET_TENANTS_récupère_tous_les_tenants_par_le_nom_dans_un_tenant_auquel_il_n_est_pas_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_TENANTS() { try { final QueryDto criteria = QueryDto.criteria("name", TestConstants.CAS_TENANT_NAME, CriterionOperator.EQUALS); - tenantDtos = getTenantRestClient().getAll(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_ADMIN), + tenantDtos = getTenantRestClient().getAll(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_ADMIN), criteria.toOptionalJson(), Optional.empty()); } catch (final RuntimeException e) { diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantUpdateSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantUpdateSteps.java index b46d9a5fa27cd473a481cc5219c65a4642019841..cc75354428bf8dc3ec35dd70fb94c7ff6878a700 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantUpdateSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/tenant/ApiIamExternalTenantUpdateSteps.java @@ -69,7 +69,7 @@ public class ApiIamExternalTenantUpdateSteps extends CommonSteps { @When("^un utilisateur sans le rôle ROLE_UPDATE_TENANTS met à jour un tenant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_UPDATE_TENANTS$") public void un_utilisateur_sans_le_rôle_ROLE_UPDATE_TENANTS_met_à _jour_un_tenant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_TENANTS() { try { - getTenantRestClient().update(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + getTenantRestClient().update(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), buildTenantToUpdate()); } catch (final RuntimeException e) { diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCheckSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCheckSteps.java index df1eb3aa85bdd2a643c44113d13ef87acb1dcaf0..551a79386c415b6268246a9b5b527fcbfde54393 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCheckSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCheckSteps.java @@ -2,9 +2,8 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.user; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_USERS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; + import cucumber.api.java.en.Given; import cucumber.api.java.en.When; @@ -34,15 +33,15 @@ public class ApiIamUserCheckSteps extends CommonSteps { final QueryDto criteria = QueryDto.criteria("email", TestConstants.SYSTEM_USER_PREFIX_EMAIL + CommonConstants.EMAIL_SEPARATOR + defaultEmailDomain, CriterionOperator.EQUALS); - testContext.bResponse = getUserRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_USERS }) - .checkExist(getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_GET_USERS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), criteria.toJson()); + testContext.bResponse = getUserRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_USERS }) + .checkExist(getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_GET_USERS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), criteria.toJson()); } @Given("^deux tenants et un rôle par défaut pour la vérification de l'existence d'un utilisateur par son email$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_vérification_de_l_existence_d_un_utilisateur_par_son_email() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCreationSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCreationSteps.java index 361013cf4a658b9f0d276c7488a90985afe9d95a..a8839c9f95f2baba159718014b672e2d8629169e 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCreationSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserCreationSteps.java @@ -2,9 +2,8 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.user; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_CREATE_USERS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; + import static org.assertj.core.api.Assertions.assertThat; import cucumber.api.Transform; @@ -124,8 +123,8 @@ public class ApiIamUserCreationSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour l'ajout d'un utilisateur$") public void deux_tenants_et_un_rôle_par_défaut_pour_l_ajout_d_un_utilisateur() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserGetSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserGetSteps.java index 09132a643d2e820d2e2e682b341f1f376531522b..adb9a17b6e65a4e77e26fde36eae91d2f65b6d89 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserGetSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserGetSteps.java @@ -2,10 +2,9 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.user; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_GET_USERS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; + import static org.assertj.core.api.Assertions.assertThat; import java.util.Collection; @@ -70,8 +69,8 @@ public class ApiIamUserGetSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_GET_USERS récupère un utilisateur d'un autre client par son identifiant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_GET_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_GET_USERS_récupère_un_utilisateur_d_un_autre_client_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_USERS() { try { - userDto = getUserRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_USERS }).getOne( - getContext(SYSTEM_TENANT_IDENTIFIER, tokenUserTest(new String[] { ROLE_GET_USERS }, SYSTEM_TENANT_IDENTIFIER, CLIENT1_CUSTOMER_ID, "")), + userDto = getUserRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_USERS }).getOne( + getContext(proofTenantIdentifier, tokenUserTest(new String[] { ROLE_GET_USERS }, proofTenantIdentifier, CLIENT1_CUSTOMER_ID, "")), SYSTEM_USER_ID, Optional.empty()); } catch (final RuntimeException e) { @@ -90,9 +89,9 @@ public class ApiIamUserGetSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_GET_USERS sans le bon niveau récupère un utilisateur par son identifiant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_GET_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_GET_USERS_sans_le_bon_niveau_récupère_un_utilisateur_par_son_identifiant_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_USERS() { try { - userDto = getUserRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_USERS }).getOne( - getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_GET_USERS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), + userDto = getUserRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_USERS }).getOne( + getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_GET_USERS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), SYSTEM_USER_ID, Optional.empty()); } catch (final RuntimeException e) { @@ -102,8 +101,8 @@ public class ApiIamUserGetSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la récupération d'utilisateurs$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_récupération_d_utilisateurs() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } @@ -134,8 +133,8 @@ public class ApiIamUserGetSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_GET_USERS récupère tous les utilisateurs d'un autre client avec pagination dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_GET_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_GET_USERS_récupère_tous_les_utilisateurs_d_un_autre_client_avec_pagination_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_GET_USERS() { - paginatedUsers = getUserRestClient(true, new Integer[] { SYSTEM_TENANT_IDENTIFIER }, new String[] { ROLE_GET_USERS }).getAllPaginated( - getContext(SYSTEM_TENANT_IDENTIFIER, tokenUserTest(new String[] { ROLE_GET_USERS }, SYSTEM_TENANT_IDENTIFIER, CLIENT1_CUSTOMER_ID, "")), 0, 10, + paginatedUsers = getUserRestClient(true, new Integer[] { proofTenantIdentifier }, new String[] { ROLE_GET_USERS }).getAllPaginated( + getContext(proofTenantIdentifier, tokenUserTest(new String[] { ROLE_GET_USERS }, proofTenantIdentifier, CLIENT1_CUSTOMER_ID, "")), 0, 10, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()).getValues(); } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserPatchSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserPatchSteps.java index d67c8cddaea2626f9c93a6d5251375e94e412d38..6bd390a0de51314cea310ac74975c3ed88200913 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserPatchSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserPatchSteps.java @@ -3,10 +3,9 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.user; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_UPDATE_ME_USERS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_UPDATE_USERS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; + import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; @@ -134,8 +133,8 @@ public class ApiIamUserPatchSteps extends CommonSteps { @When("^un utilisateur avec le rôle ROLE_UPDATE_USERS sans le bon niveau met à jour partiellement un utilisateur dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_UPDATE_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_USERS_sans_le_bon_niveau_met_à _jour_partiellement_un_utilisateur_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_USERS() { try { - getUserRestClient(true, null, new String[] { ROLE_UPDATE_USERS }).patch(getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_UPDATE_USERS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), buildUserToPatch()); + getUserRestClient(true, null, new String[] { ROLE_UPDATE_USERS }).patch(getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_UPDATE_USERS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), buildUserToPatch()); } catch (final RuntimeException e) { testContext.exception = e; @@ -151,8 +150,8 @@ public class ApiIamUserPatchSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour partielle d'un utilisateur$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_partielle_d_un_utilisateur() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } @@ -172,7 +171,7 @@ public class ApiIamUserPatchSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_ME_USERS_se_met_à _jour_partiellement_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_ME_USERS() { writeToken(TestConstants.TESTS_TOKEN_ID, testContext.savedUserDto.getId()); patchedUser = getUserRestClient(true, null, new String[] { ROLE_UPDATE_ME_USERS }) - .patchMe(getContext(SYSTEM_TENANT_IDENTIFIER, TestConstants.TESTS_TOKEN_ID), buildUserToPatch()); + .patchMe(getContext(proofTenantIdentifier, TestConstants.TESTS_TOKEN_ID), buildUserToPatch()); } @When("^un utilisateur avec le rôle ROLE_UPDATE_ME_USERS se met à jour partiellement avec un autre identifiant dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_UPDATE_ME_USERS$") @@ -181,14 +180,14 @@ public class ApiIamUserPatchSteps extends CommonSteps { patch.put("id", SYSTEM_USER_ID); writeToken(TestConstants.TESTS_TOKEN_ID, testContext.savedUserDto.getId()); patchedUser = getUserRestClient(true, null, new String[] { ROLE_UPDATE_ME_USERS }) - .patchMe(getContext(SYSTEM_TENANT_IDENTIFIER, TestConstants.TESTS_TOKEN_ID), patch); + .patchMe(getContext(proofTenantIdentifier, TestConstants.TESTS_TOKEN_ID), patch); } @When("^un utilisateur avec le rôle ROLE_UPDATE_ME_USERS se met à jour partiellement dans un tenant auquel il est autorisé en utilisant un certificat full access sans le rôle ROLE_UPDATE_ME_USERS$") public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_ME_USERS_se_met_à _jour_partiellement_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_sans_le_rôle_ROLE_UPDATE_ME_USERS() { writeToken(TestConstants.TESTS_TOKEN_ID, testContext.savedUserDto.getId()); try { - getUserRestClient(true, null, new String[] { ROLE_LOGBOOKS }).patchMe(getContext(SYSTEM_TENANT_IDENTIFIER, TestConstants.TESTS_TOKEN_ID), + getUserRestClient(true, null, new String[] { ROLE_LOGBOOKS }).patchMe(getContext(proofTenantIdentifier, TestConstants.TESTS_TOKEN_ID), buildUserToPatch()); } catch (final RuntimeException e) { diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserUpdateSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserUpdateSteps.java index 40a4e35a29f472d1607714fd92722e6594dba392..fcebadac1c17a520845daba7f57baf1610a19223 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserUpdateSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/back/steps/iam/user/ApiIamUserUpdateSteps.java @@ -2,10 +2,9 @@ package fr.gouv.vitamui.cucumber.back.steps.iam.user; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_LOGBOOKS; import static fr.gouv.vitamui.commons.api.domain.ServicesData.ROLE_UPDATE_USERS; -import static fr.gouv.vitamui.utils.TestConstants.CAS_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.CLIENT1_CUSTOMER_ID; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; + import static org.assertj.core.api.Assertions.assertThat; import java.time.OffsetDateTime; @@ -132,8 +131,8 @@ public class ApiIamUserUpdateSteps extends CommonSteps { public void un_utilisateur_avec_le_rôle_ROLE_UPDATE_USERS_sans_le_bon_niveau_met_à _jour_un_utilisateur_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_UPDATE_USERS() { updatedUser = buildUserToUpdate(); try { - getUserRestClient(true, null, new String[] { ROLE_UPDATE_USERS }).update(getContext(SYSTEM_TENANT_IDENTIFIER, - tokenUserTest(new String[] { ROLE_UPDATE_USERS }, SYSTEM_TENANT_IDENTIFIER, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), updatedUser); + getUserRestClient(true, null, new String[] { ROLE_UPDATE_USERS }).update(getContext(proofTenantIdentifier, + tokenUserTest(new String[] { ROLE_UPDATE_USERS }, proofTenantIdentifier, SYSTEM_CUSTOMER_ID, "WRONGLEVEL")), updatedUser); } catch (final RuntimeException e) { testContext.exception = e; @@ -168,8 +167,8 @@ public class ApiIamUserUpdateSteps extends CommonSteps { @Given("^deux tenants et un rôle par défaut pour la mise à jour d'un utilisateur$") public void deux_tenants_et_un_rôle_par_défaut_pour_la_mise_à _jour_d_un_utilisateur() { - setMainTenant(SYSTEM_TENANT_IDENTIFIER); - setSecondTenant(CAS_TENANT_IDENTIFIER); + setMainTenant(proofTenantIdentifier); + setSecondTenant(casTenantIdentifier); testContext.defaultRole = ROLE_LOGBOOKS; testContext.level = ""; } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/BaseIntegration.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/BaseIntegration.java index 27c84175d7a54a68c77533f28be022eaf9ad48dc..270c4646df380ad5f720cca44fc12c284c4fe173 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/BaseIntegration.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/BaseIntegration.java @@ -189,6 +189,18 @@ public abstract class BaseIntegration { @Value("${vitamui_platform_informations.default_email_domain}") protected String defaultEmailDomain; + @Value("${vitamui_platform_informations.system_archive_tenant_identifier}") + protected int systemArchiveTenantIdentifier; + + @Value("${vitamui_platform_informations.proof_tenant}") + protected int proofTenantIdentifier; + + @Value("${vitamui_platform_informations.cas_tenant}") + protected int casTenantIdentifier; + + @Value("${vitamui_platform_informations.system_archive_tenant_identifier}") + protected int client1TenantIdentifier; + @Autowired protected RestTemplateBuilder restTemplateBuilder; @@ -200,14 +212,14 @@ public abstract class BaseIntegration { protected ExternalHttpContext getSystemTenantUserAdminContext() { buildSystemTenantUserAdminContext(); - return new ExternalHttpContext(TestConstants.SYSTEM_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_ADMIN, TESTS_CONTEXT_ID, "admincaller", "requestId"); + return new ExternalHttpContext(proofTenantIdentifier, TestConstants.TOKEN_USER_ADMIN, TESTS_CONTEXT_ID, "admincaller", "requestId"); } protected ExternalHttpContext getArchiveTenantUserAdminContext() { buildSystemTenantUserAdminContext(); - return new ExternalHttpContext(TestConstants.SYSTEM_ARCHIVE_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_ADMIN, TESTS_CONTEXT_ID, "admincaller", - "requestId", ACCESS_CONTRACT); + return new ExternalHttpContext(systemArchiveTenantIdentifier, TestConstants.TOKEN_USER_ADMIN, TESTS_CONTEXT_ID, "admincaller", "requestId", + ACCESS_CONTRACT); } protected ExternalHttpContext getArchiveTenantUserAdminContext(final Integer tenantIdentifier) { diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/CommonSteps.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/CommonSteps.java index d61376b3d605fa2f67b81ab9e06e76415203eef1..f1ed6ffd35bcb078d8545eda42955c7dc3058916 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/CommonSteps.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/common/CommonSteps.java @@ -94,8 +94,8 @@ public abstract class CommonSteps extends BaseIntegration { final String customerId = customer.getId(); final String adminEmail = "admin@" + customer.getDefaultEmailDomain(); - final AuthUserDto adminUser = (AuthUserDto) getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, - new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(TestConstants.CAS_TENANT_IDENTIFIER, TestConstants.TOKEN_USER_CAS), + final AuthUserDto adminUser = (AuthUserDto) getCasRestClient(false, new Integer[] { casTenantIdentifier }, + new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS), adminEmail, Optional.of(CommonConstants.AUTH_TOKEN_PARAMETER)); final QueryDto criteria = QueryDto.criteria("name", ownerName, CriterionOperator.CONTAINSIGNORECASE); @@ -210,7 +210,7 @@ public abstract class CommonSteps extends BaseIntegration { } protected String tokenUserTestTenantSystem() { - return tokenUserTestSystemCustomer(ServicesData.ROLE_GET_TENANTS, TestConstants.SYSTEM_TENANT_IDENTIFIER); + return tokenUserTestSystemCustomer(ServicesData.ROLE_GET_TENANTS, proofTenantIdentifier); } protected String tokenUserNoRole(final int tenant) { diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/front/steps/common/CommonStepDefinitions.java b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/front/steps/common/CommonStepDefinitions.java index f4a3447466baed8c7c231817cf2b7c3bc13a2d09..4e26a8c768c3d86f6c192094bf64e5f0fa6e28db 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/front/steps/common/CommonStepDefinitions.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/cucumber/front/steps/common/CommonStepDefinitions.java @@ -99,9 +99,9 @@ public class CommonStepDefinitions extends CommonSteps { } private UserDto getCurrentUser() { - final ExternalHttpContext extneralHttpContext = getContext(TestConstants.CAS_TENANT_IDENTIFIER, + final ExternalHttpContext extneralHttpContext = getContext(casTenantIdentifier, TestConstants.TOKEN_USER_CAS); - final UserDto basicUserDto = getCasRestClient(false, new Integer[] { TestConstants.CAS_TENANT_IDENTIFIER }, + final UserDto basicUserDto = getCasRestClient(false, new Integer[] { casTenantIdentifier }, new String[] { ServicesData.ROLE_CAS_USERS }).getUserByEmail(extneralHttpContext, getCurrentUserEmail(), Optional.empty()); return basicUserDto; diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/utils/FactoryDto.java b/integration-tests/src/test/java/fr/gouv/vitamui/utils/FactoryDto.java index 817134e7bf04f28918390d3f2dcfa2c37af35290..f333fdd8a2f06995cd219b2312a8b4eb046e8611 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/utils/FactoryDto.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/utils/FactoryDto.java @@ -2,7 +2,6 @@ package fr.gouv.vitamui.utils; import static fr.gouv.vitamui.utils.TestConstants.ADMIN_LEVEL; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_CUSTOMER_ID; -import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_TENANT_IDENTIFIER; import static fr.gouv.vitamui.utils.TestConstants.SYSTEM_USER_PROFILE_ID; import java.util.Arrays; @@ -10,6 +9,8 @@ import java.util.concurrent.ThreadLocalRandom; import org.apache.commons.lang3.RandomStringUtils; import org.openqa.selenium.InvalidArgumentException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import fr.gouv.vitamui.commons.api.domain.GroupDto; import fr.gouv.vitamui.commons.api.domain.OwnerDto; @@ -23,6 +24,13 @@ import fr.gouv.vitamui.iam.common.dto.IdentityProviderDto; import fr.gouv.vitamui.iam.commons.utils.IamDtoBuilder; public class FactoryDto { + + private static Integer proofTenantIdentitfier = 10; + + @Autowired + public FactoryDto(Environment env) { + proofTenantIdentitfier = Integer.valueOf(env.getProperty("vitamui_platform_informations.proof_tenant")); + } public static <T> T buildDto(final Class<T> clazz) { T dto = null; @@ -66,7 +74,7 @@ public class FactoryDto { } private static ProfileDto buildProfileDto() { - return IamDtoBuilder.buildProfileDto(null, randomString(), SYSTEM_CUSTOMER_ID, SYSTEM_TENANT_IDENTIFIER, "applicationName", ADMIN_LEVEL, + return IamDtoBuilder.buildProfileDto(null, randomString(), SYSTEM_CUSTOMER_ID, proofTenantIdentitfier, "applicationName", ADMIN_LEVEL, Arrays.asList(new Role(ServicesData.ROLE_CREATE_PROFILES))); } diff --git a/integration-tests/src/test/java/fr/gouv/vitamui/utils/TestConstants.java b/integration-tests/src/test/java/fr/gouv/vitamui/utils/TestConstants.java index 374e6efaa5be3561bed1150aa1287e7ba7e4f1cd..b049bc32b6cab22c4bae9a49158a954d7443a9d3 100644 --- a/integration-tests/src/test/java/fr/gouv/vitamui/utils/TestConstants.java +++ b/integration-tests/src/test/java/fr/gouv/vitamui/utils/TestConstants.java @@ -1,5 +1,7 @@ package fr.gouv.vitamui.utils; +import fr.gouv.vitamui.cucumber.common.BaseIntegration; + /** * Test Constants. * @@ -21,12 +23,32 @@ public class TestConstants { public static final String VITAM_UI_CUSTOMER_CODE = "123456"; + /** + * This value is defined now in {@link BaseIntegration} and is read from config file. + * It will be removed with the next version. + */ + @Deprecated public static final int SYSTEM_ARCHIVE_TENANT_IDENTIFIER = 9; + /** + * This value is defined now in {@link BaseIntegration} and is read from config file. + * It will be removed with the next version. + */ + @Deprecated public static final int SYSTEM_TENANT_IDENTIFIER = 10; + /** + * This value is defined now in {@link BaseIntegration} and is read from config file. + * It will be removed with the next version. + */ + @Deprecated public static final int CAS_TENANT_IDENTIFIER = 11; + /** + * This value is defined now in {@link BaseIntegration} and is read from config file. + * It will be removed with the next version. + */ + @Deprecated public static final int CLIENT1_TENANT_IDENTIFIER = 102; public static final String TOKEN_USER_CAS = "tokcas_ie6UZsEcHIWrfv2x"; diff --git a/integration-tests/src/test/resources/application-dev.yml b/integration-tests/src/test/resources/application-dev.yml index fd96828cfa93dbbe545fa2d1cf5cccb0554a4247..182877c4a311cf219c18bbe90f10299ad3a463d4 100644 --- a/integration-tests/src/test/resources/application-dev.yml +++ b/integration-tests/src/test/resources/application-dev.yml @@ -69,3 +69,8 @@ vitamui_platform_informations: zip_code: change-it city: change-it country: change-it + proof_tenant: 10 + cas_tenant: -1 + first_customer_tenant: 100 + system_archive_tenant_identifier: 9 + client1_tenant_identifier: 102 diff --git a/integration-tests/src/test/resources/application-integration.yml b/integration-tests/src/test/resources/application-integration.yml index 275a9af9d3388c4dc9da395cc4ecaaa4d40c22c8..525b48993626c92c60240540aa933873a58e09c4 100644 --- a/integration-tests/src/test/resources/application-integration.yml +++ b/integration-tests/src/test/resources/application-integration.yml @@ -69,4 +69,7 @@ vitamui_platform_informations: zip_code: change-it city: change-it country: change-it + proof_tenant: 10 + cas_tenant: -1 + first_customer_tenant: 100 diff --git a/integration-tests/src/test/resources/certs/local/cas-server.jks b/integration-tests/src/test/resources/certs/local/cas-server.jks index c48ba2ae5f861cda0bb7ed034f541bb707bb7d45..2722c426e9f37b0f30deb3a86d7eb6961cdcf38d 100644 Binary files a/integration-tests/src/test/resources/certs/local/cas-server.jks and b/integration-tests/src/test/resources/certs/local/cas-server.jks differ diff --git a/integration-tests/src/test/resources/certs/local/generic-it.jks b/integration-tests/src/test/resources/certs/local/generic-it.jks index e30dfcd32996c10b7111f1b2b34dc48f2e56a1bf..1a0fd07d4172209e269c990a1e5bbd4c4a5f746b 100644 Binary files a/integration-tests/src/test/resources/certs/local/generic-it.jks and b/integration-tests/src/test/resources/certs/local/generic-it.jks differ diff --git a/integration-tests/src/test/resources/certs/local/truststore.jks b/integration-tests/src/test/resources/certs/local/truststore.jks index bca6afed16bca6a28687be09e9cfba62334995dc..33058df7190e4c48f79813ce75b4e4da97b77b3c 100644 Binary files a/integration-tests/src/test/resources/certs/local/truststore.jks and b/integration-tests/src/test/resources/certs/local/truststore.jks differ diff --git a/integration-tests/src/test/resources/certs/local/ui-archive.jks b/integration-tests/src/test/resources/certs/local/ui-archive.jks deleted file mode 100644 index e1ab3f1a9115dc7c971d73de316e13120ef934af..0000000000000000000000000000000000000000 Binary files a/integration-tests/src/test/resources/certs/local/ui-archive.jks and /dev/null differ diff --git a/integration-tests/src/test/resources/certs/local/ui-flow.jks b/integration-tests/src/test/resources/certs/local/ui-flow.jks deleted file mode 100644 index b7c6ff73a6812e8379d72f964a5988d19f378f13..0000000000000000000000000000000000000000 Binary files a/integration-tests/src/test/resources/certs/local/ui-flow.jks and /dev/null differ diff --git a/integration-tests/src/test/resources/certs/local/ui-identity.jks b/integration-tests/src/test/resources/certs/local/ui-identity.jks index 4340673355ddd3e81ee79679c7b6dadd343eac68..81c11377fd2bcbb05feb0f51da76ee030768c2db 100644 Binary files a/integration-tests/src/test/resources/certs/local/ui-identity.jks and b/integration-tests/src/test/resources/certs/local/ui-identity.jks differ diff --git a/integration-tests/src/test/resources/certs/local/ui-portal.jks b/integration-tests/src/test/resources/certs/local/ui-portal.jks index 93a76ee1e25ad18ac90ffa9e7f80b18366a0d9f6..cb7803ab0ff9af33706a7a94dfbf5fa71b92461f 100644 Binary files a/integration-tests/src/test/resources/certs/local/ui-portal.jks and b/integration-tests/src/test/resources/certs/local/ui-portal.jks differ diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html index 998a48dab84460ba6c5f5e2ae13ba88952fce6e3..f63696d85f53be6dfb2ae93b65fa30397645a9aa 100644 --- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html +++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html @@ -208,7 +208,7 @@ <p class="hint" i18n="the evidence tenant is automatically created with the owner@@customerCreateHint">Le coffre des éléments de preuve est créé automatiquement avec son propriétaire</p> </div> - <button type="submit" class="btn primary" [disabled]="form.pending || form.invalid" i18n="Finish customer creation button@@customerCreateFinishButton">Terminer</button> + <button type="submit" class="btn primary" [disabled]="form.pending || form.invalid || creating" i18n="Finish customer creation button@@customerCreateFinishButton">Terminer</button> <button type="button" class="btn cancel" (click)="onCancel()" i18n="Cancel customer creation@@customerCreateCancelButton">Annuler</button> <button type="button" class="back" cdkStepperPrevious> <i class="material-icons">arrow_back</i> <ng-container i18n="Previous step button label@@customerCreateBackButton">Retour</ng-container> diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts index 71b2c2b278e0edfd856c724d156025b057df8050..d6ec74a4a4cbf7f9a6851ed75cf7b82acf513acb 100644 --- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts @@ -65,6 +65,7 @@ export class CustomerCreateComponent implements OnInit, OnDestroy { lastUploadedImageUrl: any; hasError = true; message: string; + creating = false; // stepCount is the total number of steps and is used to calculate the advancement of the progress bar. // We could get the number of steps using ViewChildren(StepComponent) but this triggers a @@ -160,12 +161,13 @@ export class CustomerCreateComponent implements OnInit, OnDestroy { onSubmit() { if (this.form.invalid) { return; } + this.creating = true; this.customerService.create(this.form.value, this.imageToUpload).subscribe( () => { this.dialogRef.close(true); }, (error) => { - this.dialogRef.close(false); + this.creating = false; console.error(error); }); } diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/customer-popup.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/customer-popup.component.ts index 9abc1df642d7e45a3e7da723374b4b7b50eddf30..930d966df4a944bac04d341fed09e68d3ddd4e68 100644 --- a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/customer-popup.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/customer-popup.component.ts @@ -41,7 +41,7 @@ import { Customer } from 'ui-frontend-common'; @Component({ selector: 'app-customer-popup', - template: '<app-customer-preview (close)="closePopup()" [customer]="customer" [isPopup]="true"></app-customer-preview>' + template: '<app-customer-preview (previewClose)="closePopup()" [customer]="customer" [isPopup]="true"></app-customer-preview>' }) export class CustomerPopupComponent implements OnInit { diff --git a/ui/ui-frontend/projects/identity/src/app/customer/owner-preview/owner-popup.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/owner-preview/owner-popup.component.ts index fdfd8c82a8942a07926c66d39e4a2031178377f2..16f31357f3cc7cd9994fb8f59a6b7152ef45b2ab 100644 --- a/ui/ui-frontend/projects/identity/src/app/customer/owner-preview/owner-popup.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/customer/owner-preview/owner-popup.component.ts @@ -42,7 +42,7 @@ import { OwnerService } from '../owner.service'; @Component({ selector: 'app-owner-popup', - template: '<app-owner-preview (close)="closePopup()" [owner]="owner" [tenant]="tenant" [isPopup]="true"></app-owner-preview>' + template: '<app-owner-preview (previewClose)="closePopup()" [owner]="owner" [tenant]="tenant" [isPopup]="true"></app-owner-preview>' }) export class OwnerPopupComponent implements OnInit { diff --git a/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-popup.component.ts b/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-popup.component.ts index 896e60e4f26494e8442b58bea6b14fde319db4d7..0d2b14bb9da2e9296a2b8a7d125de40a46fc6f69 100644 --- a/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-popup.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-popup.component.ts @@ -41,7 +41,7 @@ import { Group } from 'ui-frontend-common'; @Component({ selector: 'app-group-popup', - template: '<app-group-preview (close)="closePopup()" [group]="group" [isPopup]="true"></app-group-preview>' + template: '<app-group-preview (previewClose)="closePopup()" [group]="group" [isPopup]="true"></app-group-preview>' }) export class GroupPopupComponent implements OnInit { diff --git a/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-preview.component.ts b/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-preview.component.ts index f9083115e84c010673b5cb4afe6aa63a7beedfe3..cfde55ca10e40ec4ee2e2f75a958f9400a6d76ea 100644 --- a/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-preview.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/group/group-preview/group-preview.component.ts @@ -59,7 +59,7 @@ export class GroupPreviewComponent implements OnInit, OnDestroy { // tslint:disable-next-line:variable-name private _group: Group; - @Output() groupClose = new EventEmitter(); + @Output() previewClose = new EventEmitter(); groupUpdateSub: Subscription; @@ -89,7 +89,7 @@ export class GroupPreviewComponent implements OnInit, OnDestroy { } emitClose() { - this.groupClose.emit(); + this.previewClose.emit(); } ngOnDestroy(): void { diff --git a/ui/ui-frontend/projects/identity/src/app/group/group.component.html b/ui/ui-frontend/projects/identity/src/app/group/group.component.html index 90429d0546eb7bed6b5284c5610810ac36e33c98..df19be1f2d9bbb1a3added99d81baca5d7b4b8a0 100644 --- a/ui/ui-frontend/projects/identity/src/app/group/group.component.html +++ b/ui/ui-frontend/projects/identity/src/app/group/group.component.html @@ -1,7 +1,7 @@ <mat-sidenav-container [autosize]="true" [hasBackdrop]="false"> <mat-sidenav #panel mode="side" position="end" [fixedInViewport]="true"> - <app-group-preview *ngIf="openedItem" (groupClose)="closePanel()" [group]="openedItem"></app-group-preview> + <app-group-preview *ngIf="openedItem" (previewClose)="closePanel()" [group]="openedItem"></app-group-preview> </mat-sidenav> <mat-sidenav-content> diff --git a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-detail.component.ts b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-detail.component.ts index 11d0bd4d709142bec97ca2e8ab497f2f6aed6564..6267ae053c1ddeea020d350484a662436a426e4b 100644 --- a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-detail.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-detail.component.ts @@ -54,7 +54,7 @@ export class HierarchyDetailComponent implements OnInit, OnDestroy { @Input() profile: Profile; @Input() isPopup: boolean; - @Output() hierarchyClose = new EventEmitter(); + @Output() previewClose = new EventEmitter(); profileUpdateSub: Subscription; @@ -82,7 +82,7 @@ export class HierarchyDetailComponent implements OnInit, OnDestroy { } emitClose() { - this.hierarchyClose.emit(); + this.previewClose.emit(); } levelNotAllowed(): boolean { diff --git a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-popup.component.ts b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-popup.component.ts index 21500b865ab230f824017cedfa0c5e9f9823ff95..bc7bf560828f9c93485edb0ef676a0e92360fcb3 100644 --- a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-popup.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy-detail/hierarchy-popup.component.ts @@ -41,7 +41,7 @@ import { Profile } from 'ui-frontend-common'; @Component({ selector: 'app-hierarchy-popup', - template: '<app-hierarchy-detail (close)="closePopup()" [profile]="profile" [isPopup]="true"></app-hierarchy-detail>' + template: '<app-hierarchy-detail (previewClose)="closePopup()" [profile]="profile" [isPopup]="true"></app-hierarchy-detail>' }) export class HierarchyPopupComponent implements OnInit { diff --git a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy.component.html b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy.component.html index 1f2871fd1108f05d490cb4070ca6f4e2114db8de..aef09e39f9e1591e463574aefb9c289d301a6ca2 100644 --- a/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy.component.html +++ b/ui/ui-frontend/projects/identity/src/app/hierarchy/hierarchy.component.html @@ -1,7 +1,7 @@ <mat-sidenav-container [autosize]="true" [hasBackdrop]="false"> <mat-sidenav #panel mode="side" position="end" [fixedInViewport]="true"> - <app-hierarchy-detail *ngIf="openedItem" (hierarchyClose)="closePanel()" [id]="openedItem?.id"></app-hierarchy-detail> + <app-hierarchy-detail *ngIf="openedItem" (previewClose)="closePanel()" [id]="openedItem?.id"></app-hierarchy-detail> </mat-sidenav> <mat-sidenav-content> diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html index b7a515e688881fe614411f48adbbaa2be8d9972d..36cd3059e492f77e10f6d9c46689f5ffdb4143a8 100644 --- a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html +++ b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html @@ -238,7 +238,7 @@ </vitamui-common-input> </div> - <button type="submit" class="btn primary" [disabled]="formInvalid()" i18n="user create validation@@userCreateValidationButton">Valider la création</button> + <button type="submit" class="btn primary" [disabled]="formInvalid() || creating" i18n="user create validation@@userCreateValidationButton">Valider la création</button> <button type="button" class="btn cancel" (click)="onCancel()" i18n="Cancel customer creation@@customerCreateCancelButton">Annuler</button> <button type="button" class="back" cdkStepperPrevious> <i class="material-icons">arrow_back</i> <ng-container i18n="Previous step button label@@customerCreateBackButton">Retour</ng-container> diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts index 5f6d2e601c217debe3f8c72d73d42a911d91b895..7a47d721f6c1081cd81ccacf3129c0da9d34bcc0 100644 --- a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts @@ -52,6 +52,7 @@ import { UserCreateValidators } from './user-create.validators'; const PROGRESS_BAR_MULTIPLICATOR = 100; const LAST_STEP_INDEX = 2; +// tslint:disable-next-line:max-line-length const emailValidator: RegExp = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; @Component({ @@ -76,6 +77,7 @@ export class UserCreateComponent implements OnInit, OnDestroy { stepIndex = 0; connectedUserInfo: AdminUserProfile; addressEmpty = true; + creating = false; // stepCount is the total number of steps and is used to calculate the advancement of the progress bar. // We could get the number of steps using ViewChildren(StepComponent) but this triggers a @@ -191,12 +193,14 @@ export class UserCreateComponent implements OnInit, OnDestroy { onSubmit() { if (this.form.invalid) { return; } + this.creating = true; let status = ''; this.form.get('enabled').value ? status = 'ENABLED' : status = 'DISABLED'; this.form.get('status').setValue(status); this.userService.create(this.form.getRawValue()).subscribe( () => this.dialogRef.close(true), (error) => { + this.creating = false; console.error(error); }); } diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-popup.component.ts b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-popup.component.ts index ccf526b211e5b3d8146bf018b9d9b6bb0ba42b15..cfb748ad026b06aa38f8250f08081d3f2bbc08c1 100644 --- a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-popup.component.ts +++ b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-popup.component.ts @@ -43,7 +43,7 @@ import { CustomerService } from '../../core/customer.service'; @Component({ selector: 'app-profile-group-popup', - template: '<app-user-preview (close)="closePopup()" [user]="user" [customer]="customer" [isPopup]="true"></app-user-preview>' + template: '<app-user-preview (previewClose)="closePopup()" [user]="user" [customer]="customer" [isPopup]="true"></app-user-preview>' }) export class UserPopupComponent implements OnInit {