@Primary
  @Bean("OkHttpClient")
  public OkHttpClient provide(Configuration config, SonarQubeVersion version) {
    OkHttpClientBuilder builder = new OkHttpClientBuilder();
    builder.setConnectTimeoutMs(DEFAULT_CONNECT_TIMEOUT_IN_MS);
    builder.setReadTimeoutMs(DEFAULT_READ_TIMEOUT_IN_MS);
    // no need to define proxy URL as system-wide proxy is used and properly
    // configured by bootstrap process.
    builder.setProxyLogin(config.get(HTTP_PROXY_USER.getKey()).orElse(null));
    builder.setProxyPassword(config.get(HTTP_PROXY_PASSWORD.getKey()).orElse(null));
    builder.setUserAgent(format("SonarQube/%s", version));
    return builder.build();
  }
@Test
  public void get_returns_a_OkHttpClient_with_proxy_authentication() throws Exception {
    settings.setProperty(HTTP_PROXY_USER, "the-login");
    settings.setProperty(HTTP_PROXY_PASSWORD, "the-password");

    OkHttpClient client = underTest.provide(settings.asConfig(), sonarQubeVersion);
    Response response = new Response.Builder().protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://foo").build()).code(407)
      .message("").build();
    Request request = client.proxyAuthenticator().authenticate(null, response);

    assertThat(request.header("Proxy-Authorization")).isEqualTo("Basic " + Base64.getEncoder().encodeToString("the-login:the-password".getBytes()));
  }