### Question:
XPackAuth implements Auth<HttpClientConfig.Builder> { @Override public void configure(HttpClientConfig.Builder builder) { credentials.applyTo(builder); if (certInfo != null) { certInfo.applyTo(builder); } } protected  XPackAuth(Credentials<HttpClientConfig.Builder> credentials, CertInfo<HttpClientConfig.Builder> certInfo); @Override void configure(HttpClientConfig.Builder builder); @PluginBuilderFactory static XPackAuth.Builder newBuilder();  }### Answer:
@Test public void appliesCredentialsIfConfigured() { Credentials<HttpClientConfig.Builder> credentials = Mockito.mock(Credentials.class); HttpClientConfig.Builder settingsBuilder = createDefaultClientConfigBuilder(); XPackAuth xPackAuth = createTestBuilder() .withCredentials(credentials) .build(); xPackAuth.configure(settingsBuilder); verify(credentials).applyTo(builderArgumentCaptor.capture()); Assert.assertEquals(settingsBuilder, builderArgumentCaptor.getValue()); }
@Test public void appliesCertInfoIfConfigured() { CertInfo<HttpClientConfig.Builder> certInfo = Mockito.mock(CertInfo.class); HttpClientConfig.Builder settingsBuilder = createDefaultClientConfigBuilder(); XPackAuth xPackAuth = createTestBuilder() .withCertInfo(certInfo) .build(); xPackAuth.configure(settingsBuilder); verify(certInfo).applyTo(builderArgumentCaptor.capture()); Assert.assertEquals(settingsBuilder, builderArgumentCaptor.getValue()); }
@Test public void doesntApplyCertInfoIfNotConfigured() { XPackAuth auth = createTestBuilder() .withCertInfo(null) .build(); HttpClientConfig.Builder settingsBuilder = spy(createDefaultClientConfigBuilder()); auth.configure(settingsBuilder); verify(settingsBuilder, never()).sslSocketFactory(any()); verify(settingsBuilder, never()).httpsIOSessionStrategy(any()); }