Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions google-cloud-firestore/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,14 @@
<to>com.google.cloud.firestore.CollectionGroup</to>
</difference>

<!--
FakeCredentials Refactor
com.google.cloud.firestore.FirestoreOptions$Builder$FakeCredentials -> com.google.cloud.firestore.FirestoreOptions$EmulatorCredentials
-->
<difference>
<differenceType>8001</differenceType>
<className>com/google/cloud/firestore/FirestoreOptions$Builder$FakeCredentials</className>
<to>*</to>
</difference>

</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -231,39 +231,39 @@ public ManagedChannelBuilder apply(ManagedChannelBuilder input) {
.build());
// Use a `CredentialProvider` to match the Firebase Admin SDK, which prevents the Admin SDK
// from overwriting the Emulator credentials.
this.setCredentialsProvider(FixedCredentialsProvider.create(new FakeCredentials()));
this.setCredentialsProvider(FixedCredentialsProvider.create(new EmulatorCredentials()));
}

return new FirestoreOptions(this);
}
}

public class FakeCredentials extends Credentials {
private final Map<String, List<String>> HEADERS =
ImmutableMap.of("Authorization", Arrays.asList("Bearer owner"));

@Override
public String getAuthenticationType() {
throw new IllegalArgumentException("Not supported");
}
public static class EmulatorCredentials extends Credentials {
private final Map<String, List<String>> HEADERS =
ImmutableMap.of("Authorization", Arrays.asList("Bearer owner"));

@Override
public Map<String, List<String>> getRequestMetadata(URI uri) {
return HEADERS;
}
@Override
public String getAuthenticationType() {
throw new IllegalArgumentException("Not supported");
}

@Override
public boolean hasRequestMetadata() {
return true;
}
@Override
public Map<String, List<String>> getRequestMetadata(URI uri) {
return HEADERS;
}

@Override
public boolean hasRequestMetadataOnly() {
return true;
}
@Override
public boolean hasRequestMetadata() {
return true;
}

@Override
public void refresh() {}
@Override
public boolean hasRequestMetadataOnly() {
return true;
}

@Override
public void refresh() {}
}

@InternalApi("This class should only be extended within google-cloud-java")
Expand Down