3232package com .google .auth .mtls ;
3333
3434import static org .junit .Assert .assertTrue ;
35+ import static org .junit .Assert .fail ;
3536
3637import java .io .ByteArrayInputStream ;
3738import java .io .File ;
4546import java .security .cert .CertificateFactory ;
4647import java .util .HashMap ;
4748import java .util .Map ;
49+ import net .bytebuddy .pool .TypePool .Resolution .Illegal ;
4850import org .junit .Assert ;
4951import org .junit .Test ;
5052
@@ -88,14 +90,10 @@ public class X509ProviderTest {
8890 public void x509Provider_fileDoesntExist_throws () {
8991 String certConfigPath = "badfile.txt" ;
9092 X509Provider testProvider = new TestX509Provider (certConfigPath );
91- String expectedErrorMessage =
92- String .format (
93- "Error reading certificate configuration file value '%s': File does not exist." ,
94- certConfigPath );
93+ String expectedErrorMessage = "File does not exist." ;
9594
9695 CertificateSourceUnavailableException exception =
97- Assert .assertThrows (
98- CertificateSourceUnavailableException .class , () -> testProvider .getKeyStore ());
96+ Assert .assertThrows (CertificateSourceUnavailableException .class , () -> testProvider .getKeyStore ());
9997 assertTrue (exception .getMessage ().contains (expectedErrorMessage ));
10098 }
10199
@@ -107,11 +105,11 @@ public void x509Provider_emptyFile_throws() {
107105 testProvider .addFile (certConfigPath , certConfigStream );
108106 String expectedErrorMessage =
109107 String .format (
110- "Error reading certificate configuration file value '%s': no JSON input found" ,
108+ "no JSON input found" ,
111109 certConfigPath );
112110
113- IOException exception =
114- Assert .assertThrows (IOException .class , () -> testProvider .getKeyStore ());
111+ IllegalArgumentException exception =
112+ Assert .assertThrows (IllegalArgumentException .class , () -> testProvider .getKeyStore ());
115113 assertTrue (exception .getMessage ().contains (expectedErrorMessage ));
116114 }
117115
0 commit comments