Skip to content

Commit db62832

Browse files
authored
Merge pull request #67 from IABTechLab/gdm-UID2-5040-e2e
Enhanced E2E test suite
2 parents 77c108c + b2d6f26 commit db62832

23 files changed

+416
-269
lines changed
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Publish E2E Test Suites
2-
run-name: ${{ format('Publish E2E Test Suites{0} {1} Release', ':', inputs.release_type) }}
1+
name: Release UID2 E2E Image
2+
run-name: ${{ inputs.release_type == 'Snapshot' && 'Publish Pre-release' || format('Release {0}', inputs.release_type)}} Docker Image by @${{ github.actor }}
33
on:
44
workflow_dispatch:
55
inputs:
66
release_type:
77
type: choice
8-
description: 'The type of release'
8+
description: The type of release
99
options:
1010
- Snapshot
1111
- Patch
@@ -15,14 +15,21 @@ on:
1515
description: If set, the version number will not be incremented and the given number will be used.
1616
type: string
1717
default: ''
18+
vulnerability_severity:
19+
description: The severity to fail the workflow if such vulnerability is detected. DO NOT override it unless a Jira ticket is raised.
20+
type: choice
21+
options:
22+
- CRITICAL,HIGH
23+
- CRITICAL,HIGH,MEDIUM
24+
- CRITICAL (DO NOT use if JIRA ticket not raised)
1825

1926
jobs:
2027
Image:
2128
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-publish-java-to-docker-versioned.yaml@v3
2229
with:
2330
release_type: ${{ inputs.release_type }}
2431
version_number_input: ${{ inputs.version_number_input }}
25-
java_version: '21'
26-
force_release: 'yes'
32+
vulnerability_severity: ${{ inputs.vulnerability_severity }}
33+
java_version: 21
2734
skip_tests: true
2835
secrets: inherit

Dockerfile

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,35 @@ COPY ./src ./src
1111
######################
1212
# Configure env vars #
1313
######################
14-
ENV UID2_E2E_ENV "github-test-pipeline"
15-
16-
ENV UID2_E2E_SITE_ID ""
17-
ENV UID2_E2E_API_KEY ""
18-
ENV UID2_E2E_API_SECRET ""
19-
ENV UID2_E2E_API_KEY_OLD ""
20-
ENV UID2_E2E_API_SECRET_OLD ""
21-
ENV UID2_E2E_API_KEY_SHARING_RECIPIENT ""
22-
ENV UID2_E2E_API_SECRET_SHARING_RECIPIENT ""
23-
ENV UID2_E2E_API_KEY_NON_SHARING_RECIPIENT ""
24-
ENV UID2_E2E_API_SECRET_NON_SHARING_RECIPIENT ""
25-
ENV UID2_E2E_SUBSCRIPTION_ID ""
26-
ENV UID2_E2E_SERVER_PUBLIC_KEY ""
27-
ENV UID2_E2E_ORIGIN ""
28-
ENV UID2_E2E_INVALID_ORIGIN ""
29-
30-
ENV UID2_E2E_IDENTITY_SCOPE ""
31-
ENV UID2_E2E_PHONE_SUPPORT ""
32-
33-
ENV UID2_E2E_PIPELINE_OPERATOR_URL ""
34-
ENV UID2_E2E_PIPELINE_OPERATOR_TYPE ""
35-
ENV UID2_E2E_PIPELINE_OPERATOR_CLOUD_PROVIDER ""
36-
37-
ENV UID2_E2E_CORE_API_TOKEN ""
38-
ENV UID2_E2E_OPTOUT_TO_CALL_CORE_API_TOKEN ""
39-
ENV UID2_E2E_CORE_URL ""
40-
ENV UID2_E2E_OPTOUT_URL ""
41-
42-
CMD \
43-
if [ "$UID2_E2E_PIPELINE_OPERATOR_TYPE" != "PUBLIC" ] && [ "$UID2_E2E_PIPELINE_OPERATOR_TYPE" != "PRIVATE" ] ; \
44-
then \
45-
echo "ERROR: Incorrect operator type: $UID2_E2E_PIPELINE_OPERATOR_TYPE. Exiting." ; \
46-
exit 1 ; \
47-
elif [ "$UID2_E2E_PIPELINE_OPERATOR_TYPE" = "PUBLIC" ] ; \
48-
then \
49-
mvn test -Dtest="E2EPublicOperatorTestSuite" ; \
50-
else \
51-
mvn test -Dtest="E2EPrivateOperatorTestSuite" ; \
52-
fi
14+
ENV E2E_SUITES ""
15+
ENV E2E_ARGS_JSON ""
16+
17+
ENV E2E_ENV ""
18+
ENV E2E_IDENTITY_SCOPE ""
19+
ENV E2E_PHONE_SUPPORT ""
20+
21+
ENV UID2_CORE_E2E_OPERATOR_API_KEY ""
22+
ENV UID2_CORE_E2E_OPTOUT_API_KEY ""
23+
ENV UID2_CORE_E2E_CORE_URL ""
24+
ENV UID2_CORE_E2E_OPTOUT_URL ""
25+
26+
ENV UID2_OPERATOR_E2E_CLIENT_SITE_ID ""
27+
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY ""
28+
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET ""
29+
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF ""
30+
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF ""
31+
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_SHARING_RECIPIENT ""
32+
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET_SHARING_RECIPIENT ""
33+
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_NON_SHARING_RECIPIENT ""
34+
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET_NON_SHARING_RECIPIENT ""
35+
ENV UID2_OPERATOR_E2E_CSTG_SUBSCRIPTION_ID ""
36+
ENV UID2_OPERATOR_E2E_CSTG_SERVER_PUBLIC_KEY ""
37+
ENV UID2_OPERATOR_E2E_CSTG_ORIGIN ""
38+
ENV UID2_OPERATOR_E2E_CSTG_INVALID_ORIGIN ""
39+
40+
ENV UID2_PIPELINE_E2E_CORE_URL ""
41+
ENV UID2_PIPELINE_E2E_OPERATOR_URL ""
42+
ENV UID2_PIPELINE_E2E_OPERATOR_TYPE ""
43+
ENV UID2_PIPELINE_E2E_OPERATOR_CLOUD_PROVIDER ""
44+
45+
CMD mvn test -Dtest="${E2E_SUITES}"

README.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,68 @@ Any changes to [uid2-operator](https://github.com/IABTechLab/uid2-operator) need
88

99
There are different test suites that can be run depending on the environment and operator type:
1010

11-
| Test Suite | Description |
12-
|---------------------------------------|--------------------------------------------------------------|
13-
| `E2ELocalFullTestSuite` | Used when running both public and private operators locally. |
14-
| `E2EPipelinePrivateOperatorTestSuite` | Used when testing private operators in a pipeline. |
15-
| `E2EPipelinePublicOperatorTestSuite` | Used when testing public operators in a pipeline. |
16-
| `E2EPrivateOperatorTestSuite` | Used when testing real private operators. |
17-
| `E2EPublicOperatorTestSuite` | Used when testing real public operators. |
11+
| Test Suite | Description |
12+
|-------------------------------|-------------------------------------|
13+
| `E2ELocalFullTestSuite` | Used to test all apps locally |
14+
| `E2ECoreTestSuite` | Used when testing Core |
15+
| `E2EPublicOperatorTestSuite` | Used when testing public Operators |
16+
| `E2EPrivateOperatorTestSuite` | Used when testing private Operators |
17+
18+
## Environment Variables
19+
20+
* `E2E_SUITES` - **Docker image only** - The test suites to run, comma separated
21+
* e.g. `E2EPrivateOperatorTestSuite,E2ECoreTestSuite`
22+
* `E2E_ARGS_JSON` - The below environment variables can be put into this environment variable as a JSON
23+
* Any environment variables declared explicitly will override args in `E2E_ARGS_JSON`
24+
25+
### General
26+
27+
| Name | Value |
28+
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
29+
| `E2E_ENV` | The E2E environment - this determines which apps get instantiated<br/>Certain tests run for `local` environments only<br/>Check `AppsMap` for details |
30+
| `E2E_IDENTITY_SCOPE` | The identity scope - one of [UID2, EUID] |
31+
| `E2E_PHONE_SUPPORT` | True if APIs support phone numbers, false otherwise |
32+
33+
### Core
34+
35+
| Name | Value |
36+
|----------------------------------|------------------------------------------------------|
37+
| `UID2_CORE_E2E_OPERATOR_API_KEY` | The API key for an Operator to communicate with Core |
38+
| `UID2_CORE_E2E_OPTOUT_API_KEY` | The API key for Optout to communicate with Core |
39+
| `UID2_CORE_E2E_CORE_URL` | The Core URL to include in attestation requests |
40+
| `UID2_CORE_E2E_OPTOUT_URL` | The Optout URL to include in attestation requests |
41+
42+
### Operator
43+
44+
| Name | Value |
45+
|-------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
46+
| `UID2_OPERATOR_E2E_CLIENT_SITE_ID` | The site ID of the client communicating with Operator |
47+
| `UID2_OPERATOR_E2E_CLIENT_API_KEY` | The API key for a client to communicate with Operator |
48+
| `UID2_OPERATOR_E2E_CLIENT_API_SECRET` | The API secret for a client to communicate with Operator |
49+
| `UID2_OPERATOR_E2E_CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF` | **Optout cutoff tests** - The API key before the optout policy cutoff for a client to communicate with Operator |
50+
| `UID2_OPERATOR_E2E_CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF` | **Optout cutoff tests** - The API secret before the optout policy cutoff for a client to communicate with Operator |
51+
| `UID2_OPERATOR_E2E_CLIENT_API_KEY_SHARING_RECIPIENT` | **Sharing tests** - The API key with SHARER role for a client to communicate with Operator |
52+
| `UID2_OPERATOR_E2E_CLIENT_API_SECRET_SHARING_RECIPIENT` | **Sharing tests** - The API with SHARER role secret for a client to communicate with Operator |
53+
| `UID2_OPERATOR_E2E_CLIENT_API_KEY_NON_SHARING_RECIPIENT` | **Sharing tests** - The API key without SHARER role for a client to communicate with Operator |
54+
| `UID2_OPERATOR_E2E_CLIENT_API_SECRET_NON_SHARING_RECIPIENT` | **Sharing tests** - The API without SHARER role secret for a client to communicate with Operator |
55+
| `UID2_OPERATOR_E2E_CSTG_SUBSCRIPTION_ID` | **CSTG tests** - The subscription ID |
56+
| `UID2_OPERATOR_E2E_CSTG_SERVER_PUBLIC_KEY` | **CSTG tests** - The server public key |
57+
| `UID2_OPERATOR_E2E_CSTG_ORIGIN` | **CSTG tests** - A valid origin |
58+
| `UID2_OPERATOR_E2E_CSTG_INVALID_ORIGIN` | **CSTG tests** - An invalid origin |
59+
60+
### Pipeline
61+
62+
| Name | Value |
63+
|---------------------------------------------|---------------------------------------------------------------------------------------------------------------|
64+
| `UID2_PIPELINE_E2E_CORE_URL` | The Core URL |
65+
| `UID2_PIPELINE_E2E_OPERATOR_URL` | The Operator URL |
66+
| `UID2_PIPELINE_E2E_OPERATOR_TYPE` | The type of Operator - one of [PUBLIC, PRIVATE] |
67+
| `UID2_PIPELINE_E2E_OPERATOR_CLOUD_PROVIDER` | Empty for public Operators, the cloud provider for private Operators - one of [aws-nitro, gcp-oidc, azure-cc] |
1868

1969
## Running the Dockerfile
2070

21-
`docker build -f Dockerfile -t uid2-e2e . && docker run --env <ENV>=<VAR> ... uid2-e2e`
22-
* Set each environment variable specified in the Dockerfile as `--env <ENV>=<VAR>`
71+
```shell
72+
docker build -f Dockerfile -t uid2-e2e .
73+
docker run --env <ENV>=<VAR> ... uid2-e2e
74+
```
2375
* If running the E2E tests against localhost, include the option `--network=host`

src/test/java/app/AppsMap.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package app;
22

3-
import common.EnvUtil;
43
import app.component.App;
54

65
import java.lang.reflect.InvocationTargetException;
@@ -10,8 +9,6 @@
109

1110
public final class AppsMap {
1211
private static final Map<String, String> APP_MAP;
13-
private static final String ENV = EnvUtil.getEnv("UID2_E2E_ENV");
14-
1512
private static final Apps APPS;
1613

1714
static {
@@ -24,10 +21,11 @@ public final class AppsMap {
2421
"uid2-prod", "app.Uid2ProdApps",
2522
"euid-integ", "app.EuidIntegApps",
2623
"euid-prod", "app.EuidProdApps",
24+
"github-test-pipeline-local", "app.GitHubTestPipelineApps",
2725
"github-test-pipeline", "app.GitHubTestPipelineApps"
2826
);
2927

30-
APPS = (Apps) Class.forName(APP_MAP.get(ENV)).getDeclaredConstructor().newInstance();
28+
APPS = (Apps) Class.forName(APP_MAP.get(App.ENV)).getDeclaredConstructor().newInstance();
3129
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
3230
throw new RuntimeException(e);
3331
}
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package app;
22

3+
import common.Const;
4+
import common.EnabledCondition;
35
import common.EnvUtil;
46
import app.component.Core;
57
import app.component.Operator;
68

79
import java.util.Set;
810

911
public class GitHubTestPipelineApps extends Apps {
10-
private static final String OPERATOR_URL = EnvUtil.getEnv("UID2_E2E_PIPELINE_OPERATOR_URL");
11-
private static final Operator.Type OPERATOR_TYPE = Operator.Type.valueOf(EnvUtil.getEnv("UID2_E2E_PIPELINE_OPERATOR_TYPE"));
12-
private static final Operator.CloudProvider OPERATOR_CLOUD_PROVIDER = Operator.CloudProvider.valueOf(EnvUtil.getEnv("UID2_E2E_PIPELINE_OPERATOR_CLOUD_PROVIDER"));
12+
private static final String CORE_URL = EnvUtil.getEnv(Const.Config.Pipeline.CORE_URL, EnabledCondition.isLocal());
1313

14-
private static final String CORE_URL = EnvUtil.getEnv("UID2_E2E_CORE_URL");
14+
private static final String OPERATOR_URL = EnvUtil.getEnv(Const.Config.Pipeline.OPERATOR_URL);
15+
private static final Operator.Type OPERATOR_TYPE = Operator.Type.valueOf(EnvUtil.getEnv(Const.Config.Pipeline.OPERATOR_TYPE));
16+
private static final Operator.CloudProvider OPERATOR_CLOUD_PROVIDER = Operator.CloudProvider.valueOf(EnvUtil.getEnv(Const.Config.Pipeline.OPERATOR_CLOUD_PROVIDER));
1517
private static final String OPERATOR_NAME = OPERATOR_TYPE == Operator.Type.PUBLIC
1618
? "GitHub Test Pipeline - Public Operator"
1719
: "GitHub Test Pipeline - Private %s Operator".formatted(OPERATOR_CLOUD_PROVIDER.toString());
1820

1921
public GitHubTestPipelineApps() {
20-
super(Set.of(
21-
new Operator(OPERATOR_URL, OPERATOR_NAME, OPERATOR_TYPE),
22-
new Core(CORE_URL, "GitHub Test Pipeline - Core")
23-
));
22+
super(EnabledCondition.isLocal() ?
23+
Set.of(
24+
new Operator(OPERATOR_URL, OPERATOR_NAME, OPERATOR_TYPE),
25+
new Core(CORE_URL, "GitHub Test Pipeline - Core")) :
26+
Set.of(new Operator(OPERATOR_URL, OPERATOR_NAME, OPERATOR_TYPE)));
2427
}
2528
}

src/test/java/app/LocalApps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import java.util.Set;
66

77
public final class LocalApps extends Apps {
8+
// TODO: Add optout
89
public LocalApps() {
910
super(Set.of(
10-
// TODO: Add optout, monitorstack
1111
new Localstack("http://localhost", 5001, "Local - Localstack"),
1212
new Admin("http://localhost", 8089, "Local - Admin"),
1313
new Core("http://localhost", 8088, "Local - Core"),

src/test/java/app/component/App.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package app.component;
22

3+
import com.uid2.client.IdentityScope;
4+
import common.Const;
5+
import common.EnvUtil;
36
import common.HttpClient;
7+
import lombok.Getter;
48

9+
@Getter
510
public abstract class App {
11+
public static final String ENV = EnvUtil.getEnv(Const.Config.ENV);
12+
public static final IdentityScope IDENTITY_SCOPE = IdentityScope.valueOf(EnvUtil.getEnv(Const.Config.IDENTITY_SCOPE));
13+
public static final boolean PHONE_SUPPORT = Boolean.parseBoolean(EnvUtil.getEnv(Const.Config.PHONE_SUPPORT));
14+
615
private final String host;
716
private final Integer port;
817
private final String name;
@@ -13,18 +22,6 @@ public App(String host, Integer port, String name) {
1322
this.name = name;
1423
}
1524

16-
public String getHost() {
17-
return host;
18-
}
19-
20-
public Integer getPort() {
21-
return port;
22-
}
23-
24-
public String getName() {
25-
return name;
26-
}
27-
2825
public String getBaseUrl() {
2926
return getPort() == null ? getHost() : "%s:%d".formatted(getHost(), getPort());
3027
}

src/test/java/app/component/Core.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package app.component;
22

3+
import common.Const;
34
import common.EnvUtil;
45
import common.HttpClient;
56
import common.Mapper;
@@ -9,10 +10,10 @@
910
import java.util.Map;
1011

1112
public class Core extends App {
12-
private static final String CORE_API_TOKEN = EnvUtil.getEnv("UID2_E2E_CORE_API_TOKEN");
13-
private static final String OPTOUT_TO_CALL_CORE_API_TOKEN = EnvUtil.getEnv("UID2_E2E_OPTOUT_TO_CALL_CORE_API_TOKEN");
14-
public static final String CORE_URL = EnvUtil.getEnv("UID2_E2E_CORE_URL");
15-
public static final String OPTOUT_URL = EnvUtil.getEnv("UID2_E2E_OPTOUT_URL");
13+
private static final String OPERATOR_API_KEY = EnvUtil.getEnv(Const.Config.Core.OPERATOR_API_KEY);
14+
private static final String OPTOUT_API_KEY = EnvUtil.getEnv(Const.Config.Core.OPTOUT_API_KEY);
15+
public static final String CORE_URL = EnvUtil.getEnv(Const.Config.Core.CORE_URL);
16+
public static final String OPTOUT_URL = EnvUtil.getEnv(Const.Config.Core.OPTOUT_URL);
1617

1718
public Core(String host, Integer port, String name) {
1819
super(host, port, name);
@@ -23,7 +24,7 @@ public Core(String host, String name) {
2324
}
2425

2526
public JsonNode attest(String attestationRequest) throws Exception {
26-
String response = HttpClient.post(getBaseUrl() + "/attest", attestationRequest, CORE_API_TOKEN);
27+
String response = HttpClient.post(getBaseUrl() + "/attest", attestationRequest, OPERATOR_API_KEY);
2728
return Mapper.OBJECT_MAPPER.readTree(response);
2829
}
2930

@@ -35,12 +36,12 @@ public JsonNode getWithCoreApiToken(String path, boolean encrypted) throws Excep
3536
Map<String, String> headers = new HashMap<>();
3637
if (encrypted)
3738
headers.put("Encrypted", "true");
38-
String response = HttpClient.get(getBaseUrl() + path, CORE_API_TOKEN, headers);
39+
String response = HttpClient.get(getBaseUrl() + path, OPERATOR_API_KEY, headers);
3940
return Mapper.OBJECT_MAPPER.readTree(response);
4041
}
4142

4243
public JsonNode getWithOptOutApiToken(String path) throws Exception {
43-
String response = HttpClient.get(getBaseUrl() + path, OPTOUT_TO_CALL_CORE_API_TOKEN);
44+
String response = HttpClient.get(getBaseUrl() + path, OPTOUT_API_KEY);
4445
return Mapper.OBJECT_MAPPER.readTree(response);
4546
}
4647
}

0 commit comments

Comments
 (0)