Skip to content

Commit 276e0a7

Browse files
committed
Revert "Added separate test class for mTLS-utils. Added missing cert and malformed cert tests to X509Provider."
This reverts commit e8fbea7.
1 parent e8fbea7 commit 276e0a7

8 files changed

Lines changed: 8 additions & 328 deletions

File tree

oauth2_http/java/com/google/auth/mtls/MtlsUtils.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,15 @@ static WorkloadCertificateConfiguration getWorkloadCertificateConfiguration(
115115
}
116116

117117
private static File getWellKnownCertificateConfigFile(
118-
EnvironmentProvider envProvider, PropertyProvider propProvider) throws IOException {
118+
EnvironmentProvider envProvider, PropertyProvider propProvider) {
119119
File cloudConfigPath;
120120
String envPath = envProvider.getEnv("CLOUDSDK_CONFIG");
121121
if (envPath != null) {
122122
cloudConfigPath = new File(envPath);
123123
} else {
124124
String osName = propProvider.getProperty("os.name", "").toLowerCase(Locale.US);
125125
if (osName.indexOf("windows") >= 0) {
126-
String appData = envProvider.getEnv("APPDATA");
127-
if (Strings.isNullOrEmpty(appData)) {
128-
throw new CertificateSourceUnavailableException(
129-
"APPDATA environment variable is not set on Windows.");
130-
}
131-
File appDataPath = new File(appData);
126+
File appDataPath = new File(envProvider.getEnv("APPDATA"));
132127
cloudConfigPath = new File(appDataPath, CLOUDSDK_CONFIG_DIRECTORY);
133128
} else {
134129
File configPath = new File(propProvider.getProperty("user.home", ""), ".config");

oauth2_http/java/com/google/auth/oauth2/EnvironmentProvider.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
/*
2-
* Copyright 2026 Google LLC
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions are
6-
* met:
7-
*
8-
* * Redistributions of source code must retain the above copyright
9-
* notice, this list of conditions and the following disclaimer.
10-
* * Redistributions in binary form must reproduce the above
11-
* copyright notice, this list of conditions and the following disclaimer
12-
* in the documentation and/or other materials provided with the
13-
* distribution.
14-
* * Neither the name of Google LLC nor the names of its
15-
* contributors may be used to endorse or promote products derived from
16-
* this software without specific prior written permission.
17-
*
18-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
*/
30-
311
package com.google.auth.oauth2;
322

333
import com.google.api.core.InternalApi;

oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ private IdentityPoolSubjectTokenSupplier createCertificateSubjectTokenSupplier(
176176

177177
private X509Provider getX509Provider(
178178
Builder builder, IdentityPoolCredentialSource credentialSource) {
179+
final IdentityPoolCredentialSource.CertificateConfig certConfig =
180+
credentialSource.getCertificateConfig();
181+
179182
// Use the provided X509Provider if available, otherwise initialize a default one.
180183
X509Provider x509Provider = builder.x509Provider;
181184
if (x509Provider == null) {
@@ -190,9 +193,6 @@ private X509Provider getX509Provider(
190193
private static String getExplicitCertConfigPath(IdentityPoolCredentialSource credentialSource) {
191194
IdentityPoolCredentialSource.CertificateConfig certConfig =
192195
credentialSource.getCertificateConfig();
193-
if (certConfig == null) {
194-
return null;
195-
}
196196
return certConfig.useDefaultCertificateConfig()
197197
? null
198198
: certConfig.getCertificateConfigLocation();

oauth2_http/java/com/google/auth/oauth2/PropertyProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2026 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are

oauth2_http/java/com/google/auth/oauth2/SystemPropertyProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2026 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are

oauth2_http/javatests/com/google/auth/mtls/MtlsUtilsTest.java

Lines changed: 0 additions & 246 deletions
This file was deleted.

oauth2_http/javatests/com/google/auth/mtls/X509ProviderTest.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -169,43 +169,4 @@ void x509Provider_succeeds_withWindowsPath()
169169
assertEquals(1, store.size());
170170
assertNotNull(store.getCertificateAlias(expectedCert));
171171
}
172-
173-
@Test
174-
void x509Provider_certFileDoesntExist_throws() throws IOException {
175-
Path tempConfig = Files.createTempFile("config", ".json");
176-
tempConfig.toFile().deleteOnExit();
177-
Path nonExistentCert = tempConfig.getParent().resolve("non_existent_cert.pem");
178-
179-
Files.write(
180-
tempConfig,
181-
("{\"cert_configs\":{\"workload\":{\"cert_path\":\""
182-
+ nonExistentCert.toString()
183-
+ "\",\"key_path\":\"key.pem\"}}}")
184-
.getBytes());
185-
186-
X509Provider testProvider = new X509Provider(tempConfig.toString());
187-
188-
assertThrows(IOException.class, testProvider::getKeyStore);
189-
}
190-
191-
@Test
192-
void x509Provider_malformedCert_throws() throws IOException {
193-
Path tempConfig = Files.createTempFile("config", ".json");
194-
tempConfig.toFile().deleteOnExit();
195-
Path malformedCert = Files.createTempFile("badcert", ".pem");
196-
malformedCert.toFile().deleteOnExit();
197-
198-
Files.write(malformedCert, "This is not a valid certificate".getBytes());
199-
200-
Files.write(
201-
tempConfig,
202-
("{\"cert_configs\":{\"workload\":{\"cert_path\":\""
203-
+ malformedCert.toString()
204-
+ "\",\"key_path\":\"key.pem\"}}}")
205-
.getBytes());
206-
207-
X509Provider testProvider = new X509Provider(tempConfig.toString());
208-
209-
assertThrows(Exception.class, testProvider::getKeyStore);
210-
}
211172
}

oauth2_http/javatests/com/google/auth/oauth2/TestPropertyProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2026 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are

0 commit comments

Comments
 (0)