EurekaClientOAuth2AutoConfiguration { @Bean @ConditionalOnMissingBean(DiscoveryClientOptionalArgs.class) public OAuth2DiscoveryClientOptionalArgs discoveryClientOptionalArgs( EurekaClientOAuth2Properties eurekaClientOAuth2Properties) { ClientRegistration clientRegistration = ClientRegistration.withRegistrationId("eureka-client") .clientId(eurekaClientOAuth2Properties.getClientId()) .clientSecret(eurekaClientOAuth2Properties.getClientSecret()) .tokenUri(eurekaClientOAuth2Properties.getAccessTokenUri()) .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS).build(); return new OAuth2DiscoveryClientOptionalArgs(clientRegistration); }  @Bean @ConditionalOnMissingBean(DiscoveryClientOptionalArgs.class) OAuth2DiscoveryClientOptionalArgs discoveryClientOptionalArgs(
			EurekaClientOAuth2Properties eurekaClientOAuth2Properties);  }
@Test public void discoveryClientOptionalArgs() { contextRunner.withPropertyValues("eureka.client.oauth2.client-id=" + CLIENT_ID, "eureka.client.oauth2.client-secret=" + CLIENT_SECRET, "eureka.client.oauth2.access-token-uri=" + TOKEN_URI).run(context -> { assertThat(context).hasSingleBean(OAuth2DiscoveryClientOptionalArgs.class); OAuth2DiscoveryClientOptionalArgs discoveryClientOptionalArgs = context .getBean(OAuth2DiscoveryClientOptionalArgs.class); @SuppressWarnings("unchecked") TransportClientFactories<Void> factories = (TransportClientFactories) ReflectionTestUtils .getField(discoveryClientOptionalArgs, "transportClientFactories"); assertThat(factories).isNotNull(); ClientRegistration clientRegistration = (ClientRegistration) ReflectionTestUtils.getField(factories, "clientRegistration"); assertThat(clientRegistration).isNotNull(); assertThat(clientRegistration.getClientId()).isEqualTo(CLIENT_ID); assertThat(clientRegistration.getClientSecret()).isEqualTo(CLIENT_SECRET); assertThat(clientRegistration.getProviderDetails().getTokenUri()).isEqualTo(TOKEN_URI); assertThat(clientRegistration.getAuthorizationGrantType()).isEqualTo(CLIENT_CREDENTIALS); }); }