From 5f5e9816724e578a7b832ac6c5c95887a6a87e0f Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Wed, 14 Feb 2024 16:38:13 -0500 Subject: [PATCH] Fixes base64 encoded hardcoded admin credentials Signed-off-by: Darshit Chanpura --- .../org/opensearch/replication/MultiClusterRestTestCase.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt index 090bdf006..ced4d9780 100644 --- a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt @@ -63,6 +63,7 @@ import java.security.KeyStore import java.security.KeyStoreException import java.security.NoSuchAlgorithmException import java.security.cert.CertificateException +import java.util.Base64 import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicReference import java.util.Collections @@ -233,8 +234,10 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() { for ((key, value) in headers) { defaultHeaders[i++] = BasicHeader(key, value) } + + val creds = System.getProperty("user", "admin") + System.getProperty("password", "myStrongPassword123!"); if(securityEnabled) { - defaultHeaders[i++] = BasicHeader("Authorization", "Basic YWRtaW46YWRtaW4=") + defaultHeaders[i++] = BasicHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString(creds.toByteArray())) } builder.setDefaultHeaders(defaultHeaders)