Fix incorrect log warning when exporting monitoring via HTTP without authentication (#57552)
This commit is contained in:
parent
79ac69cfa3
commit
97a51272b0
|
@ -764,9 +764,15 @@ public class HttpExporter extends Exporter {
|
|||
* @throws SettingsException if the username is missing, but a password is supplied
|
||||
*/
|
||||
@Nullable
|
||||
private static CredentialsProvider createCredentialsProvider(final Config config) {
|
||||
// visible for testing
|
||||
static CredentialsProvider createCredentialsProvider(final Config config) {
|
||||
final String username = AUTH_USERNAME_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings());
|
||||
|
||||
if (Strings.isNullOrEmpty(username)) {
|
||||
// nothing to configure; default situation for most users
|
||||
return null;
|
||||
}
|
||||
|
||||
final String deprecatedPassword = AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings());
|
||||
final SecureString securePassword = SECURE_AUTH_PASSWORDS.get(config.name());
|
||||
final String password;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.monitoring.exporter.http;
|
||||
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
|
||||
|
@ -356,6 +357,17 @@ public class HttpExporterTests extends ESTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testCreateCredentialsProviderWithoutSecurity() {
|
||||
final Settings.Builder builder = Settings.builder()
|
||||
.put("xpack.monitoring.exporters._http.type", "http")
|
||||
.put("xpack.monitoring.exporters._http.host", "http://localhost:9200");
|
||||
|
||||
final Config config = createConfig(builder.build());
|
||||
CredentialsProvider provider = HttpExporter.createCredentialsProvider(config);
|
||||
|
||||
assertNull(provider);
|
||||
}
|
||||
|
||||
public void testCreateSnifferDisabledByDefault() {
|
||||
final Config config = createConfig(Settings.EMPTY);
|
||||
final RestClient client = mock(RestClient.class);
|
||||
|
|
Loading…
Reference in New Issue