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 22ec716e36af11bf4f76e3009ce3e3669123aed3..ebcc5c9be49629b680d4e5a68ab5da0038f489b9 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 @@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.nio.file.Path; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -50,6 +51,22 @@ public class ApiIamExternalCustomerCreationSteps extends CommonSteps { Optional.of(ResourcesUtils.getResourcePath("data/vitamui-logo.png"))); } + @When("^un utilisateur avec le rôle ROLE_CREATE_CUSTOMERS ajoute un nouveau client avec un thème personnalisé dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_CUSTOMERS$") + public void un_utilisateur_avec_le_rôle_ROLE_CREATE_CUSTOMERS_ajoute_un_nouveau_client_avec_un_thème_personnalisé_dans_un_tenant_auquel_il_est_autorisé_en_utilisant_un_certificat_full_access_avec_le_rôle_ROLE_CREATE_CUSTOMERS() + throws IOException { + testContext.savedBasicCustomerDto = FactoryDto.buildDto(CustomerDto.class); + + HashMap<String, String> themeColors = new HashMap<>(); + themeColors.put("vitamui-primary", "#123456"); + themeColors.put("vitamui-secondary", "#654321"); + testContext.savedBasicCustomerDto.setHasCustomGraphicIdentity(true); + testContext.savedBasicCustomerDto.setThemeColors(themeColors); + + testContext.basicCustomerDto = create(getSystemTenantUserAdminContext(), testContext.savedBasicCustomerDto, + Optional.of(ResourcesUtils.getResourcePath("data/vitamui-logo.png"))); + } + + public CustomerDto create(final ExternalHttpContext context, final CustomerDto customerDto, final Optional<Path> logoPath) { final IamExternalWebClientFactory iamExternalWebClientFactory = getIamWebClientFactory(true, null, new String[] { ServicesData.ROLE_CREATE_CUSTOMERS }); diff --git a/integration-tests/src/test/resources/features/back/iam/customer/ExternalCustomerCreation.feature b/integration-tests/src/test/resources/features/back/iam/customer/ExternalCustomerCreation.feature index d1374cb96aae708479a1b54ed7daf11d6ee50efc..1f6787d2d310a4a9663f1eb631313ef91eb9d608 100644 --- a/integration-tests/src/test/resources/features/back/iam/customer/ExternalCustomerCreation.feature +++ b/integration-tests/src/test/resources/features/back/iam/customer/ExternalCustomerCreation.feature @@ -18,7 +18,7 @@ Feature: API Customers : création d'un nouveau client @ApiIamCustomersCreationLogo Scenario: Cas normal avec un logo - When un utilisateur avec le rôle ROLE_CREATE_CUSTOMERS ajoute un nouveau client avec son logo dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_CUSTOMERS + When un utilisateur avec le rôle ROLE_CREATE_CUSTOMERS ajoute un nouveau client avec un thème personnalisé dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_CUSTOMERS Then le serveur retourne le client créé And un identity provider par défaut est associé au client And un tenant par défaut est créé @@ -26,6 +26,16 @@ Feature: API Customers : création d'un nouveau client And un utilisateur admin est associé au client And une trace de création d'un client est présente dans vitam + @ApiIamCustomersCreationWithTheme + Scenario: Cas normal avec un logo + When un utilisateur avec le rôle ROLE_CREATE_CUSTOMERS ajoute un nouveau client avec son logo dans un tenant auquel il est autorisé en utilisant un certificat full access avec le rôle ROLE_CREATE_CUSTOMERS + Then le serveur retourne le client créé + And un identity provider par défaut est associé au client + And un tenant par défaut est créé + And 6 profils sont créés pour le tenant principal + And un utilisateur admin est associé au client + And une trace de création d'un client est présente dans vitam + Scenario Outline: Cas sécurité, par un utilisateur <(userRole) avec ou sans> les rôles ROLE_CREATE_CUSTOMERS sur le tenant principal, après avoir choisi le tenant <(headerTenant) principal ou secondaire> dans l'IHM, et en utilisant un certificat <(certRole) avec ou sans> les rôles ROLE_CREATE_CUSTOMERS <(certTenant) sur le tenant principal ou sur le tenant secondaire ou étant fullAccess> = le serveur <autorise ou refuse> l'accès à l'api customers Given deux tenants et un rôle par défaut pour l'ajout d'un client diff --git a/ui/ui-frontend-common/src/app/modules/theme.service.ts b/ui/ui-frontend-common/src/app/modules/theme.service.ts index 957aa8f506829499589d9d91cf6e29d592070d2d..46d72ed2ba1e62718d010bbc6178bf99a0f581bb 100644 --- a/ui/ui-frontend-common/src/app/modules/theme.service.ts +++ b/ui/ui-frontend-common/src/app/modules/theme.service.ts @@ -12,12 +12,15 @@ export class ThemeService { 'vitamui-primary': '#702382', 'vitamui-primary-light': '', 'vitamui-primary-light-20': '', + 'vitamui-primary-dark': '', + 'vitamui-secondary': '#7FA1D4', 'vitamui-secondary-light': '', 'vitamui-secondary-light-8': '', 'vitamui-secondary-dark-5': '' }; + // Theme for current app configuration applicationColorMap; constructor() { diff --git a/ui/ui-frontend-common/src/app/modules/utils/colors.util.ts b/ui/ui-frontend-common/src/app/modules/utils/colors.util.ts index 62b7d344966c3e521af404061ec15641eb6537f2..d9875c01aa1a99d2889ff160d6f67804d6b82634 100644 --- a/ui/ui-frontend-common/src/app/modules/utils/colors.util.ts +++ b/ui/ui-frontend-common/src/app/modules/utils/colors.util.ts @@ -76,7 +76,6 @@ function convertToLightColor(color: string, lightModificator: number = 10) { return color; } - const max = 255; const rgbValue: RGB = hexToRgb(color); const hslValue: HSL = rgbToHsl(rgbValue); diff --git a/ui/ui-frontend-common/src/app/modules/utils/theme-colors.interface.ts b/ui/ui-frontend-common/src/app/modules/utils/theme-colors.interface.ts index 72074f30f7a002179e9d7af0628b1e6073032d3d..fe6cea971bf2668f5c7e17c69166caf6eb5bec75 100644 --- a/ui/ui-frontend-common/src/app/modules/utils/theme-colors.interface.ts +++ b/ui/ui-frontend-common/src/app/modules/utils/theme-colors.interface.ts @@ -5,6 +5,7 @@ export interface ThemeColors { 'vitamui-primary-light'?: string; 'vitamui-primary-light-20'?: string; + 'vitamui-primary-dark'?: string; 'vitamui-secondary': string; 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 4e74a784adba6e2dcc570f6ab5e524f47d959f6c..bd1addf3588351d972ccd7355722dcb29212218c 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 @@ -199,8 +199,9 @@ export class CustomerCreateComponent implements OnInit, OnDestroy { 'vitamui-primary': themeColors.primary, 'vitamui-secondary': themeColors.secondary }; - - customer.themeColors = this.themeService.getThemeColors(customerTheme); + if (customer.hasCustomGraphicIdentity) { + customer.themeColors = customerTheme; + } return customer; }