From d156916e37689d4d64239a69ec24c08c8935004a Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Thu, 30 Jan 2025 18:58:12 -0800 Subject: [PATCH 1/3] 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. --- .../main/java/com/google/cloud/firestore/FirestoreOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java index b0887f602..e8df452a4 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java @@ -313,7 +313,7 @@ public static class EmulatorCredentials extends Credentials { @Override public String getAuthenticationType() { - throw new IllegalArgumentException("Not supported"); + return "Unauthenticated"; } @Override From c2b20f4ed4d7d7c850d5ad3a95cbceb1ff036181 Mon Sep 17 00:00:00 2001 From: Ehsan Nasiri Date: Fri, 31 Jan 2025 15:25:03 -0800 Subject: [PATCH 2/3] Add unit test for EmulatorCredentials. --- .../cloud/firestore/EmulatorCredentials.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java new file mode 100644 index 000000000..1314ec490 --- /dev/null +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java @@ -0,0 +1,35 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertEquals; + +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.FixedCredentialsProvider; +import java.io.IOException; +import org.junit.Test; + +public class EmulatorCredentials { + @Test + public void implementsCredentials() throws IOException { + CredentialsProvider emulatorCredentials = + FixedCredentialsProvider.create(new FirestoreOptions.EmulatorCredentials()); + assertEquals("Unauthenticated", emulatorCredentials.getCredentials().getAuthenticationType()); + assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadata()); + assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadataOnly()); + } +} From 1ddb5a25708c431cf1b3f56617cadbdf377d4612 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Sat, 1 Feb 2025 00:18:51 +0000 Subject: [PATCH 3/3] chore: generate libraries at Sat Feb 1 00:17:14 UTC 2025 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd4c7b6ae..333abc8e3 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If you are using Maven without the BOM, add this to your dependencies: com.google.cloud google-cloud-firestore - 3.30.5 + 3.30.6 ```