22
22
import io .fabric8 .kubernetes .api .model .NamedContextBuilder ;
23
23
import io .fabric8 .kubernetes .client .Config ;
24
24
import io .fabric8 .kubernetes .client .ConfigBuilder ;
25
+ import io .fabric8 .kubernetes .client .http .TestStandardHttpClient ;
25
26
import io .fabric8 .kubernetes .client .http .TestStandardHttpClientBuilder ;
26
27
import io .fabric8 .kubernetes .client .http .TestStandardHttpClientFactory ;
27
28
import org .assertj .core .api .InstanceOfAssertFactories ;
@@ -116,6 +117,7 @@ void setUp() throws Exception {
116
117
authProviderConfig .put ("id-token" , "original-token" );
117
118
authProviderConfig .put ("idp-issuer-url" , "https://auth.fabric8.example.com" );
118
119
authProviderConfig .put ("client-id" , "id-of-test-client" );
120
+ authProviderConfig .put ("client-secret" , "secret-of-test-client" );
119
121
}
120
122
121
123
@ AfterEach
@@ -359,7 +361,7 @@ void updatesCurrentConfigAuthProviderConfigWithNewTokenInFile() throws Exception
359
361
360
362
@ Test
361
363
@ DisplayName ("Certificate is loaded into HttpClient trust manager" )
362
- void certificateIsLoadedIntoHttpClientTrustManager () throws Exception {
364
+ void certificateIsLoadedIntoHttpClientTrustManager () {
363
365
assertThat (httpClientBuilder .getTrustManagers ())
364
366
.singleElement ()
365
367
.asInstanceOf (InstanceOfAssertFactories .type (X509ExtendedTrustManager .class ))
@@ -369,6 +371,20 @@ void certificateIsLoadedIntoHttpClientTrustManager() throws Exception {
369
371
.extracting (Principal ::getName )
370
372
.contains ("CN=auth.fabric8.example.com" );
371
373
}
374
+
375
+ @ Test
376
+ @ DisplayName ("Token refresh request contains valid auth and form data" )
377
+ void tokenRefreshRequestContainsValidFormData () {
378
+ assertThat (httpClientBuilder .build ().getRecordedConsumeBytesDirects ())
379
+ .filteredOn (r -> r .getRequest ().uri ().getPath ().equals ("/token" ))
380
+ .singleElement ()
381
+ .extracting (TestStandardHttpClient .RecordedConsumeBytesDirect ::getRequest )
382
+ .hasFieldOrPropertyWithValue ("method" , "POST" )
383
+ .hasFieldOrPropertyWithValue ("contentType" , "application/x-www-form-urlencoded" )
384
+ .hasFieldOrPropertyWithValue ("bodyString" ,
385
+ "refresh_token=original-refresh-token&grant_type=refresh_token&client_id=id-of-test-client&client_secret=secret-of-test-client" )
386
+ .returns ("Basic aWQtb2YtdGVzdC1jbGllbnQ6c2VjcmV0LW9mLXRlc3QtY2xpZW50" , r -> r .header ("Authorization" ));
387
+ }
372
388
}
373
389
}
374
390
}
0 commit comments