|
58 | 58 | import io.grpc.ManagedChannelBuilder; |
59 | 59 | import io.grpc.TlsChannelCredentials; |
60 | 60 | import io.grpc.alts.ComputeEngineChannelBuilder; |
| 61 | +import java.io.File; |
61 | 62 | import java.io.IOException; |
62 | | -import java.io.InputStream; |
63 | 63 | import java.security.GeneralSecurityException; |
64 | 64 | import java.time.Duration; |
65 | 65 | import java.util.ArrayList; |
@@ -993,37 +993,36 @@ void createMtlsToS2AChannelCredentials_missingAllFiles_throws() throws IOExcepti |
993 | 993 | void createMtlsToS2AChannelCredentials_missingRootFile_throws() throws IOException { |
994 | 994 | InstantiatingGrpcChannelProvider provider = |
995 | 995 | InstantiatingGrpcChannelProvider.newBuilder().build(); |
996 | | - InputStream privateKey = this.getClass().getClassLoader().getResourceAsStream("client_key.pem"); |
997 | | - InputStream certChain = this.getClass().getClassLoader().getResourceAsStream("client_cert.pem"); |
| 996 | + File privateKey = new File("src/test/resources/client_key.pem"); |
| 997 | + File certChain = new File("src/test/resources/client_cert.pem"); |
998 | 998 | assertThat(provider.createMtlsToS2AChannelCredentials(null, privateKey, certChain)).isNull(); |
999 | 999 | } |
1000 | 1000 |
|
1001 | 1001 | @Test |
1002 | 1002 | void createMtlsToS2AChannelCredentials_missingKeyFile_throws() throws IOException { |
1003 | 1003 | InstantiatingGrpcChannelProvider provider = |
1004 | 1004 | InstantiatingGrpcChannelProvider.newBuilder().build(); |
1005 | | - InputStream trustBundle = this.getClass().getClassLoader().getResourceAsStream("root_cert.pem"); |
1006 | | - InputStream certChain = this.getClass().getClassLoader().getResourceAsStream("client_cert.pem"); |
| 1005 | + File trustBundle = new File("src/test/resources/root_cert.pem"); |
| 1006 | + File certChain = new File("src/test/resources/client_cert.pem"); |
1007 | 1007 | assertThat(provider.createMtlsToS2AChannelCredentials(trustBundle, null, certChain)).isNull(); |
1008 | 1008 | } |
1009 | 1009 |
|
1010 | 1010 | @Test |
1011 | 1011 | void createMtlsToS2AChannelCredentials_missingCertChainFile_throws() throws IOException { |
1012 | 1012 | InstantiatingGrpcChannelProvider provider = |
1013 | 1013 | InstantiatingGrpcChannelProvider.newBuilder().build(); |
1014 | | - InputStream trustBundle = this.getClass().getClassLoader().getResourceAsStream("root_cert.pem"); |
1015 | | - InputStream privateKey = this.getClass().getClassLoader().getResourceAsStream("client_key.pem"); |
| 1014 | + File trustBundle = new File("src/test/resources/root_cert.pem"); |
| 1015 | + File privateKey = new File("src/test/resources/client_key.pem"); |
1016 | 1016 | assertThat(provider.createMtlsToS2AChannelCredentials(trustBundle, privateKey, null)).isNull(); |
1017 | 1017 | } |
1018 | 1018 |
|
1019 | 1019 | @Test |
1020 | 1020 | void createMtlsToS2AChannelCredentials_success() throws IOException { |
1021 | 1021 | InstantiatingGrpcChannelProvider provider = |
1022 | 1022 | InstantiatingGrpcChannelProvider.newBuilder().build(); |
1023 | | - InputStream trustBundle = this.getClass().getClassLoader().getResourceAsStream("root_cert.pem"); |
1024 | | - InputStream privateKey = this.getClass().getClassLoader().getResourceAsStream("client_key.pem"); |
1025 | | - InputStream certChain = this.getClass().getClassLoader().getResourceAsStream("client_cert.pem"); |
1026 | | - assertThat(trustBundle).isNotNull(); |
| 1023 | + File trustBundle = new File("src/test/resources/root_cert.pem"); |
| 1024 | + File privateKey = new File("src/test/resources/client_key.pem"); |
| 1025 | + File certChain = new File("src/test/resources/client_cert.pem"); |
1027 | 1026 | assertEquals( |
1028 | 1027 | provider.createMtlsToS2AChannelCredentials(trustBundle, privateKey, certChain).getClass(), |
1029 | 1028 | TlsChannelCredentials.class); |
|
0 commit comments