@Test
public void applicationDefaultServiceAccountWhenConfigured() throws Exception {

  CredentialFactory credentialFactory = getCredentialFactory();
  GoogleCredentialWithRetry credential =
      (GoogleCredentialWithRetry)
          withEnvironmentVariable(CREDENTIAL_ENV_VAR, getStringPath("test-credential.json"))
              .execute(() -> credentialFactory.getCredential(TEST_SCOPES));
  assertThat(credential.getServiceAccountId()).isEqualTo("test-email@gserviceaccount.com");
  assertThat(credential.getServiceAccountPrivateKeyId()).isEqualTo("test-key-id");
}