Skip to content

Commit b5d952e

Browse files
committed
fix per review
1 parent 3c5e8cd commit b5d952e

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,17 @@ public static Optimizely newDefaultInstance(String sdkKey, String fallback) {
193193
* Returns a new Optimizely instance with authenticated datafile support.
194194
*
195195
* @param sdkKey SDK key used to build the ProjectConfigManager.
196-
* @param authDatafileToken Token for authenticated datafile access.
196+
* @param datafileAuthToken Token for authenticated datafile access.
197197
* @param fallback Fallback datafile string used by the ProjectConfigManager to be immediately available.
198198
*/
199-
public static Optimizely newDefaultInstance(String sdkKey, String authDatafileToken, String fallback) {
199+
public static Optimizely newDefaultInstance(String sdkKey, String datafileAuthToken, String fallback) {
200200
NotificationCenter notificationCenter = new NotificationCenter();
201201

202202
HttpProjectConfigManager.Builder builder = HttpProjectConfigManager.builder()
203203
.withDatafile(fallback)
204204
.withNotificationCenter(notificationCenter)
205205
.withSdkKey(sdkKey)
206-
.withAuthDatafileToken(authDatafileToken);
206+
.withDatafileAuthToken(datafileAuthToken);
207207

208208
return newDefaultInstance(builder.build(), notificationCenter);
209209
}

core-httpclient-impl/src/main/java/com/optimizely/ab/config/HttpProjectConfigManager.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ public class HttpProjectConfigManager extends PollingProjectConfigManager {
5454

5555
private final OptimizelyHttpClient httpClient;
5656
private final URI uri;
57-
private final String authDatafileToken;
57+
private final String datafileAuthToken;
5858
private String datafileLastModified;
5959

6060
private HttpProjectConfigManager(long period,
6161
TimeUnit timeUnit,
6262
OptimizelyHttpClient httpClient,
6363
String url,
64-
String authDatafileToken,
64+
String datafileAuthToken,
6565
long blockingTimeoutPeriod,
6666
TimeUnit blockingTimeoutUnit,
6767
NotificationCenter notificationCenter) {
6868
super(period, timeUnit, blockingTimeoutPeriod, blockingTimeoutUnit, notificationCenter);
6969
this.httpClient = httpClient;
7070
this.uri = URI.create(url);
71-
this.authDatafileToken = authDatafileToken;
71+
this.datafileAuthToken = datafileAuthToken;
7272
}
7373

7474
public URI getUri() {
@@ -133,8 +133,8 @@ protected ProjectConfig poll() {
133133
HttpGet createHttpRequest() {
134134
HttpGet httpGet = new HttpGet(uri);
135135

136-
if (authDatafileToken != null) {
137-
httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + authDatafileToken);
136+
if (datafileAuthToken != null) {
137+
httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + datafileAuthToken);
138138
}
139139

140140
if (datafileLastModified != null) {
@@ -151,7 +151,7 @@ public static Builder builder() {
151151
public static class Builder {
152152
private String datafile;
153153
private String url;
154-
private String authDatafileToken = null;
154+
private String datafileAuthToken = null;
155155
private String format = "https://cdn.optimizely.com/datafiles/%s.json";
156156
private String authFormat = "https://config.optimizely.com/datafiles/auth/%s.json";
157157
private OptimizelyHttpClient httpClient;
@@ -174,8 +174,8 @@ public Builder withSdkKey(String sdkKey) {
174174
return this;
175175
}
176176

177-
public Builder withAuthDatafileToken(String token) {
178-
this.authDatafileToken = token;
177+
public Builder withDatafileAuthToken(String token) {
178+
this.datafileAuthToken = token;
179179
return this;
180180
}
181181

@@ -287,7 +287,7 @@ public HttpProjectConfigManager build(boolean defer) {
287287
throw new NullPointerException("sdkKey cannot be null");
288288
}
289289

290-
if (authDatafileToken == null) {
290+
if (datafileAuthToken == null) {
291291
url = String.format(format, sdkKey);
292292
} else {
293293
url = String.format(authFormat, sdkKey);
@@ -303,7 +303,7 @@ public HttpProjectConfigManager build(boolean defer) {
303303
timeUnit,
304304
httpClient,
305305
url,
306-
authDatafileToken,
306+
datafileAuthToken,
307307
blockingTimeoutPeriod,
308308
blockingTimeoutUnit,
309309
notificationCenter);

core-httpclient-impl/src/test/java/com/optimizely/ab/OptimizelyFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void newDefaultInstanceWithFallback() throws Exception {
192192
}
193193

194194
@Test
195-
public void newDefaultInstanceWithAuthDatafileToken() throws Exception {
195+
public void newDefaultInstanceWithDatafileAuthToken() throws Exception {
196196
String datafileString = Resources.toString(Resources.getResource("valid-project-config-v4.json"), Charsets.UTF_8);
197197
optimizely = OptimizelyFactory.newDefaultInstance("sdk-key", "auth-token", datafileString);
198198
assertTrue(optimizely.isValid());

core-httpclient-impl/src/test/java/com/optimizely/ab/config/HttpProjectConfigManagerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ public void testHttpGetBySdkKeyForAuthDatafile() throws Exception {
128128
projectConfigManager = builder()
129129
.withOptimizelyHttpClient(mockHttpClient)
130130
.withSdkKey("sdk-key")
131-
.withAuthDatafileToken("auth-token")
131+
.withDatafileAuthToken("auth-token")
132132
.build();
133133

134134
URI actual = projectConfigManager.getUri();
135-
assertEquals(new URI("https://www.optimizely-cdn.com/datafiles/auth/sdk-key.json"), actual);
135+
assertEquals(new URI("https://config.optimizely.com/datafiles/auth/sdk-key.json"), actual);
136136
}
137-
137+
138138
@Test
139139
public void testHttpGetByCustomUrlForAuthDatafile() throws Exception {
140140
String expected = "https://custom.optimizely.com/custom-location.json";
@@ -143,7 +143,7 @@ public void testHttpGetByCustomUrlForAuthDatafile() throws Exception {
143143
.withOptimizelyHttpClient(mockHttpClient)
144144
.withUrl(expected)
145145
.withSdkKey("sdk-key")
146-
.withAuthDatafileToken("auth-token")
146+
.withDatafileAuthToken("auth-token")
147147
.build();
148148

149149
URI actual = projectConfigManager.getUri();
@@ -167,11 +167,11 @@ public void testCreateHttpRequestForAuthDatafile() throws Exception {
167167
projectConfigManager = builder()
168168
.withOptimizelyHttpClient(mockHttpClient)
169169
.withSdkKey("sdk-key")
170-
.withAuthDatafileToken("auth-token")
170+
.withDatafileAuthToken("auth-token")
171171
.build();
172172

173173
HttpGet request = projectConfigManager.createHttpRequest();
174-
assertEquals(request.getURI().toString(), "https://www.optimizely-cdn.com/datafiles/auth/sdk-key.json");
174+
assertEquals(request.getURI().toString(), "https://config.optimizely.com/datafiles/auth/sdk-key.json");
175175
assertEquals(request.getHeaders("Authorization")[0].getValue(), "Bearer auth-token");
176176
}
177177

0 commit comments

Comments
 (0)