2222import io .fabric8 .kubernetes .api .model .NamedContextBuilder ;
2323import io .fabric8 .kubernetes .client .Config ;
2424import io .fabric8 .kubernetes .client .ConfigBuilder ;
25+ import io .fabric8 .kubernetes .client .http .TestStandardHttpClient ;
2526import io .fabric8 .kubernetes .client .http .TestStandardHttpClientBuilder ;
2627import io .fabric8 .kubernetes .client .http .TestStandardHttpClientFactory ;
2728import org .assertj .core .api .InstanceOfAssertFactories ;
@@ -116,6 +117,7 @@ void setUp() throws Exception {
116117 authProviderConfig .put ("id-token" , "original-token" );
117118 authProviderConfig .put ("idp-issuer-url" , "https://auth.fabric8.example.com" );
118119 authProviderConfig .put ("client-id" , "id-of-test-client" );
120+ authProviderConfig .put ("client-secret" , "secret-of-test-client" );
119121 }
120122
121123 @ AfterEach
@@ -359,7 +361,7 @@ void updatesCurrentConfigAuthProviderConfigWithNewTokenInFile() throws Exception
359361
360362 @ Test
361363 @ DisplayName ("Certificate is loaded into HttpClient trust manager" )
362- void certificateIsLoadedIntoHttpClientTrustManager () throws Exception {
364+ void certificateIsLoadedIntoHttpClientTrustManager () {
363365 assertThat (httpClientBuilder .getTrustManagers ())
364366 .singleElement ()
365367 .asInstanceOf (InstanceOfAssertFactories .type (X509ExtendedTrustManager .class ))
@@ -369,6 +371,20 @@ void certificateIsLoadedIntoHttpClientTrustManager() throws Exception {
369371 .extracting (Principal ::getName )
370372 .contains ("CN=auth.fabric8.example.com" );
371373 }
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+ }
372388 }
373389 }
374390 }
0 commit comments