Skip to content

Commit 29afb41

Browse files
fix: getAuthenticationType in EmulatorCredentials should not throw. (#2003)
* fix: getAuthenticationType in EmulatorCredentials should not throw. `EmulatorCredentials` extends the abstract `Credentials` class. The signature of `getAuthenticationType()` function of this class does not indicate that this API could throw, and based on [this description](https://cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.OAuth2Credentials#com_google_auth_oauth2_OAuth2Credentials_getAuthenticationType__), I don't think it should. Fixes #2002. * Add unit test for EmulatorCredentials. * chore: generate libraries at Sat Feb 1 00:17:14 UTC 2025 --------- Co-authored-by: cloud-java-bot <[email protected]>
1 parent b3917a9 commit 29afb41

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If you are using Maven without the BOM, add this to your dependencies:
4141
<dependency>
4242
<groupId>com.google.cloud</groupId>
4343
<artifactId>google-cloud-firestore</artifactId>
44-
<version>3.30.5</version>
44+
<version>3.30.6</version>
4545
</dependency>
4646

4747
```

google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static class EmulatorCredentials extends Credentials {
313313

314314
@Override
315315
public String getAuthenticationType() {
316-
throw new IllegalArgumentException("Not supported");
316+
return "Unauthenticated";
317317
}
318318

319319
@Override
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.firestore;
18+
19+
import static org.junit.Assert.assertEquals;
20+
21+
import com.google.api.gax.core.CredentialsProvider;
22+
import com.google.api.gax.core.FixedCredentialsProvider;
23+
import java.io.IOException;
24+
import org.junit.Test;
25+
26+
public class EmulatorCredentials {
27+
@Test
28+
public void implementsCredentials() throws IOException {
29+
CredentialsProvider emulatorCredentials =
30+
FixedCredentialsProvider.create(new FirestoreOptions.EmulatorCredentials());
31+
assertEquals("Unauthenticated", emulatorCredentials.getCredentials().getAuthenticationType());
32+
assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadata());
33+
assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadataOnly());
34+
}
35+
}

0 commit comments

Comments
 (0)