-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QA-5872: completed the logic to dynamically generate the tracing and …
…interop tokens for the QA environment. Additionally, a switch was added to execute the tracing tests in the dev environment
- Loading branch information
1 parent
c7b6c5c
commit c17641c
Showing
17 changed files
with
253 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#TRACING | ||
pn.interop.tracing.base-url=https://api.dev.tracing.interop.pagopa.it | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#TRACING | ||
pn.interop.tracing.base-url=https://api.qa.tracing.interop.pagopa.it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ts/src/main/java/it/pagopa/interop/authorization/service/factory/InteropTokenFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package it.pagopa.interop.authorization.service.factory; | ||
|
||
import it.pagopa.interop.authorization.service.utils.ConfigFileReader; | ||
import it.pagopa.interop.conf.InteropClientConfigs; | ||
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; | ||
|
||
import java.util.Map; | ||
|
||
@Slf4j | ||
@Getter | ||
@Setter | ||
public class InteropTokenFactory extends SessionTokenFactory { | ||
private static final String WELLKNOWN_URL = "https://qa.interop.pagopa.it/.well-known/jwks.json"; | ||
private Map<String, Map<String, String>> cachedTokens = null; | ||
|
||
public InteropTokenFactory(InteropClientConfigs interopClientConfigs, ConfigFileReader configFileReader) { | ||
super(interopClientConfigs, configFileReader); | ||
} | ||
|
||
public Map<String, Map<String, String>> loadToken() { | ||
getSessionTokenPayloadTemplate().put("aud", "{{ENVIRONMENT}}.interop.pagopa.it/ui"); | ||
try { | ||
if (cachedTokens == null) cachedTokens = generateSessionToken(); | ||
} catch (Exception ex) { | ||
throw new IllegalArgumentException("There was an error while creating the session token: " + ex.getMessage(), ex); | ||
} | ||
return cachedTokens; | ||
} | ||
|
||
@Override | ||
public String getRemoteWellknownUrl() { | ||
return WELLKNOWN_URL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ts/src/main/java/it/pagopa/interop/authorization/service/factory/TracingTokenFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package it.pagopa.interop.authorization.service.factory; | ||
|
||
import it.pagopa.interop.authorization.service.utils.ConfigFileReader; | ||
import it.pagopa.interop.conf.InteropClientConfigs; | ||
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; | ||
|
||
import java.util.Map; | ||
|
||
@Slf4j | ||
@Getter | ||
@Setter | ||
public class TracingTokenFactory extends SessionTokenFactory { | ||
private static final String WELLKNOWN_URL = "https://tracing-qa-only-well-known-qa.s3.eu-south-1.amazonaws.com/.well-known/jwks.json"; | ||
private Map<String, Map<String, String>> cachedTokens = null; | ||
|
||
public TracingTokenFactory(InteropClientConfigs interopClientConfigs, ConfigFileReader configFileReader) { | ||
super(interopClientConfigs, configFileReader); | ||
} | ||
|
||
@Override | ||
public Map<String, Map<String, String>> loadToken() { | ||
getSessionTokenPayloadTemplate().put("aud", "{{ENVIRONMENT}}.interop.pagopa.it/m2m"); | ||
try { | ||
if (cachedTokens == null) cachedTokens = generateSessionToken(); | ||
} catch (Exception ex) { | ||
throw new IllegalArgumentException("There was an error while creating the session token: " + ex.getMessage(), ex); | ||
} | ||
return cachedTokens; | ||
} | ||
|
||
@Override | ||
public String getRemoteWellknownUrl() { | ||
return WELLKNOWN_URL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...java/it/pagopa/interop/config/springconfig/springconfig/JwtTokenServiceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package it.pagopa.interop.config.springconfig.springconfig; | ||
|
||
import it.pagopa.interop.authorization.service.factory.InteropTokenFactory; | ||
import it.pagopa.interop.authorization.service.factory.TracingTokenFactory; | ||
import it.pagopa.interop.authorization.service.utils.ConfigFileReader; | ||
import it.pagopa.interop.authorization.service.utils.IdentityService; | ||
import it.pagopa.interop.conf.InteropClientConfigs; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.context.annotation.Scope; | ||
|
||
@Configuration | ||
public class JwtTokenServiceConfiguration { | ||
|
||
@Bean | ||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) | ||
public TracingTokenFactory tracingTokenFactory(InteropClientConfigs interopClientConfigs, ConfigFileReader configFileReader) { | ||
return new TracingTokenFactory(interopClientConfigs, configFileReader); | ||
} | ||
|
||
@Bean | ||
@Primary | ||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) | ||
public InteropTokenFactory interopTokenFactory(InteropClientConfigs interopClientConfigs, ConfigFileReader configFileReader) { | ||
return new InteropTokenFactory(interopClientConfigs, configFileReader); | ||
} | ||
|
||
@Bean(name = "tracingIdentityService") | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
public IdentityService tracingIdentityService(TracingTokenFactory tracingTokenFactory, ConfigFileReader configFileReader) { | ||
return new IdentityService(tracingTokenFactory, configFileReader); | ||
} | ||
|
||
@Bean(name = "interopIdentityService") | ||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
public IdentityService interopIdentityService(InteropTokenFactory interopTokenFactory, ConfigFileReader configFileReader) { | ||
return new IdentityService(interopTokenFactory, configFileReader); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.