-
Notifications
You must be signed in to change notification settings - Fork 382
Add validation of Test Store API keys #5385
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 validation of Test Store API keys #5385
Conversation
#if TEST_STORE | ||
if apiKey.hasPrefix(testStoreKeyPrefix) { | ||
// Test Store key format: "test_CtDdmbdWBySmqJeeQUTyrNxETUVkajsJ" | ||
return .testStore | ||
} | ||
#endif // TEST_STORE |
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.
Having only this under the TEST_STORE
flag is enough, since the APIKeyValidationResult
enum is an internal API
📸 Snapshot Test1 modified, 704 unchanged
🛸 Powered by Emerge Tools |
@@ -396,12 +404,14 @@ extension Configuration { | |||
fileprivate static func verify(apiKey: String) { | |||
switch self.validate(apiKey: apiKey) { | |||
case .validApplePlatform: break | |||
case .testStore: Logger.warn(Strings.configure.testStoreAPIKey) |
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 wasn't sure about this being a warn
ing or just a debug
log. I think making it a warning doesn't harm and serves as a constant reminder that the Test Store API key will eventually need to change. Lmk if you think otherwise!
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.
Looks great! Just a small comment but not blocking
case .legacy: Logger.debug(Strings.configure.legacyAPIKey) | ||
case .otherPlatforms: Logger.error(Strings.configure.invalidAPIKey) | ||
} | ||
} | ||
|
||
private static let applePlatformKeyPrefixes: Set<String> = ["appl_", "mac_"] | ||
private static let testStoreKeyPrefix = "test_" |
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 wondering should we make it a bit more explicit? Something like rc_test_
? Not sure if we discussed this in the past though 😅
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.
Yeah, that's a very good point. I don't have a strong opinion in favor or against it, but, for sure, it's something that we can change anytime as long as we have the TEST_STORE
compiler flag ON
This is the first PR of a series to add support for the Test Store in the SDK.
Checklist
purchases-android
and hybridsMotivation
The SDK has to identify API keys for the Test Store to modify its behavior accordingly
Description
Adds the validation of the Test Store API keys under the
TEST_STORE
compiler flag