22
33import com .google .protobuf .Struct ;
44import com .google .protobuf .Value ;
5- import io .grpc .ClientInterceptor ;
65import io .grpc .Metadata ;
76import io .grpc .Server ;
87import io .grpc .ServerBuilder ;
@@ -89,17 +88,23 @@ void testKeystoreSSLContext() throws Exception{
8988
9089 }
9190
91+
92+ @ Test
93+ public void testPlatformPlainTextAndIDPWithSSL () throws Exception {
94+ sdkServicesSetup (false , true );
95+ }
96+
9297 @ Test
9398 void testSDKServicesWithTruststore () throws Exception {
94- sdkServicesSetup (true );
99+ sdkServicesSetup (true , true );
95100 }
96101
97102 @ Test
98103 void testCreatingSDKServicesPlainText () throws Exception {
99- sdkServicesSetup (false );
104+ sdkServicesSetup (false , false );
100105 }
101106
102- void sdkServicesSetup (boolean useSSL ) throws Exception {
107+ void sdkServicesSetup (boolean useSSLPlatform , boolean useSSLIDP ) throws Exception {
103108
104109 HeldCertificate rootCertificate = new HeldCertificate .Builder ()
105110 .certificateAuthority (0 )
@@ -122,7 +127,7 @@ void sdkServicesSetup(boolean useSSL) throws Exception{
122127 // * it returns the OIDC configuration we use at bootstrapping time
123128 // * it fakes out being an IDP and returns an access token when need to retrieve an access token
124129 try (MockWebServer httpServer = new MockWebServer ()) {
125- if (useSSL ){
130+ if (useSSLIDP ){
126131 httpServer .useHttps (serverHandshakeCertificates .sslSocketFactory (), false );
127132 }
128133 String oidcConfig ;
@@ -179,7 +184,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re
179184 return next .startCall (call , headers );
180185 }
181186 });
182- if (useSSL ){
187+ if (useSSLPlatform ){
183188 platformServicesServerBuilder = platformServicesServerBuilder .useTransportSecurity (
184189 new ByteArrayInputStream (serverCertificate .certificatePem ().getBytes ()),
185190 new ByteArrayInputStream (serverCertificate .privateKeyPkcs8Pem ().getBytes ()));
@@ -207,7 +212,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re
207212 }
208213 });
209214
210- if (useSSL ){
215+ if (useSSLPlatform ){
211216 kasServerBuilder = kasServerBuilder .useTransportSecurity (
212217 new ByteArrayInputStream (serverCertificate .certificatePem ().getBytes ()),
213218 new ByteArrayInputStream (serverCertificate .privateKeyPkcs8Pem ().getBytes ()));
@@ -220,15 +225,16 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re
220225 .clientSecret ("client-id" , "client-secret" )
221226 .platformEndpoint ("localhost:" + platformServicesServer .getPort ());
222227
223- if (!useSSL ) {
228+ if (!useSSLPlatform ) {
224229 servicesBuilder = servicesBuilder .useInsecurePlaintextConnection (true );
225- }else {
230+ }
231+ if (useSSLPlatform || useSSLIDP ){
226232 servicesBuilder = servicesBuilder .sslFactory (SSLFactory .builder ().withTrustMaterial (rootCertificate .
227233 certificate ()).build ());
228234 }
229235
230236 var servicesAndComponents = servicesBuilder .buildServices ();
231- if (useSSL ) {
237+ if (useSSLPlatform || useSSLIDP ) {
232238 assertThat (servicesAndComponents .trustManager ).isNotNull ();
233239 }
234240 assertThat (servicesAndComponents .interceptor ).isNotNull ();
0 commit comments