use of com.google.firebase.firestore.testutil.EmptyAppCheckTokenProvider in project firebase-android-sdk by firebase.
the class StreamTest method testStreamRefreshesTokenUponExpiration.
@Test
public void testStreamRefreshesTokenUponExpiration() throws Exception {
AsyncQueue testQueue = new AsyncQueue();
MockCredentialsProvider mockCredentialsProvider = new MockCredentialsProvider();
Datastore datastore = new Datastore(IntegrationTestUtil.testEnvDatabaseInfo(), testQueue, mockCredentialsProvider, new EmptyAppCheckTokenProvider(), ApplicationProvider.getApplicationContext(), null);
StreamStatusCallback callback = new StreamStatusCallback();
WriteStream writeStream = datastore.createWriteStream(callback);
waitForWriteStreamOpen(testQueue, writeStream, callback);
// Simulate callback from GRPC with an unauthenticated error -- this should invalidate the
// token.
testQueue.runSync(() -> writeStream.handleServerClose(Status.UNAUTHENTICATED));
waitForWriteStreamOpen(testQueue, writeStream, callback);
// Simulate a different error -- token should not be invalidated this time.
testQueue.runSync(() -> writeStream.handleServerClose(Status.UNAVAILABLE));
waitForWriteStreamOpen(testQueue, writeStream, callback);
assertThat(mockCredentialsProvider.observedStates()).containsExactly("getToken", "invalidateToken", "getToken", "getToken").inOrder();
}
Aggregations