@@ -72,8 +72,9 @@ public class ConfigFetchHttpClientTest {
72
72
private static final String API_KEY = "fake_api_key" ;
73
73
private static final String FAKE_APP_ID = "1:14368190084:android:09cb977358c6f241" ;
74
74
private static final String PROJECT_NUMBER = "14368190084" ;
75
- private static final String INSTANCE_ID_STRING = "fake instance id" ;
76
- private static final String INSTANCE_ID_TOKEN_STRING = "fake instance id token" ;
75
+ private static final String INSTALLATION_ID_STRING = "'fL71_VyL3uo9jNMWu1L60S" ;
76
+ private static final String INSTALLATION_AUTH_TOKEN_STRING =
77
+ "eyJhbGciOiJF.eyJmaWQiOiJmaXMt.AB2LPV8wRQIhAPs4NvEgA3uhubH" ;
77
78
private static final String DEFAULT_NAMESPACE = RemoteConfigComponent .DEFAULT_NAMESPACE ;
78
79
private static final String ETAG_FORMAT =
79
80
"etag-" + PROJECT_NUMBER + "-" + DEFAULT_NAMESPACE + "-fetch-%d" ;
@@ -177,6 +178,7 @@ public void fetch_setsAllHeaders_sendsAllHeadersToServer() throws Exception {
177
178
expectedHeaders .put ("X-Android-Package" , context .getPackageName ());
178
179
expectedHeaders .put ("X-Android-Cert" , null );
179
180
expectedHeaders .put ("X-Google-GFE-Can-Retry" , "yes" );
181
+ expectedHeaders .put ("X-Goog-Firebase-Installations-Auth" , INSTALLATION_AUTH_TOKEN_STRING );
180
182
expectedHeaders .put ("Content-Type" , "application/json" );
181
183
expectedHeaders .put ("Accept" , "application/json" );
182
184
// Custom user-defined headers.
@@ -195,8 +197,8 @@ public void fetch_setsAllElementsOfRequestBody_sendsRequestBodyToServer() throws
195
197
fetch (FIRST_ETAG , userProperties );
196
198
197
199
JSONObject requestBody = new JSONObject (fakeHttpURLConnection .getOutputStream ().toString ());
198
- assertThat (requestBody .get (INSTANCE_ID )).isEqualTo (INSTANCE_ID_STRING );
199
- assertThat (requestBody .get (INSTANCE_ID_TOKEN )).isEqualTo (INSTANCE_ID_TOKEN_STRING );
200
+ assertThat (requestBody .get (INSTANCE_ID )).isEqualTo (INSTALLATION_ID_STRING );
201
+ assertThat (requestBody .get (INSTANCE_ID_TOKEN )).isEqualTo (INSTALLATION_AUTH_TOKEN_STRING );
200
202
assertThat (requestBody .get (APP_ID )).isEqualTo (FAKE_APP_ID );
201
203
Locale locale = context .getResources ().getConfiguration ().locale ;
202
204
assertThat (requestBody .get (COUNTRY_CODE )).isEqualTo (locale .getCountry ());
@@ -240,22 +242,22 @@ public void fetch_localeUsesToStringBelowLollipop() throws Exception {
240
242
}
241
243
242
244
@ Test
243
- public void fetch_instanceIdIsNull_throwsFRCClientException () throws Exception {
245
+ public void fetch_installationIdIsNull_throwsFRCClientException () throws Exception {
244
246
setServerResponseTo (noChangeResponseBody , SECOND_ETAG );
245
247
246
248
FirebaseRemoteConfigClientException frcException =
247
- assertThrows (FirebaseRemoteConfigClientException .class , () -> fetchWithoutIid ());
249
+ assertThrows (FirebaseRemoteConfigClientException .class , () -> fetchWithoutInstallationId ());
248
250
249
- assertThat (frcException ).hasMessageThat ().contains ("instance id is null" );
251
+ assertThat (frcException ).hasMessageThat ().contains ("installation id is null" );
250
252
}
251
253
252
254
@ Test
253
- public void fetch_instanceIdTokenIsNull_doesNotThrowException () throws Exception {
255
+ public void fetch_installationAuthTokenIsNull_doesNotThrowException () throws Exception {
254
256
setServerResponseTo (noChangeResponseBody , SECOND_ETAG );
255
257
256
- FetchResponse fetchResponse = fetchWithoutIidToken ();
258
+ FetchResponse fetchResponse = fetchWithoutInstallationAuthToken ();
257
259
258
- assertWithMessage ("Fetch() failed with null instance id token!" )
260
+ assertWithMessage ("Fetch() failed with null installation auth token!" )
259
261
.that (fetchResponse )
260
262
.isNotNull ();
261
263
}
@@ -291,8 +293,8 @@ public void fetch_serverReturnsException_throwsFirebaseRemoteConfigException() {
291
293
private FetchResponse fetch (String eTag ) throws Exception {
292
294
return configFetchHttpClient .fetch (
293
295
fakeHttpURLConnection ,
294
- INSTANCE_ID_STRING ,
295
- INSTANCE_ID_TOKEN_STRING ,
296
+ INSTALLATION_ID_STRING ,
297
+ INSTALLATION_AUTH_TOKEN_STRING ,
296
298
/* analyticsUserProperties= */ ImmutableMap .of (),
297
299
eTag ,
298
300
/* customHeaders= */ ImmutableMap .of (),
@@ -302,8 +304,8 @@ private FetchResponse fetch(String eTag) throws Exception {
302
304
private FetchResponse fetch (String eTag , Map <String , String > userProperties ) throws Exception {
303
305
return configFetchHttpClient .fetch (
304
306
fakeHttpURLConnection ,
305
- INSTANCE_ID_STRING ,
306
- INSTANCE_ID_TOKEN_STRING ,
307
+ INSTALLATION_ID_STRING ,
308
+ INSTALLATION_AUTH_TOKEN_STRING ,
307
309
userProperties ,
308
310
eTag ,
309
311
/* customHeaders= */ ImmutableMap .of (),
@@ -315,30 +317,30 @@ private FetchResponse fetch(
315
317
throws Exception {
316
318
return configFetchHttpClient .fetch (
317
319
fakeHttpURLConnection ,
318
- INSTANCE_ID_STRING ,
319
- INSTANCE_ID_TOKEN_STRING ,
320
+ INSTALLATION_ID_STRING ,
321
+ INSTALLATION_AUTH_TOKEN_STRING ,
320
322
userProperties ,
321
323
eTag ,
322
324
customHeaders ,
323
325
new Date (mockClock .currentTimeMillis ()));
324
326
}
325
327
326
- private FetchResponse fetchWithoutIid () throws Exception {
328
+ private FetchResponse fetchWithoutInstallationId () throws Exception {
327
329
return configFetchHttpClient .fetch (
328
330
fakeHttpURLConnection ,
329
- /* instanceId = */ null ,
330
- INSTANCE_ID_TOKEN_STRING ,
331
+ /* installationId = */ null ,
332
+ INSTALLATION_AUTH_TOKEN_STRING ,
331
333
/* analyticsUserProperties= */ ImmutableMap .of (),
332
334
/* lastFetchETag= */ "bogus-etag" ,
333
335
/* customHeaders= */ ImmutableMap .of (),
334
336
new Date (mockClock .currentTimeMillis ()));
335
337
}
336
338
337
- private FetchResponse fetchWithoutIidToken () throws Exception {
339
+ private FetchResponse fetchWithoutInstallationAuthToken () throws Exception {
338
340
return configFetchHttpClient .fetch (
339
341
fakeHttpURLConnection ,
340
- INSTANCE_ID_STRING ,
341
- /* instanceIdToken = */ null ,
342
+ INSTALLATION_ID_STRING ,
343
+ /* installationAuthToken = */ null ,
342
344
/* analyticsUserProperties= */ ImmutableMap .of (),
343
345
/* lastFetchETag= */ "bogus-etag" ,
344
346
/* customHeaders= */ ImmutableMap .of (),
0 commit comments