Skip to content

Commit 765eb3b

Browse files
committed
test(auth): add unit test in MtlsUtilsTest to provide coverage for ECP flow in getCertificatePath
1 parent 9be88f6 commit 765eb3b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ public String getProperty(String name, String def) {
101101
() -> MtlsUtils.getCertificatePath(envProvider, propProvider, configFile.toString()));
102102
}
103103

104+
@Test
105+
void getCertificatePath_ecpOnlyConfig_throwsCertificateSourceUnavailableException()
106+
throws IOException {
107+
Path configFile = tempDir.resolve("ecp_config.json");
108+
Files.write(
109+
configFile, "{\"cert_configs\":{\"enterprise_certificates\":{\"libs\":[]}}}".getBytes());
110+
111+
EnvironmentProvider envProvider = name -> null;
112+
PropertyProvider propProvider = (name, def) -> def;
113+
114+
assertThrows(
115+
CertificateSourceUnavailableException.class,
116+
() -> MtlsUtils.getCertificatePath(envProvider, propProvider, configFile.toString()));
117+
}
118+
104119
@Test
105120
void getWorkloadCertificateConfiguration_overridePath() throws IOException {
106121
Path configFile = tempDir.resolve("custom_config.json");

0 commit comments

Comments
 (0)