-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@@ -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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?"
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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(); | ||
} | ||
|
There was a problem hiding this comment.
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?
This pull request adds tests for CSTG. They cover the happy path and the case of an invalid origin.