Skip to content

Commit

Permalink
Fixes base64 encoded hardcoded admin credentials
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Feb 14, 2024
1 parent d703887 commit 5f5e981
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5f5e981

Please sign in to comment.