Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSTG tests #7

Merged
merged 3 commits into from
Jan 14, 2024
Merged

Add CSTG tests #7

merged 3 commits into from
Jan 14, 2024

Conversation

mcollins-ttd
Copy link
Contributor

This pull request adds tests for CSTG. They cover the happy path and the case of an invalid origin.

@@ -182,6 +201,125 @@ public JsonNode v2TokenGenerateUsingPayload(String payload, boolean asOldPartici
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret(asOldParticipant));
}

public JsonNode v2ClientSideTokenGenerate(String requestBody, boolean useValidOrigin) throws Exception {
final byte[] serverPublicKeyBytes = base64ToByteArray(CLIENT_SIDE_TOKEN_GENERATE_SERVER_PUBLIC_KEY.substring(PUBLIC_KEY_PREFIX_LENGTH));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big issue, but final isn't really needed for local variables

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan because it reduces cognitive overhead, no need to ask: "is this variable intentionally mutable / going to be reassigned later?"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's fine too, I don't have very strong opinions on either

private static final String CLIENT_API_KEY = EnvUtil.getEnv("UID2_E2E_API_KEY");
private static final String CLIENT_API_SECRET = EnvUtil.getEnv("UID2_E2E_API_SECRET");
private static final String CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF = EnvUtil.getEnv("UID2_E2E_API_KEY_OLD");
private static final String CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF = EnvUtil.getEnv("UID2_E2E_API_SECRET_OLD");
private static final String CLIENT_SIDE_TOKEN_GENERATE_SUBSCRIPTION_ID = EnvUtil.getEnv("UID2_E2E_SUBSCRIPTION_ID");
private static final String CLIENT_SIDE_TOKEN_GENERATE_SERVER_PUBLIC_KEY = EnvUtil.getEnv("UID2_E2E_SERVER_PUBLIC_KEY");
private static final String CLIENT_SIDE_TOKEN_GENERATE_ORIGIN = EnvUtil.getEnv("UID2_E2E_ORIGIN");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do both valid and invalid origins have to be passed in dynamically? Can they be hardcoded instead?

}
return keyPairGenerator.genKeyPair();
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @gmsdelmundo mentioned, any way to share this code with Operator (test) code?

@mcollins-ttd mcollins-ttd merged commit e98d3e9 into main Jan 14, 2024
1 check passed
@mcollins-ttd mcollins-ttd deleted the mkc-UID2-1760-cstg-e2e-tests branch January 14, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants