diff --git a/interop-qa-tests/pom.xml b/interop-qa-tests/pom.xml index 7e482b061..2f5b7e97a 100644 --- a/interop-qa-tests/pom.xml +++ b/interop-qa-tests/pom.xml @@ -119,6 +119,19 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + + cucumber.junit-platform.naming-strategy=long + + + + + org.openapitools openapi-generator-maven-plugin diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/AgreementClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/AgreementClientImpl.java index 5ea8a21c1..1822d4a60 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/AgreementClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/AgreementClientImpl.java @@ -6,24 +6,27 @@ import it.pagopa.interop.generated.openapi.clients.bff.ApiClient; import it.pagopa.interop.generated.openapi.clients.bff.api.AgreementsApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.io.File; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class AgreementClientImpl implements IAgreementClient { private final AgreementsApi agreementsApi; private final RestTemplate restTemplate; private final InteropClientConfigs interopClientConfigs; private final String basePath; - private final String bearerToken; public AgreementClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.agreementsApi = new AgreementsApi(createApiClient(bearerToken)); + this.agreementsApi = new AgreementsApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/EServiceApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/EServiceApiClientImpl.java index fb3339ebd..3cb97efad 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/EServiceApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/agreement/service/impl/EServiceApiClientImpl.java @@ -6,23 +6,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.ApiClient; import it.pagopa.interop.generated.openapi.clients.bff.api.EservicesApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class EServiceApiClientImpl implements IEServiceClient { private final EservicesApi eservicesApi; private final RestTemplate restTemplate; private final InteropClientConfigs interopClientConfigs; private final String basePath; - private final String bearerToken; public EServiceApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.eservicesApi = new EservicesApi(createApiClient(bearerToken)); + this.eservicesApi = new EservicesApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/attribute/service/impl/AttributeApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/attribute/service/impl/AttributeApiClientImpl.java index 5646d92f3..46f6be28b 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/attribute/service/impl/AttributeApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/attribute/service/impl/AttributeApiClientImpl.java @@ -6,23 +6,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.ApiClient; import it.pagopa.interop.generated.openapi.clients.bff.api.AttributesApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.List; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class AttributeApiClientImpl implements IAttributeApiClient { private final AttributesApi attributesApi; private final RestTemplate restTemplate; private final InteropClientConfigs interopClientConfigs; private final String basePath; - private final String bearerToken; public AttributeApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.attributesApi = new AttributesApi(createApiClient(bearerToken)); + this.attributesApi = new AttributesApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/factory/SessionTokenFactory.java b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/factory/SessionTokenFactory.java index c2ceaffea..bf1273afb 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/factory/SessionTokenFactory.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/factory/SessionTokenFactory.java @@ -6,8 +6,13 @@ import com.google.gson.reflect.TypeToken; import it.pagopa.interop.authorization.domain.Tenant; import it.pagopa.interop.authorization.domain.ExternalId; +import it.pagopa.interop.authorization.service.utils.ConfigFileReader; import it.pagopa.interop.conf.springconfig.InteropClientConfigs; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.services.kms.KmsClient; import software.amazon.awssdk.services.kms.model.*; @@ -22,6 +27,8 @@ import java.util.*; @Slf4j +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) public class SessionTokenFactory { private static final Map> CONFIG = new HashMap<>(); private static final Map SESSION_TOKEN_PAYLOAD_TEMPLATE; @@ -61,9 +68,26 @@ public class SessionTokenFactory { } private final InteropClientConfigs interopClientConfigs; + @Getter + private Map> cachedTokens = null; + private ConfigFileReader configFileReader; - public SessionTokenFactory(InteropClientConfigs interopClientConfigs) { + + public SessionTokenFactory(InteropClientConfigs interopClientConfigs, ConfigFileReader configFileReader) { this.interopClientConfigs = interopClientConfigs; + this.configFileReader = configFileReader; + this.cachedTokens = loadToken(); + } + + private Map> loadToken() { + try { + if (cachedTokens == null) { + cachedTokens = generateSessionToken(configFileReader.getTenantList()); + } + } catch (Exception ex) { + throw new IllegalArgumentException("There was an error while creating the session token: " + ex.getMessage(), ex); + } + return cachedTokens; } public Map> generateSessionToken(List configFile) throws Exception { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/AuthorizationClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/AuthorizationClientImpl.java index 0bd37a5ea..447e4f4eb 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/AuthorizationClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/AuthorizationClientImpl.java @@ -4,6 +4,9 @@ import java.util.UUID; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import it.pagopa.interop.authorization.service.IAuthorizationClient; @@ -13,17 +16,17 @@ import it.pagopa.interop.generated.openapi.clients.bff.api.ClientsApi; import it.pagopa.interop.generated.openapi.clients.bff.api.PurposesApi; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class AuthorizationClientImpl implements IAuthorizationClient { private final ClientsApi clientsApi; private final RestTemplate restTemplate; private final String basePath; - private final String bearerToken; public AuthorizationClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "apiBearerToken"; - this.clientsApi = new ClientsApi(createApiClient(bearerToken)); + this.clientsApi = new ClientsApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/ProducerClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/ProducerClientImpl.java index 17b46898a..218a038aa 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/ProducerClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/impl/ProducerClientImpl.java @@ -5,23 +5,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.ApiClient; import it.pagopa.interop.generated.openapi.clients.bff.api.EservicesApi; import it.pagopa.interop.generated.openapi.clients.bff.model.ProducerEServiceDescriptor; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ProducerClientImpl implements IProducerClient { private final EservicesApi eservicesApi; private final RestTemplate restTemplate; private final InteropClientConfigs interopClientConfigs; private final String basePath; - private final String bearerToken; public ProducerClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "apiBearerToken"; - this.eservicesApi = new EservicesApi(createApiClient(bearerToken)); + this.eservicesApi = new EservicesApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/CommonUtils.java b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/CommonUtils.java index 500240300..2f5ee2c34 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/CommonUtils.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/CommonUtils.java @@ -2,71 +2,47 @@ import it.pagopa.interop.authorization.domain.Tenant; import it.pagopa.interop.authorization.service.factory.SessionTokenFactory; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import it.pagopa.interop.conf.springconfig.InteropClientConfigs; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; import java.util.*; import java.util.function.Predicate; import java.util.function.Supplier; @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Slf4j public class CommonUtils { private final SessionTokenFactory sessionTokenFactory; - private final KeyPairGeneratorUtil keyPairGeneratorUtil; - private final ClientTokenConfigurator clientTokenConfigurator; private final InteropClientConfigs interopClientConfigs; - private final List configFile; - - private Map> cachedTokens = null; + private final List tenantList; public CommonUtils(SessionTokenFactory sessionTokenFactory, KeyPairGeneratorUtil keyPairGeneratorUtil, - ClientTokenConfigurator clientTokenConfigurator, - InteropClientConfigs interopClientConfigs) { + InteropClientConfigs interopClientConfigs, + ConfigFileReader configFileReader) { this.sessionTokenFactory = sessionTokenFactory; - this.keyPairGeneratorUtil = keyPairGeneratorUtil; - this.clientTokenConfigurator = clientTokenConfigurator; this.interopClientConfigs = interopClientConfigs; - this.configFile = readProperty(); + this.tenantList = configFileReader.getTenantList(); } public String getToken(String tenantType, String role) { - try { - if (cachedTokens == null) { - cachedTokens = sessionTokenFactory.generateSessionToken(configFile); - } - } catch (Exception ex) { - throw new IllegalArgumentException("There was an error while creating the session token: " + ex.getMessage(), ex); - } - Map tenantTokens = cachedTokens.get(tenantType); - - String token = Optional.ofNullable(cachedTokens) + String token = Optional.ofNullable(sessionTokenFactory.getCachedTokens()) .map(m -> m.get(tenantType)) .filter(Objects::nonNull) .map(m -> (role == null) ? m.get("admin") : m.get(role)) .filter(Objects::nonNull) - .orElse(null); - - if (token == null) { - throw new IllegalArgumentException("Token not found for tenant: " + tenantType + " and role: " + role); - } + .orElseThrow(() -> new IllegalArgumentException("Token not found for tenant: " + tenantType + " and role: " + role)); return token; } - public void setBearerToken(String token) { - clientTokenConfigurator.setBearerToken(token); - } - public UUID getUserId(String tenantType, String role) { - return configFile.stream() + return tenantList.stream() .filter(tenant -> tenantType.equals(tenant.getName())) .map(Tenant::getUserRoles) .map(userRole -> userRole.get(role)) @@ -76,7 +52,7 @@ public UUID getUserId(String tenantType, String role) { } public UUID getOrganizationId(String tenantType) { - return configFile.stream() + return tenantList.stream() .filter(tenant -> tenantType.equals(tenant.getName())) .map(tenant -> tenant.getOrganizationId()) .map(o -> o.get("dev")) @@ -105,18 +81,4 @@ public void makePolling(Supplier promise, Predicate shouldStop, String throw new IllegalArgumentException("Eventual consistency error: " + errorMessage); } - private List readProperty() { - InputStream inputStream = null; - List tenantList = new ArrayList<>(); - try { - inputStream = new FileInputStream(new File("config/tenants-ids.yaml")); - Yaml yaml = new Yaml(new Constructor(Tenant.class)); - yaml.loadAll(inputStream).forEach(i -> tenantList.add((Tenant) i)); - } catch (Exception e) { - throw new RuntimeException(e); - } - return tenantList; - } - - } diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ConfigFileReader.java b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ConfigFileReader.java new file mode 100644 index 000000000..c95a833de --- /dev/null +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ConfigFileReader.java @@ -0,0 +1,38 @@ +package it.pagopa.interop.authorization.service.utils; + +import it.pagopa.interop.authorization.domain.Tenant; +import lombok.Getter; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.constructor.Constructor; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@Component +@Getter +public class ConfigFileReader { + private final List tenantList; + + public ConfigFileReader() { + this.tenantList = readProperty(); + } + + private List readProperty() { + String filePath = "config/tenants-ids.yaml"; + List tenantList = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + Yaml yaml = new Yaml(new Constructor(Tenant.class)); + yaml.loadAll(reader).forEach(i -> tenantList.add((Tenant) i)); + } catch (IOException exception) { + exception.printStackTrace(); + } + return tenantList; + } + +} diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/DelegationApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/DelegationApiClientImpl.java index 139c63c71..926100a65 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/DelegationApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/DelegationApiClientImpl.java @@ -5,23 +5,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.ApiClient; import it.pagopa.interop.generated.openapi.clients.bff.api.DelegationsApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.io.File; import java.util.List; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DelegationApiClientImpl implements IDelegationApiClient { private final DelegationsApi delegationsApi; private final RestTemplate restTemplate; private final String basePath; - private final String bearerToken; public DelegationApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.delegationsApi = new DelegationsApi(createApiClient(bearerToken)); + this.delegationsApi = new DelegationsApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/ProducerDelegationsApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/ProducerDelegationsApiClientImpl.java index ae1b3c0de..73567754b 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/ProducerDelegationsApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/delegate/service/impl/ProducerDelegationsApiClientImpl.java @@ -7,21 +7,24 @@ import it.pagopa.interop.generated.openapi.clients.bff.model.CreatedResource; import it.pagopa.interop.generated.openapi.clients.bff.model.DelegationSeed; import it.pagopa.interop.generated.openapi.clients.bff.model.RejectDelegationPayload; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ProducerDelegationsApiClientImpl implements IProducerDelegationsApiClient { private final ProducerDelegationsApi producerDelegationsApi; private final RestTemplate restTemplate; private final String basePath; - private final String bearerToken; public ProducerDelegationsApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.producerDelegationsApi = new ProducerDelegationsApi(createApiClient(bearerToken)); + this.producerDelegationsApi = new ProducerDelegationsApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/purpose/service/impl/PurposeApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/purpose/service/impl/PurposeApiClientImpl.java index 936c60ae2..310be1cfc 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/purpose/service/impl/PurposeApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/purpose/service/impl/PurposeApiClientImpl.java @@ -6,23 +6,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.api.PurposesApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; import it.pagopa.interop.purpose.service.IPurposeApiClient; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PurposeApiClientImpl implements IPurposeApiClient { private final PurposesApi purposesApi; private final RestTemplate restTemplate; private final String basePath; - private final String bearerToken; private final InteropClientConfigs interopClientConfigs; public PurposeApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.purposesApi = new PurposesApi(createApiClient(bearerToken)); + this.purposesApi = new PurposesApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/tenant/service/impl/TenantsApiClientImpl.java b/interop-qa-tests/src/main/java/it/pagopa/interop/tenant/service/impl/TenantsApiClientImpl.java index dd4e0f29d..d041b989c 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/tenant/service/impl/TenantsApiClientImpl.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/tenant/service/impl/TenantsApiClientImpl.java @@ -6,23 +6,26 @@ import it.pagopa.interop.generated.openapi.clients.bff.api.TenantsApi; import it.pagopa.interop.generated.openapi.clients.bff.model.*; import it.pagopa.interop.tenant.service.ITenantsApi; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import java.util.UUID; +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TenantsApiClientImpl implements ITenantsApi { private final TenantsApi tenantsApi; private final RestTemplate restTemplate; private final InteropClientConfigs interopClientConfigs; private final String basePath; - private final String bearerToken; public TenantsApiClientImpl(RestTemplate restTemplate, InteropClientConfigs interopClientConfigs) { this.restTemplate = restTemplate; this.interopClientConfigs = interopClientConfigs; this.basePath = interopClientConfigs.getBaseUrl(); - this.bearerToken = "bearerToken"; - this.tenantsApi = new TenantsApi(createApiClient(bearerToken)); + this.tenantsApi = new TenantsApi(createApiClient("dummyBearer")); } private ApiClient createApiClient(String bearerToken) { diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/utils/HttpCallExecutor.java b/interop-qa-tests/src/main/java/it/pagopa/interop/utils/HttpCallExecutor.java index 990a8cfbd..cef5e2ffd 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/utils/HttpCallExecutor.java +++ b/interop-qa-tests/src/main/java/it/pagopa/interop/utils/HttpCallExecutor.java @@ -1,6 +1,7 @@ package it.pagopa.interop.utils; import lombok.Data; +import lombok.Getter; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.http.HttpStatus; @@ -9,8 +10,8 @@ import java.util.function.Supplier; -@Data @Component +@Getter @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class HttpCallExecutor { private HttpStatus clientResponse; diff --git a/interop-qa-tests/src/main/resources/junit-platform.properties b/interop-qa-tests/src/main/resources/junit-platform.properties new file mode 100644 index 000000000..19ee1aaad --- /dev/null +++ b/interop-qa-tests/src/main/resources/junit-platform.properties @@ -0,0 +1,7 @@ +cucumber.execution.parallel.enabled=true +cucumber.execution.parallel.config.strategy=fixed +#One for each feature file +#cucumber.execution.parallel.config.fixed.parallelism=39 +cucumber.execution.parallel.config.fixed.parallelism=10 +cucumber.execution.execution-mode.feature=same_thread + diff --git a/interop-qa-tests/src/main/resources/qa-interop.properties b/interop-qa-tests/src/main/resources/qa-interop.properties index 05f147b16..30f83206b 100644 --- a/interop-qa-tests/src/main/resources/qa-interop.properties +++ b/interop-qa-tests/src/main/resources/qa-interop.properties @@ -3,4 +3,4 @@ remote-wellknown-url=https://qa.interop.pagopa.it/.well-known/jwks.json session.tokens.duration.seconds=3000 interop-env=qa max-polling-try-ms=50 -max-polling-sleep-ms=100 \ No newline at end of file +max-polling-sleep-ms=1000 \ No newline at end of file diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/CapofilaTest.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/CapofilaTest.java index fb92ffd0b..39079830e 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/CapofilaTest.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/CapofilaTest.java @@ -12,7 +12,7 @@ @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/cucumber-report.json," + "html:target/cucumber-report.html"), @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "it.pagopa.pn.interop.cucumber.steps"), - @ConfigurationParameter(key = EXECUTION_MODE_FEATURE_PROPERTY_NAME, value = "concurrent"), + @ConfigurationParameter(key = EXECUTION_MODE_FEATURE_PROPERTY_NAME, value = "same_thread"), }) @ExcludeTags({"wait_for_fix"}) @IncludeTags({"capofila"}) diff --git a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ClientTokenConfigurator.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/ClientTokenConfigurator.java similarity index 76% rename from interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ClientTokenConfigurator.java rename to interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/ClientTokenConfigurator.java index acaca22d7..28e7d4470 100644 --- a/interop-qa-tests/src/main/java/it/pagopa/interop/authorization/service/utils/ClientTokenConfigurator.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/ClientTokenConfigurator.java @@ -1,5 +1,6 @@ -package it.pagopa.interop.authorization.service.utils; +package it.pagopa.pn.interop.cucumber.steps; +import io.cucumber.spring.ScenarioScope; import it.pagopa.interop.agreement.service.IAgreementClient; import it.pagopa.interop.agreement.service.IEServiceClient; import it.pagopa.interop.attribute.service.IAttributeApiClient; @@ -10,7 +11,14 @@ import it.pagopa.interop.purpose.service.IPurposeApiClient; import it.pagopa.interop.tenant.service.ITenantsApi; import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +@Getter +@Component +@ScenarioScope @AllArgsConstructor public class ClientTokenConfigurator { private IAuthorizationClient authorizationClient; @@ -20,7 +28,7 @@ public class ClientTokenConfigurator { private IEServiceClient eServiceClient; private IProducerClient producerClient; private IPurposeApiClient purposeApiClient; - private IProducerDelegationsApiClient delegationsApiClient; + private IProducerDelegationsApiClient producerDelegationsApiClient; private IDelegationApiClient delegationApiClient; public void setBearerToken(String token) { @@ -31,7 +39,7 @@ public void setBearerToken(String token) { eServiceClient.setBearerToken(token); producerClient.setBearerToken(token); purposeApiClient.setBearerToken(token); - delegationsApiClient.setBearerToken(token); + producerDelegationsApiClient.setBearerToken(token); delegationApiClient.setBearerToken(token); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/DataPreparationService.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/DataPreparationService.java index 875af60ac..08baa87f6 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/DataPreparationService.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/DataPreparationService.java @@ -33,9 +33,9 @@ import static it.pagopa.interop.generated.openapi.clients.bff.model.EServiceMode.RECEIVE; @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public class DataPreparationService { private static final ClientSeed DEFAULT_CLIENT_SEED = new ClientSeed(); + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final IAgreementClient agreementClient; private final IAttributeApiClient attributeApiClient; @@ -54,28 +54,22 @@ public class DataPreparationService { DEFAULT_CLIENT_SEED.setMembers(List.of()); } - public DataPreparationService(IAuthorizationClient authorizationClient, - IAgreementClient agreementClient, - IAttributeApiClient attributeApiClient, - ITenantsApi tenantsApi, - IEServiceClient eServiceClient, - IProducerClient producerClient, - IPurposeApiClient purposeApiClient, - HttpCallExecutor httpCallExecutor, + public DataPreparationService(ClientTokenConfigurator clientTokenConfigurator, CommonUtils commonUtils, RiskAnalysisDataInitializer riskAnalysisDataInitializer, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; - this.agreementClient = agreementClient; - this.attributeApiClient = attributeApiClient; - this.tenantsApi = tenantsApi; - this.eServiceClient = eServiceClient; - this.producerClient = producerClient; - this.purposeApiClient = purposeApiClient; - this.httpCallExecutor = httpCallExecutor; - this.commonUtils = commonUtils; - this.riskAnalysisDataInitializer = riskAnalysisDataInitializer; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); + this.agreementClient = clientTokenConfigurator.getAgreementClient(); + this.attributeApiClient = clientTokenConfigurator.getAttributeApiClient(); + this.tenantsApi = clientTokenConfigurator.getTenantsApi(); + this.eServiceClient = clientTokenConfigurator.getEServiceClient(); + this.producerClient = clientTokenConfigurator.getProducerClient(); + this.purposeApiClient = clientTokenConfigurator.getPurposeApiClient(); this.sharedStepsContext = sharedStepsContext; + this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); + this.commonUtils = sharedStepsContext.getCommonUtils(); + this.riskAnalysisDataInitializer = riskAnalysisDataInitializer; } public UUID createClient(String clientKind, ClientSeed partialClientSeed) { @@ -105,7 +99,11 @@ public void addMemberToClient(UUID clientId, UUID userId) { assertValidResponse(); commonUtils.makePolling( () -> httpCallExecutor.performCall(() -> authorizationClient.getClientUsers(sharedStepsContext.getXCorrelationId(), clientId)), - res -> ((List) httpCallExecutor.getResponse()).stream().anyMatch(user -> user.getUserId().equals(userId)), + res -> Optional.ofNullable(httpCallExecutor.getResponse()) + .map(obj -> (List) obj) + .orElse(List.of()) + .stream() + .anyMatch(user -> user.getUserId().equals(userId)), "Failed to retrieve the client users list!" ); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/InteropCucumberSpringIntegration.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/InteropCucumberSpringIntegration.java index b698e612d..c537834ad 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/InteropCucumberSpringIntegration.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/InteropCucumberSpringIntegration.java @@ -8,7 +8,7 @@ import it.pagopa.interop.attribute.service.IAttributeApiClient; import it.pagopa.interop.attribute.service.impl.AttributeApiClientImpl; import it.pagopa.interop.authorization.service.IAuthorizationClient; -import it.pagopa.interop.authorization.service.utils.ClientTokenConfigurator; +import it.pagopa.interop.authorization.service.utils.ConfigFileReader; import it.pagopa.interop.conf.springconfig.InteropClientConfigs; import it.pagopa.interop.config.springconfig.springconfig.InteropRestTemplateConfiguration; import it.pagopa.interop.authorization.service.impl.AuthorizationClientImpl; @@ -52,7 +52,8 @@ RiskAnalysisDataInitializer.class, ClientTokenConfigurator.class, ProducerDelegationsApiClientImpl.class, - DelegationApiClientImpl.class + DelegationApiClientImpl.class, + ConfigFileReader.class }) @EnableScheduling diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/SharedStepsContext.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/SharedStepsContext.java index 36efb582c..6d5e65ce6 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/SharedStepsContext.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/SharedStepsContext.java @@ -9,6 +9,7 @@ import it.pagopa.pn.interop.cucumber.steps.common.PurposeCommonContext; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -18,12 +19,11 @@ @Getter @Setter +@Slf4j @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class SharedStepsContext { private HttpCallExecutor httpCallExecutor; private CommonUtils commonUtils; - - private int testSeed; private String tenantType; private String userToken; diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementActivateSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementActivateSteps.java index 751060b27..448fde810 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementActivateSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementActivateSteps.java @@ -4,6 +4,7 @@ import it.pagopa.interop.agreement.domain.EServiceDescriptor; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; @@ -12,12 +13,15 @@ import java.util.UUID; public class AgreementActivateSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final DataPreparationService dataPreparationService; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; - public AgreementActivateSteps(DataPreparationService dataPreparationService, + public AgreementActivateSteps(ClientTokenConfigurator clientTokenConfigurator, + DataPreparationService dataPreparationService, SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.dataPreparationService = dataPreparationService; this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -25,7 +29,7 @@ public AgreementActivateSteps(DataPreparationService dataPreparationService, @Given("{string} ha già approvato quella richiesta di fruizione") public void tenantHasAlreadyAcceptedThatRequest(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); dataPreparationService.activateAgreement(sharedStepsContext.getAgreementId(), null); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCommonSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCommonSteps.java index dde865e63..f8d0709d6 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCommonSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCommonSteps.java @@ -4,6 +4,7 @@ import it.pagopa.interop.agreement.domain.EServiceDescriptor; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.*; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.common.EServicesCommonContext; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; @@ -12,21 +13,23 @@ import java.util.concurrent.ThreadLocalRandom; public class AgreementCommonSteps { + private ClientTokenConfigurator clientTokenConfigurator; private DataPreparationService dataPreparationService; private CommonUtils commonUtils; private SharedStepsContext sharedStepsContext; - public AgreementCommonSteps(DataPreparationService dataPreparationService, - CommonUtils commonUtils, - SharedStepsContext sharedStepsContext) { + public AgreementCommonSteps(ClientTokenConfigurator clientTokenConfigurator, + DataPreparationService dataPreparationService, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.dataPreparationService = dataPreparationService; - this.commonUtils = commonUtils; this.sharedStepsContext = sharedStepsContext; + this.commonUtils = sharedStepsContext.getCommonUtils(); } @Given("{string} ha una richiesta di fruizione in stato {string} per quell'e-service") public void tenantAlreadyHasFruitionRequestWithState(String tenant, String agreementState) { - commonUtils.setBearerToken(commonUtils.getToken(tenant, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenant, null)); UUID agreementId = dataPreparationService.createAgreementWithGivenState( AgreementState.fromValue(agreementState), sharedStepsContext.getEServicesCommonContext().getEserviceId(), @@ -45,7 +48,7 @@ public void tenantHasCreatedCertifiedAttribute(String certifier, String tenantTy @Given("{string} ha già creato e pubblicato {int} e-service(s)") public void tenantHasAlreadyCreatedAndPublishedEService(String tenantType, int totalEservices) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); // Create e-services and publish descriptors EServicesCommonContext eServicesCommonContext = sharedStepsContext.getEServicesCommonContext(); for (int i = 0; i < totalEservices; i++) { @@ -72,7 +75,7 @@ public void tenantHasAlreadyCreatedAndPublishedEService(String tenantType, int t @Given("{string} ha già creato un e-service in stato {string} con approvazione {string}") public void tenantHasAlreadyCreatedEServiceWithStatusAndApproval(String tenantType, String descriptorState, String agreementApprovalPolicy) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); EServiceDescriptor eServiceDescriptor = dataPreparationService.createEServiceAndDraftDescriptor(new EServiceSeed(), new UpdateEServiceDescriptorSeed().agreementApprovalPolicy(AgreementApprovalPolicy.valueOf(agreementApprovalPolicy))); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCreationStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCreationStep.java index f81c5ed3e..3a1c1b103 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCreationStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/agreement/AgreementCreationStep.java @@ -3,18 +3,22 @@ import io.cucumber.java.en.Given; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.AgreementState; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; import java.util.UUID; public class AgreementCreationStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final DataPreparationService dataPreparationService; - public AgreementCreationStep(SharedStepsContext sharedStepsContext, + public AgreementCreationStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext, DataPreparationService dataPreparationService) { + this.clientTokenConfigurator = clientTokenConfigurator; this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.dataPreparationService = dataPreparationService; @@ -22,13 +26,13 @@ public AgreementCreationStep(SharedStepsContext sharedStepsContext, @Given("{string} ha già rifiutato quella richiesta di fruizione") public void tenantHasDeclinedThatRequest(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); dataPreparationService.rejectAgreement(sharedStepsContext.getAgreementId()); } @Given("{string} ha già creato e inviato una richiesta di fruizione per quell'e-service ed è in attesa di approvazione") public void requestForServiceAlreadySubmittedAndPendingApproval(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); UUID agreementId = dataPreparationService.createAgreement(sharedStepsContext.getEServicesCommonContext().getEserviceId(), sharedStepsContext.getEServicesCommonContext().getDescriptorId()); sharedStepsContext.setAgreementId(agreementId); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCommonSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCommonSteps.java index a8d2095e8..070709dd5 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCommonSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCommonSteps.java @@ -8,11 +8,13 @@ import it.pagopa.interop.generated.openapi.clients.bff.model.PurposeAdditionDetailsSeed; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.authorization.service.utils.KeyPairGeneratorUtil; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +26,9 @@ @Getter @Setter +@Slf4j public class ClientCommonSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final DataPreparationService dataPreparationService; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; @@ -33,8 +37,10 @@ public class ClientCommonSteps { private PurposeAdditionDetailsSeed purposeAdditionDetailsSeed; @Autowired - public ClientCommonSteps(DataPreparationService dataPreparationService, + public ClientCommonSteps(ClientTokenConfigurator clientTokenConfigurator, + DataPreparationService dataPreparationService, SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.dataPreparationService = dataPreparationService; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -43,7 +49,7 @@ public ClientCommonSteps(DataPreparationService dataPreparationService, @Given("{string} ha già creato {int} client {string}") public void createClientsForTenants(String tenantType, int numClient, String clientKind) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); List clientIds = IntStream.range(0, numClient) .mapToObj(i -> dataPreparationService.createClient(clientKind, createClientSeed(i))) @@ -53,7 +59,7 @@ public void createClientsForTenants(String tenantType, int numClient, String cli @Given("{string} ha già inserito l'utente con ruolo {string} come membro di quel client") public void tenantHasAlreadyAddUsersWithRole(String tenantType, String roleOfMemberToAdd) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); UUID clientMemberUserId = commonUtils.getUserId(tenantType, roleOfMemberToAdd); dataPreparationService.addMemberToClient(sharedStepsContext.getClientCommonContext().getFirstClient(), clientMemberUserId); sharedStepsContext.getClientCommonContext().setUsers(List.of(clientMemberUserId)); @@ -67,7 +73,7 @@ public void verifyStatusCodeAndClientList(int statusCode, int count) { @Given("un {string} di {string} ha caricato una chiave pubblica in quel client") public void roleOfTenantHasAlreadyUploadClientPublicKey(String role, String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, role)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, role)); String userPublicKey = KeyPairGeneratorUtil.createBase64PublicKey("RSA", 2048); sharedStepsContext.getClientCommonContext().setClientPublicKey(userPublicKey); String keyId = dataPreparationService.addPublicKeyToClient(sharedStepsContext.getClientCommonContext().getFirstClient(), KeyPairGeneratorUtil.createKeySeed(KeyUse.SIG, "RS256", userPublicKey).get(0)); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCreateStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCreateStep.java index 156d042d6..7f7fac54d 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCreateStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientCreateStep.java @@ -2,21 +2,24 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.generated.openapi.clients.bff.model.ClientSeed; import it.pagopa.interop.authorization.service.IAuthorizationClient; import it.pagopa.interop.authorization.service.utils.CommonUtils; -import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; import it.pagopa.interop.utils.HttpCallExecutor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import java.util.List; import java.util.Random; +@Slf4j public class ClientCreateStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClientCreate; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; @@ -24,9 +27,10 @@ public class ClientCreateStep { private ResponseEntity createClientResponse; - public ClientCreateStep(IAuthorizationClient authorizationClientCreate, + public ClientCreateStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClientCreate = authorizationClientCreate; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClientCreate = clientTokenConfigurator.getAuthorizationClient(); this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.sharedStepsContext = sharedStepsContext; @@ -35,7 +39,7 @@ public ClientCreateStep(IAuthorizationClient authorizationClientCreate, @Given("l'utente è un {string} di {string}") public void setRole(String role, String tenantType) { String token = commonUtils.getToken(tenantType, role); - commonUtils.setBearerToken(token); + clientTokenConfigurator.setBearerToken(token); sharedStepsContext.setUserToken(token); sharedStepsContext.setTenantType(tenantType); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientDeleteSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientDeleteSteps.java index 0fd2d7664..48f4b0475 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientDeleteSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientDeleteSteps.java @@ -2,19 +2,22 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientDeleteSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClientCreate; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientDeleteSteps(IAuthorizationClient authorizationClientCreate, + public ClientDeleteSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClientCreate = authorizationClientCreate; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClientCreate = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -22,7 +25,7 @@ public ClientDeleteSteps(IAuthorizationClient authorizationClientCreate, @When("l'utente richiede una operazione di cancellazione di quel client") public void deleteClient() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClientCreate.deleteClient(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient())); } } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyContentReadSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyContentReadSteps.java index 4ef2ec290..a524d93e0 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyContentReadSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyContentReadSteps.java @@ -2,19 +2,22 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientKeyContentReadSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientKeyContentReadSteps(IAuthorizationClient authorizationClient, + public ClientKeyContentReadSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -22,7 +25,7 @@ public ClientKeyContentReadSteps(IAuthorizationClient authorizationClient, @When("l'utente richiede la lettura del contenuto della chiave pubblica") public void readPublicKey() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.getEncodedClientKeyById(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), sharedStepsContext.getClientCommonContext().getKeyId())); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyDeleteSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyDeleteSteps.java index 34643c23b..786dfd1c7 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyDeleteSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyDeleteSteps.java @@ -3,6 +3,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; @@ -10,14 +11,16 @@ import java.util.UUID; public class ClientKeyDeleteSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; - public ClientKeyDeleteSteps(IAuthorizationClient authorizationClient, + public ClientKeyDeleteSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -30,7 +33,7 @@ public void removeClientMemberByRole(String tenantType, String role) { @When("l'utente richiede una operazione di cancellazione della chiave di quel client") public void deleteClientKeyById() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.deleteClientKeyById(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), sharedStepsContext.getClientCommonContext().getKeyId())); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyListingSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyListingSteps.java index 727574857..a8dc12f91 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyListingSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyListingSteps.java @@ -2,6 +2,7 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.generated.openapi.clients.bff.model.PublicKeys; import it.pagopa.interop.authorization.service.IAuthorizationClient; import it.pagopa.interop.authorization.service.utils.CommonUtils; @@ -12,14 +13,16 @@ import java.util.List; public class ClientKeyListingSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; - public ClientKeyListingSteps(IAuthorizationClient authorizationClient, + public ClientKeyListingSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyReadSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyReadSteps.java index dc2ee07c6..985a0e75b 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyReadSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyReadSteps.java @@ -3,6 +3,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.When; import it.pagopa.interop.authorization.domain.KeyPairPEM; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.generated.openapi.clients.bff.model.KeyUse; import it.pagopa.interop.authorization.service.IAuthorizationClient; import it.pagopa.interop.authorization.service.utils.CommonUtils; @@ -14,16 +15,18 @@ public class ClientKeyReadSteps { private static final long MAX_SAFE_INTEGER = 9007199254740991L; + private ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; private final DataPreparationService dataPreparationService; - public ClientKeyReadSteps(IAuthorizationClient authorizationClient, + public ClientKeyReadSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext, DataPreparationService dataPreparationService) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -32,7 +35,7 @@ public ClientKeyReadSteps(IAuthorizationClient authorizationClient, @Given("un {string} di {string} ha caricato una chiave pubblica nel client") public void clientPublicKeyUpload(String role, String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, role)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, role)); KeyPairPEM keyPairPEM = KeyPairGeneratorUtil.createKeyPairPEM("RSA", 2048); String key = KeyPairGeneratorUtil.keyToBase64(keyPairPEM.getPublicKey(), true); sharedStepsContext.getClientCommonContext().setClientPublicKey(key); @@ -42,7 +45,7 @@ public void clientPublicKeyUpload(String role, String tenantType) { @When("l'utente richiede la lettura della chiave pubblica") public void userReadPublicKey() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.getClientKeyById(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyUploadSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyUploadSteps.java index 8715ba476..4134b73f5 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyUploadSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientKeyUploadSteps.java @@ -1,6 +1,7 @@ package it.pagopa.pn.interop.cucumber.steps.authorization; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.KeyUse; import it.pagopa.interop.authorization.service.IAuthorizationClient; @@ -9,14 +10,16 @@ import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientKeyUploadSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientKeyUploadSteps(IAuthorizationClient authorizationClient, + public ClientKeyUploadSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -24,7 +27,7 @@ public ClientKeyUploadSteps(IAuthorizationClient authorizationClient, @When("l'utente richiede il caricamento di una chiave pubblica di tipo {string}") public void userLoadsPublicKeyWithType(String keyType) { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.createKeys(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), KeyPairGeneratorUtil.createKeySeed(KeyUse.SIG, "RS256", KeyPairGeneratorUtil.createBase64PublicKey(keyType, 2048)))); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientListingSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientListingSteps.java index 362de9949..9507da572 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientListingSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientListingSteps.java @@ -2,6 +2,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.generated.openapi.clients.bff.model.ClientKind; import it.pagopa.interop.generated.openapi.clients.bff.model.ClientSeed; import it.pagopa.interop.authorization.service.IAuthorizationClient; @@ -16,16 +17,18 @@ import java.util.concurrent.ThreadLocalRandom; public class ClientListingSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final CommonUtils commonUtils; private final DataPreparationService dataPreparationService; private final HttpCallExecutor httpCallExecutor; private final SharedStepsContext sharedStepsContext; - public ClientListingSteps(IAuthorizationClient authorizationClient, + public ClientListingSteps(ClientTokenConfigurator clientTokenConfigurator, DataPreparationService dataPreparationService, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.commonUtils = sharedStepsContext.getCommonUtils(); this.dataPreparationService = dataPreparationService; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -70,7 +73,7 @@ public void retrieveClientsListByFilterForUserAndRole(String role) { @When("l'utente richiede una operazione di listing dei client") public void retrieveClientsList() { - commonUtils.setBearerToken(commonUtils.getToken(sharedStepsContext.getTenantType(), null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(sharedStepsContext.getTenantType(), null)); httpCallExecutor.performCall(() -> authorizationClient.getClients(sharedStepsContext.getXCorrelationId(), 0, 12, String.valueOf(sharedStepsContext.getTestSeed()), null, null)); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeAddSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeAddSteps.java index fe64ce595..c15ee3ed9 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeAddSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeAddSteps.java @@ -2,6 +2,7 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.PurposeAdditionDetailsSeed; import it.pagopa.interop.utils.HttpCallExecutor; @@ -10,14 +11,16 @@ import java.util.UUID; public class ClientPurposeAddSteps { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final HttpCallExecutor httpCallExecutor; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; - public ClientPurposeAddSteps(IAuthorizationClient authorizationClient, + public ClientPurposeAddSteps(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -25,7 +28,7 @@ public ClientPurposeAddSteps(IAuthorizationClient authorizationClient, @When("l'utente richiede l'associazione della finalità al client") public void userRetrievesFinalization() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.addClientPurpose(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), new PurposeAdditionDetailsSeed().purposeId(UUID.fromString(sharedStepsContext.getPurposeCommonContext().getPurposeId()))) diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeRemoveStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeRemoveStep.java index 5c2d79b46..49a48547a 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeRemoveStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientPurposeRemoveStep.java @@ -3,6 +3,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.pn.interop.cucumber.steps.common.PurposeCommonContext; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; @@ -13,16 +14,18 @@ public class ClientPurposeRemoveStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final DataPreparationService dataPreparationService; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientPurposeRemoveStep(IAuthorizationClient authorizationClient, + public ClientPurposeRemoveStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext, DataPreparationService dataPreparationService) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.dataPreparationService = dataPreparationService; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -31,7 +34,7 @@ public ClientPurposeRemoveStep(IAuthorizationClient authorizationClient, @Given("{string} ha già associato la finalità a quel client") public void addPurposeToClient(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); httpCallExecutor .performCall(() -> dataPreparationService.addPurposeToClient(sharedStepsContext.getClientCommonContext().getFirstClient(), UUID.fromString(sharedStepsContext.getPurposeCommonContext().getPurposeId()))); @@ -39,7 +42,7 @@ public void addPurposeToClient(String tenantType) { @Given("{string} ha già archiviato quella finalità") public void archivePurpose(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); PurposeCommonContext purposeCommonContext = sharedStepsContext.getPurposeCommonContext(); httpCallExecutor.performCall(() -> dataPreparationService.archivePurpose(UUID.fromString(purposeCommonContext.getPurposeId()), UUID.fromString(purposeCommonContext.getVersionId()))); @@ -47,7 +50,7 @@ public void archivePurpose(String tenantType) { @When("l'utente richiede la disassociazione della finalità dal client") public void getClientUsers() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.removeClientPurpose(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), UUID.fromString(sharedStepsContext.getPurposeCommonContext().getPurposeId()))); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientReadStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientReadStep.java index e5bfc6182..25e450351 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientReadStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientReadStep.java @@ -2,20 +2,23 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientReadStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientReadStep(IAuthorizationClient authorizationClient, - SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + public ClientReadStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -23,7 +26,7 @@ public ClientReadStep(IAuthorizationClient authorizationClient, @When("l'utente richiede una operazione di lettura di quel client") public void getClient() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.getClient(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient())); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserAddStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserAddStep.java index d8b800caa..52a790819 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserAddStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserAddStep.java @@ -4,22 +4,23 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; -import it.pagopa.interop.generated.openapi.clients.bff.model.InlineObject2; import it.pagopa.interop.generated.openapi.clients.bff.model.InlineObject3; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientUserAddStep { - + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; - public ClientUserAddStep(IAuthorizationClient authorizationClient, + public ClientUserAddStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -27,7 +28,7 @@ public ClientUserAddStep(IAuthorizationClient authorizationClient, @When("l'utente richiede l'aggiunta di un admin di {string} al client") public void addUsersToClient(String tenantType) { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); UUID userId = commonUtils.getUserId(tenantType, "admin"); InlineObject3 inlineObject = new InlineObject3().addUserIdsItem(userId); httpCallExecutor.performCall( diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserRemoveStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserRemoveStep.java index c1707b0d2..5c267155d 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserRemoveStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUserRemoveStep.java @@ -2,20 +2,22 @@ import io.cucumber.java.en.When; import it.pagopa.interop.authorization.service.IAuthorizationClient; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; public class ClientUserRemoveStep { - + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientUserRemoveStep(IAuthorizationClient authorizationClient, - SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + public ClientUserRemoveStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -23,7 +25,7 @@ public ClientUserRemoveStep(IAuthorizationClient authorizationClient, @When("l'utente richiede la rimozione di quel membro dal client") public void removeUserFromClient() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor.performCall(() -> authorizationClient.removeUserFromClient(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient(), sharedStepsContext.getClientCommonContext().getFirstUser())); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUsersListingStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUsersListingStep.java index 7d859f0c6..f2315fc61 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUsersListingStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/authorization/ClientUsersListingStep.java @@ -2,6 +2,7 @@ import java.util.List; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; import org.junit.jupiter.api.Assertions; @@ -14,14 +15,16 @@ public class ClientUsersListingStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IAuthorizationClient authorizationClient; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final CommonUtils commonUtils; - public ClientUsersListingStep(IAuthorizationClient authorizationClient, - SharedStepsContext sharedStepsContext) { - this.authorizationClient = authorizationClient; + public ClientUsersListingStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; + this.authorizationClient = clientTokenConfigurator.getAuthorizationClient(); this.sharedStepsContext = sharedStepsContext; this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.commonUtils = sharedStepsContext.getCommonUtils(); @@ -29,7 +32,7 @@ public ClientUsersListingStep(IAuthorizationClient authorizationClient, @When("l'utente richiede una operazione di listing dei membri di quel client") public void getClientUsers() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); httpCallExecutor .performCall(() -> authorizationClient.getClientUsers(sharedStepsContext.getXCorrelationId(), sharedStepsContext.getClientCommonContext().getFirstClient())); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationAcceptStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationAcceptStep.java index e6394f804..536d73321 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationAcceptStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationAcceptStep.java @@ -1,6 +1,7 @@ package it.pagopa.pn.interop.cucumber.steps.delegate; import io.cucumber.java.en.And; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.delegate.service.IDelegationApiClient; import it.pagopa.interop.delegate.service.IProducerDelegationsApiClient; @@ -10,17 +11,20 @@ import org.springframework.http.HttpStatus; public class DelegationAcceptStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IProducerDelegationsApiClient producerDelegationsApiClient; private final IDelegationApiClient delegationApiClient; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; - public DelegationAcceptStep(IProducerDelegationsApiClient producerDelegationsApiClient, + public DelegationAcceptStep(ClientTokenConfigurator clientTokenConfigurator, + IProducerDelegationsApiClient producerDelegationsApiClient, IDelegationApiClient delegationApiClient, SharedStepsContext sharedStepsContext) { - this.producerDelegationsApiClient = producerDelegationsApiClient; - this.delegationApiClient = delegationApiClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.producerDelegationsApiClient = clientTokenConfigurator.getProducerDelegationsApiClient(); + this.delegationApiClient = clientTokenConfigurator.getDelegationApiClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -28,14 +32,14 @@ public DelegationAcceptStep(IProducerDelegationsApiClient producerDelegationsApi @And("l'utente accetta la delega") public void userAcceptTheDelegation() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); approveDelegation(); if (httpCallExecutor.getClientResponse() == HttpStatus.OK) waitUntilDelegationIsApprove(); } @And("l'ente {string} accetta la delega") public void delegationIsAcceptedByTenant(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); approveDelegation(); if (httpCallExecutor.getClientResponse() == HttpStatus.OK) waitUntilDelegationIsApprove(); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCommonStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCommonStep.java index 13046017e..f7c769a68 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCommonStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCommonStep.java @@ -2,6 +2,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.delegate.service.IDelegationApiClient; import it.pagopa.interop.tenant.service.ITenantsApi; @@ -13,29 +14,32 @@ @Slf4j public class DelegationCommonStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final SharedStepsContext sharedStepsContext; private final IDelegationApiClient delegationApiClient; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; private final ITenantsApi tenantsApi; - public DelegationCommonStep(SharedStepsContext sharedStepsContext, - IDelegationApiClient delegationApiClient, - ITenantsApi tenantsApi) { + public DelegationCommonStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.sharedStepsContext = sharedStepsContext; - this.delegationApiClient = delegationApiClient; + this.delegationApiClient = clientTokenConfigurator.getDelegationApiClient(); this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); - this.tenantsApi = tenantsApi; + this.tenantsApi = clientTokenConfigurator.getTenantsApi(); } @Given("l'ente {string} rimuove la disponibilità a ricevere deleghe") public void tenantRemoveDelegationAvailability(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); try { tenantsApi.deleteTenantDelegatedProducerFeature(); } catch (HttpClientErrorException.Conflict e) { log.info("No delegation availability defined for the given tenant!"); + } catch (Exception e) { + e.printStackTrace(); } } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCreateStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCreateStep.java index f0edb18e3..53f829140 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCreateStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationCreateStep.java @@ -3,6 +3,7 @@ import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.delegate.service.IDelegationApiClient; import it.pagopa.interop.delegate.service.IProducerDelegationsApiClient; @@ -20,6 +21,7 @@ @Slf4j public class DelegationCreateStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IProducerDelegationsApiClient producerDelegationsApiClient; private final IDelegationApiClient delegationApiClient; private final ITenantsApi tenantsApi; @@ -34,13 +36,12 @@ public enum DelegationRole { private final Map tenants = new EnumMap<>(DelegationCreateStep.DelegationRole.class); - public DelegationCreateStep(IProducerDelegationsApiClient producerDelegationsApiClient, - IDelegationApiClient delegationApiClient, - ITenantsApi tenantsApi, + public DelegationCreateStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.producerDelegationsApiClient = producerDelegationsApiClient; - this.delegationApiClient = delegationApiClient; - this.tenantsApi = tenantsApi; + this.clientTokenConfigurator = clientTokenConfigurator; + this.producerDelegationsApiClient = clientTokenConfigurator.getProducerDelegationsApiClient(); + this.delegationApiClient = clientTokenConfigurator.getDelegationApiClient(); + this.tenantsApi = clientTokenConfigurator.getTenantsApi(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -55,7 +56,7 @@ public void givenDelegatingTenant(DelegationCreateStep.DelegationRole delegation public void givenUserWithRole(DelegationCreateStep.DelegationRole delegationRole, String iamRole) { String tenantType = tenants.get(delegationRole); String token = commonUtils.getToken(tenantType, iamRole); - commonUtils.setBearerToken(token); + clientTokenConfigurator.setBearerToken(token); sharedStepsContext.setUserToken(token); sharedStepsContext.setTenantType(tenantType); } @@ -63,19 +64,19 @@ public void givenUserWithRole(DelegationCreateStep.DelegationRole delegationRole @Given("l'ente delegante ha inoltrato una richiesta di delega all'ente delegato") public void givenDelegatingTenantHasRequestedDelegation() { String delegatingTenantToken = commonUtils.getToken(tenants.get(DELEGATING), null); - commonUtils.setBearerToken(delegatingTenantToken); + clientTokenConfigurator.setBearerToken(delegatingTenantToken); createDelegate(tenants.get(DELEGATE)); } @And("l'utente concede la disponibilità a ricevere le deleghe") public void userGrantsDelegationAvailability() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); setDelegationAvailability(sharedStepsContext.getTenantType()); } @And("l'ente {string} concede la disponibilità a ricevere deleghe") public void tenantGrantsDelegationAvailability(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); setDelegationAvailability(tenantType); } @@ -93,13 +94,13 @@ private void setDelegationAvailability(String tenantType) { @And("l'ente {string} richiede la creazione di una delega per l'ente {string}") public void createDelegate(String delegatorTenantType, String tenantType) throws InterruptedException { - commonUtils.setBearerToken(commonUtils.getToken(delegatorTenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(delegatorTenantType, null)); createDelegate(tenantType); } @And("l'utente richiede la creazione di una delega per l'ente {string}") public void userRequestDelegationCreation(String tenantType) { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); createDelegate(tenantType); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationDenyStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationDenyStep.java index dfb1a576b..83515586a 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationDenyStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationDenyStep.java @@ -1,43 +1,27 @@ package it.pagopa.pn.interop.cucumber.steps.delegate; -import io.cucumber.java.ParameterType; import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import it.pagopa.interop.agreement.domain.EServiceDescriptor; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; -import it.pagopa.interop.delegate.service.IDelegationApiClient; import it.pagopa.interop.delegate.service.IProducerDelegationsApiClient; -import it.pagopa.interop.generated.openapi.clients.bff.model.CreatedResource; -import it.pagopa.interop.generated.openapi.clients.bff.model.DelegationSeed; -import it.pagopa.interop.generated.openapi.clients.bff.model.DelegationState; -import it.pagopa.interop.generated.openapi.clients.bff.model.EServiceDescriptorState; -import it.pagopa.interop.generated.openapi.clients.bff.model.EServiceSeed; import it.pagopa.interop.generated.openapi.clients.bff.model.RejectDelegationPayload; -import it.pagopa.interop.generated.openapi.clients.bff.model.UpdateEServiceDescriptorSeed; -import it.pagopa.interop.tenant.service.ITenantsApi; import it.pagopa.interop.utils.HttpCallExecutor; -import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; -import it.pagopa.pn.interop.cucumber.steps.common.EServicesCommonContext; -import java.util.EnumMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Assertions; @Slf4j public class DelegationDenyStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IProducerDelegationsApiClient producerDelegationsApiClient; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; - public DelegationDenyStep(IProducerDelegationsApiClient producerDelegationsApiClient, + public DelegationDenyStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.producerDelegationsApiClient = producerDelegationsApiClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.producerDelegationsApiClient = clientTokenConfigurator.getProducerDelegationsApiClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -46,13 +30,13 @@ public DelegationDenyStep(IProducerDelegationsApiClient producerDelegationsApiCl @When("l'utente rifiuta la delega") public void whenUserRejectsDelegation() { String authToken = sharedStepsContext.getUserToken(); - commonUtils.setBearerToken(authToken); + clientTokenConfigurator.setBearerToken(authToken); rejectDelegation(); } @And("l'ente {string} rifiuta la delega") public void delegationIsRejectedByTenant(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); rejectDelegation(); } @@ -65,7 +49,7 @@ private void rejectDelegation() { @And("l'ente {string} con ruolo {string} revoca la delega") public void delegationIsRevokedByTenantWithRole(String tenantType, String role) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, role)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, role)); httpCallExecutor.performCall( () -> producerDelegationsApiClient.revokeProducerDelegation(sharedStepsContext.getXCorrelationId(), String.valueOf(sharedStepsContext.getDelegationCommonContext().getDelegationId()))); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationListingStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationListingStep.java index 5a12e6a6c..786174d62 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationListingStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/delegate/DelegationListingStep.java @@ -2,6 +2,7 @@ import io.cucumber.java.en.And; import io.cucumber.java.en.Then; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.delegate.service.IDelegationApiClient; import it.pagopa.interop.generated.openapi.clients.bff.model.CompactDelegation; @@ -10,6 +11,7 @@ import it.pagopa.interop.generated.openapi.clients.bff.model.Pagination; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; +import lombok.AllArgsConstructor; import org.junit.jupiter.api.Assertions; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; @@ -21,16 +23,18 @@ @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class DelegationListingStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final SharedStepsContext sharedStepsContext; private final IDelegationApiClient delegationApiClient; private final CommonUtils commonUtils; private final HttpCallExecutor httpCallExecutor; private final List delegationList; - public DelegationListingStep(SharedStepsContext sharedStepsContext, - IDelegationApiClient delegationApiClient) { + public DelegationListingStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.sharedStepsContext = sharedStepsContext; - this.delegationApiClient = delegationApiClient; + this.delegationApiClient = clientTokenConfigurator.getDelegationApiClient(); this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); this.delegationList = new ArrayList<>(); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeActivationStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeActivationStep.java index 91283d520..aa516b256 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeActivationStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeActivationStep.java @@ -1,25 +1,30 @@ package it.pagopa.pn.interop.cucumber.steps.purpose; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.PurposeVersion; import it.pagopa.interop.generated.openapi.clients.bff.model.PurposeVersionState; import it.pagopa.interop.purpose.service.IPurposeApiClient; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; +import lombok.extern.slf4j.Slf4j; import java.util.Optional; import java.util.UUID; +@Slf4j public class PurposeActivationStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final IPurposeApiClient purposeApiClient; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; - public PurposeActivationStep(IPurposeApiClient purposeApiClient, + public PurposeActivationStep(ClientTokenConfigurator clientTokenConfigurator, SharedStepsContext sharedStepsContext) { - this.purposeApiClient = purposeApiClient; + this.clientTokenConfigurator = clientTokenConfigurator; + this.purposeApiClient = clientTokenConfigurator.getPurposeApiClient(); this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); @@ -27,7 +32,7 @@ public PurposeActivationStep(IPurposeApiClient purposeApiClient, @When("l'utente (ri)attiva la finalità in stato {string} per quell'e-service") public void userActivatesPurposeInStateForThatEService(String state) throws InterruptedException { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); String versionId = "WAITING_FOR_APPROVAL".equals(state) || "REJECTED".equals(state) ? sharedStepsContext.getPurposeCommonContext().getWaitingForApprovalVersionId() : sharedStepsContext.getPurposeCommonContext().getVersionId(); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeCommonStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeCommonStep.java index 438166920..170a5abeb 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeCommonStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeCommonStep.java @@ -6,6 +6,7 @@ import it.pagopa.interop.generated.openapi.clients.bff.model.PurposeVersionState; import it.pagopa.interop.purpose.domain.RiskAnalysis; import it.pagopa.interop.purpose.domain.TEServiceMode; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.pn.interop.cucumber.steps.common.PurposeCommonContext; import it.pagopa.pn.interop.cucumber.steps.DataPreparationService; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; @@ -15,13 +16,16 @@ import java.util.concurrent.ThreadLocalRandom; public class PurposeCommonStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final CommonUtils commonUtils; private final DataPreparationService dataPreparationService; private final SharedStepsContext sharedStepsContext; - public PurposeCommonStep(CommonUtils commonUtils, + public PurposeCommonStep(ClientTokenConfigurator clientTokenConfigurator, + CommonUtils commonUtils, DataPreparationService dataPreparationService, SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.commonUtils = commonUtils; this.dataPreparationService = dataPreparationService; this.sharedStepsContext = sharedStepsContext; @@ -29,7 +33,7 @@ public PurposeCommonStep(CommonUtils commonUtils, @Given("{string} ha già creato {int} finalità in stato {string} per quell'eservice") public void tenantHasAlreadyCreateFinalizationWithStatus(String tenantType, int n, String purposeVersionState) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); UUID consumerId = commonUtils.getOrganizationId(tenantType); RiskAnalysis riskAnalysis = dataPreparationService.getRiskAnalysis(tenantType, true); PurposeCommonContext purposeCommonContext = sharedStepsContext.getPurposeCommonContext(); @@ -58,7 +62,7 @@ public void tenantHasAlreadyCreateFinalizationWithStatus(String tenantType, int @Given("{string} ha già rifiutato l'aggiornamento della stima di carico per quella finalità") public void tenantHasAlreadyRejectedLoadEstimateUpdateForPurpose(String tenantType) { - commonUtils.setBearerToken(commonUtils.getToken(tenantType, null)); + clientTokenConfigurator.setBearerToken(commonUtils.getToken(tenantType, null)); PurposeCommonContext purposeCommonContext = sharedStepsContext.getPurposeCommonContext(); dataPreparationService.rejectPurposeVersion(UUID.fromString(purposeCommonContext.getPurposeId()), UUID.fromString(purposeCommonContext.getWaitingForApprovalVersionId())); } diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeRejectStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeRejectStep.java index 365c54f7f..4486d766c 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeRejectStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeRejectStep.java @@ -1,33 +1,34 @@ package it.pagopa.pn.interop.cucumber.steps.purpose; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; import it.pagopa.interop.generated.openapi.clients.bff.model.RejectPurposeVersionPayload; import it.pagopa.interop.purpose.service.IPurposeApiClient; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; -import it.pagopa.pn.interop.cucumber.steps.common.PurposeCommonContext; -import java.util.Optional; import java.util.UUID; public class PurposeRejectStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final HttpCallExecutor httpCallExecutor; private final IPurposeApiClient purposeApiClient; - public PurposeRejectStep(SharedStepsContext sharedStepsContext, - IPurposeApiClient purposeApiClient) { + public PurposeRejectStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.sharedStepsContext = sharedStepsContext; this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); - this.purposeApiClient = purposeApiClient; + this.purposeApiClient = clientTokenConfigurator.getPurposeApiClient(); } @When("l'utente rifiuta la finalità aggiungendo una motivazione") public void userRejectsPurposeWithReason() { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); String versionId = sharedStepsContext.getPurposeCommonContext().getWaitingForApprovalVersionId() != null ? sharedStepsContext.getPurposeCommonContext().getWaitingForApprovalVersionId() : sharedStepsContext.getPurposeCommonContext().getVersionId(); diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeSuspendStep.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeSuspendStep.java index 1bb4d9316..f00faef9c 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeSuspendStep.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/purpose/PurposeSuspendStep.java @@ -1,8 +1,8 @@ package it.pagopa.pn.interop.cucumber.steps.purpose; import io.cucumber.java.en.When; +import it.pagopa.pn.interop.cucumber.steps.ClientTokenConfigurator; import it.pagopa.interop.authorization.service.utils.CommonUtils; -import it.pagopa.interop.generated.openapi.clients.bff.api.PurposesApi; import it.pagopa.interop.purpose.service.IPurposeApiClient; import it.pagopa.interop.utils.HttpCallExecutor; import it.pagopa.pn.interop.cucumber.steps.SharedStepsContext; @@ -10,22 +10,24 @@ import java.util.UUID; public class PurposeSuspendStep { + private final ClientTokenConfigurator clientTokenConfigurator; private final CommonUtils commonUtils; private final SharedStepsContext sharedStepsContext; private final IPurposeApiClient purposeApiClient; private final HttpCallExecutor httpCallExecutor; - public PurposeSuspendStep(SharedStepsContext sharedStepsContext, - IPurposeApiClient purposeApiClient) { + public PurposeSuspendStep(ClientTokenConfigurator clientTokenConfigurator, + SharedStepsContext sharedStepsContext) { + this.clientTokenConfigurator = clientTokenConfigurator; this.sharedStepsContext = sharedStepsContext; - this.purposeApiClient = purposeApiClient; + this.purposeApiClient = clientTokenConfigurator.getPurposeApiClient(); this.commonUtils = sharedStepsContext.getCommonUtils(); this.httpCallExecutor = sharedStepsContext.getHttpCallExecutor(); } @When("l'utente sospende quella finalità in stato {string}") public void userSuspendsPurposeInState(String state) { - commonUtils.setBearerToken(sharedStepsContext.getUserToken()); + clientTokenConfigurator.setBearerToken(sharedStepsContext.getUserToken()); String versionId = "WAITING_FOR_APPROVAL".equals(state) || "REJECTED".equals(state) ? sharedStepsContext.getPurposeCommonContext().getWaitingForApprovalVersionId() diff --git a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation-producer.feature b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation-producer.feature index c6bdac47b..306e2a6d4 100644 --- a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation-producer.feature +++ b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation-producer.feature @@ -108,6 +108,12 @@ Feature: Creazione di una delega in erogazione # Esito: si ottiene 403 "Unauthorized" | support | delegante | 403 | + Scenario: [TC_CAPOFILA_33] La creazione di una delega in erogazione NON può essere compiuto da un utente ADMIN se l’aderente non si è reso disponibile ad accettare deleghe + Given l'utente è un "admin" di "PA1" + Given "PA1" ha già creato e pubblicato 1 e-service + When l'utente richiede la creazione di una delega per l'ente "PA2" + Then si ottiene lo status code 403 + #TC-7: L'accettazione di una delega NON può essere fatta da un utente con ruolo diverso da ADMIN #TC-8: La revoca di una delega NON può essere fatta da un utente con ruolo diverso da ADMIN #TC-13: L'accettazione di una delega può essere fatta da un utente con ruolo ADMIN diff --git a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation_handling_fruitions.feature b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation_handling_fruitions.feature index 66a208cae..17292c001 100644 --- a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation_handling_fruitions.feature +++ b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/capofila/delegation_handling_fruitions.feature @@ -2,23 +2,17 @@ Feature: Creazione di una delega e gestione delle richieste di fruizione Background: - Given l'ente "PA2" rimuove la disponibilità a ricevere deleghe - - Scenario: [TC_CAPOFILA_33] La creazione di una delega in erogazione NON può essere compiuto da un utente ADMIN se l’aderente non si è reso disponibile ad accettare deleghe - Given l'utente è un "admin" di "PA2" - Given "PA2" ha già creato e pubblicato 1 e-service - When l'utente richiede la creazione di una delega per l'ente "PA1" - Then si ottiene lo status code 403 + Given l'ente "PA1" rimuove la disponibilità a ricevere deleghe #TC-35: Delegato da la disponibilità a ricevere deleghe #TC-55: Delegato può rifiutare una finalità in stato pending #TC-59: Delegato NON può sospendere finalità in stato pending Scenario: [TC_CAPOFILA_35_55_59] Un delegato all’erogazione che gestisce finalità per conto del delegante può rifiutare e non sospendere una finalità in stato pending - Given l'utente è un "admin" di "PA2" - Given "PA1" ha già creato e pubblicato 1 e-service - And l'ente "PA2" concede la disponibilità a ricevere deleghe - When l'ente "PA1" richiede la creazione di una delega per l'ente "PA2" - And l'ente "PA2" accetta la delega + Given l'utente è un "admin" di "PA1" + Given "PA2" ha già creato e pubblicato 1 e-service + And l'ente "PA1" concede la disponibilità a ricevere deleghe + When l'ente "PA2" richiede la creazione di una delega per l'ente "PA1" + And l'ente "PA1" accetta la delega Given "GSP" ha una richiesta di fruizione in stato "ACTIVE" per quell'e-service Given "GSP" ha già creato 1 finalità in stato "WAITING_FOR_APPROVAL" per quell'eservice When l'utente sospende quella finalità in stato "WAITING_FOR_APPROVAL" @@ -31,11 +25,11 @@ Feature: Creazione di una delega e gestione delle richieste di fruizione #TC-60: Delegato può sospendere una finalità ATTIVA #TC-61: Delegato NON può rifiutare una finalità ATTIVA Scenario Outline: [TC_CAPOFILA_58_59_60_61] Un delegato all’erogazione che gestisce finalità per conto del delegante può attivare/sospendere finalità in pending o attive - Given l'utente è un "admin" di "PA2" - Given "PA1" ha già creato e pubblicato 1 e-service - And l'ente "PA2" concede la disponibilità a ricevere deleghe - When l'ente "PA1" richiede la creazione di una delega per l'ente "PA2" - And l'ente "PA2" accetta la delega + Given l'utente è un "admin" di "PA1" + Given "PA2" ha già creato e pubblicato 1 e-service + And l'ente "PA1" concede la disponibilità a ricevere deleghe + When l'ente "PA2" richiede la creazione di una delega per l'ente "PA1" + And l'ente "PA1" accetta la delega Given "GSP" ha una richiesta di fruizione in stato "ACTIVE" per quell'e-service Given "GSP" ha già creato 1 finalità in stato "" per quell'eservice # Attivazione finalità (200 solo se finalità in PENDING) @@ -57,26 +51,26 @@ Feature: Creazione di una delega e gestione delle richieste di fruizione #TC-37: Delegato da la disponibilità a ricevere deleghe #TC-66: Delegato accetta richiesta di fruizione e-service Scenario: [TC_CAPOFILA_22_23_37_66] Un delegato all'erogazione accetta la richieste di fruizione di un e-service per conto di un delegante - Given l'utente è un "admin" di "PA1" - Given "PA1" ha già creato un e-service in stato "PUBLISHED" con approvazione "MANUAL" - And l'ente "PA2" concede la disponibilità a ricevere deleghe - When l'ente "PA1" richiede la creazione di una delega per l'ente "PA2" - And l'ente "PA2" accetta la delega + Given l'utente è un "admin" di "PA2" + Given "PA2" ha già creato un e-service in stato "PUBLISHED" con approvazione "MANUAL" + And l'ente "PA1" concede la disponibilità a ricevere deleghe + When l'ente "PA2" richiede la creazione di una delega per l'ente "PA1" + And l'ente "PA1" accetta la delega Given "GSP" ha già creato e inviato una richiesta di fruizione per quell'e-service ed è in attesa di approvazione - And "PA2" ha già approvato quella richiesta di fruizione + And "PA1" ha già approvato quella richiesta di fruizione #revoca di una delega in stato attivo da parte del delegato - And l'ente "PA2" con ruolo "admin" revoca la delega + And l'ente "PA1" con ruolo "admin" revoca la delega Then si ottiene lo status code 403 #revoca di una delega in stato attivo da parte del delegante - And l'ente "PA1" con ruolo "admin" revoca la delega + And l'ente "PA2" con ruolo "admin" revoca la delega Then si ottiene lo status code 200 Scenario: [TC_CAPOFILA_67] Un delegato all'erogazione accetta la richieste di fruizione di un e-service per conto di un delegante - Given l'utente è un "admin" di "PA1" - Given "PA1" ha già creato un e-service in stato "PUBLISHED" con approvazione "MANUAL" - And l'ente "PA2" concede la disponibilità a ricevere deleghe - When l'utente richiede la creazione di una delega per l'ente "PA2" - And l'ente "PA2" accetta la delega + Given l'utente è un "admin" di "PA2" + Given "PA2" ha già creato un e-service in stato "PUBLISHED" con approvazione "MANUAL" + And l'ente "PA1" concede la disponibilità a ricevere deleghe + When l'utente richiede la creazione di una delega per l'ente "PA1" + And l'ente "PA1" accetta la delega Given "GSP" ha già creato e inviato una richiesta di fruizione per quell'e-service ed è in attesa di approvazione - And "PA2" ha già rifiutato quella richiesta di fruizione + And "PA1" ha già rifiutato quella richiesta di fruizione