-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: add support for authenticated datafile access #378
Conversation
Pull Request Test Coverage Report for Build 1412
💛 - Coveralls |
* @param authDatafileToken Token for authenticated datafile access. | ||
* @param fallback Fallback datafile string used by the ProjectConfigManager to be immediately available. | ||
*/ | ||
public static Optimizely newDefaultInstance(String sdkKey, String authDatafileToken, String fallback) { |
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.
In other SDKs we named it datafileAuthToken
, could you please follow that for all variable & method names?
@@ -125,14 +130,30 @@ protected ProjectConfig poll() { | |||
return null; | |||
} | |||
|
|||
HttpGet createHttpRequest() { |
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.
Should createHttpRequest
be private
?
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.
Private must be right one. This default access will be useful for header testing.
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.
Then let's use the VisibleForTesting annotation.
core-httpclient-impl/src/main/java/com/optimizely/ab/config/HttpProjectConfigManager.java
Outdated
Show resolved
Hide resolved
…tpProjectConfigManager.java Co-authored-by: Matt Carroll <[email protected]>
@@ -125,14 +130,30 @@ protected ProjectConfig poll() { | |||
return null; | |||
} | |||
|
|||
HttpGet createHttpRequest() { |
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.
Then let's use the VisibleForTesting annotation.
* @param datafileAuthToken Token for authenticated datafile access. | ||
* @param fallback Fallback datafile string used by the ProjectConfigManager to be immediately available. | ||
*/ | ||
public static Optimizely newDefaultInstance(String sdkKey, String datafileAuthToken, String fallback) { |
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.
The cascading signatures here don't line up nicely. We should consistently call the next method in the chain.
public static Optimizely newDefaultInstance(String sdkKey) {
...
return newDefaultInstance(sdkKey, null)
}
public static Optimizely newDefaultInstance(String sdkKey, String fallback) {
...
String datafileAuthToken = PropertyUtils.get(HttpProjectConfigManager.CONFIG_SDK_AUTH_TOKEN);
return newDefaultInstance(sdkKey, fallback, datafileAuthToken)
}
public static Optimizely newDefaultInstance(String sdkKey, String fallback, String datafileAuthToken) {
...
return newDefaultInstance(builder.build(), notificationCenter);
}
Unfortunately these are all strings so order needs to be paid attention to. We should also provide a configuration option for datafileAuthToken
so customers can deploy this via optimizely.properties
and not have explicitly provide this value to the factory method. See the example above.
@@ -179,13 +179,29 @@ public static Optimizely newDefaultInstance(String sdkKey) { | |||
* @param fallback Fallback datafile string used by the ProjectConfigManager to be immediately available. | |||
*/ | |||
public static Optimizely newDefaultInstance(String sdkKey, String fallback) { | |||
String datafileAuthToken = PropertyUtils.get(HttpProjectConfigManager.CONFIG_DATAFILE_AUTH_TOKEN); |
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.
We've been using datafileAccessToken
in the other SDKs. Let's stick with the same name throughout.
On vacation. Will get it reviewed 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.
lgtm
Summary
(1) Optimizely optimizely = OptimizelyFactory.newDefaultInstance(String sdkKey,
String authDatafileToken,
String fallback); or
(2) HttpProjectConfigManager.Builder builder = HttpProjectConfigManager.builder()
.withSdkKey(sdkKey)
.withAuthDatafileToken(authDatafileToken);
Optimizely optimizely = OptimizelyFactory.newDefaultInstance(builder.build());
Test plan