From a639ca93bc611d02308471139121c1f00776f804 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com> Date: Mon, 12 Feb 2024 01:08:16 -0500 Subject: [PATCH] [Backport 2.x] Updates integTest behavior to accept the version and set the password accordingly and removes admin:admin reference from the Handbook (#1327) * Remove references to admin:admin (#1298) * Remove references to admin:admin Signed-off-by: Derek Ho * Try to pass in initial admin password via env variable Signed-off-by: Derek Ho * Try using the env variable Signed-off-by: Derek Ho * Revert file deletion and add logic for integration tests Signed-off-by: Derek Ho * fix env variable Signed-off-by: Derek Ho * Update logic to be the same across all repos Signed-off-by: Derek Ho * Keep old logic Signed-off-by: Derek Ho * Change variable name Signed-off-by: Derek Ho --------- Signed-off-by: Derek Ho (cherry picked from commit 3ea239b5b308b8c053511fb2da79ac37f12b2340) Signed-off-by: Darshit Chanpura * Updates integTest behavior to accept the version and set the password accordingly Signed-off-by: Darshit Chanpura (cherry picked from commit d703887f88f24c444e0513ebeca21e30b93354f8) --------- Signed-off-by: Derek Ho Signed-off-by: Darshit Chanpura Co-authored-by: Derek Ho --- HANDBOOK.md | 2 +- scripts/integtest.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) mode change 100755 => 100644 scripts/integtest.sh diff --git a/HANDBOOK.md b/HANDBOOK.md index 543b041e..e14f975b 100644 --- a/HANDBOOK.md +++ b/HANDBOOK.md @@ -66,7 +66,7 @@ plugins.security.nodes_dn_dynamic_config_enabled: true Allow connections from follower cluster on the leader as follows ```bash -curl -k -u admin:admin -XPUT "https://${LEADER}/_plugins/_security/api/nodesdn/follower" \ +curl -k -u admin: -XPUT "https://${LEADER}/_plugins/_security/api/nodesdn/follower" \ -H 'Content-type: application/json' \ -d'{"nodes_dn": ["CN=follower.example.com"]}' ``` diff --git a/scripts/integtest.sh b/scripts/integtest.sh old mode 100755 new mode 100644 index 1a0498ae..ad59f3c7 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -50,7 +50,7 @@ while getopts ":h:b:p:t:e:s:c:v:" arg; do CREDENTIAL=$OPTARG ;; v) - # Do nothing as we're not consuming this param. + OPENSEARCH_VERSION=$OPTARG ;; :) echo "-${OPTARG} requires an argument" @@ -70,9 +70,20 @@ then SECURITY_ENABLED="true" fi +OPENSEARCH_REQUIRED_VERSION="2.12.0" + if [ -z "$CREDENTIAL" ] then - CREDENTIAL="admin:admin" + # Starting in 2.12.0, security demo configuration script requires an initial admin password + # Pick the minimum of two versions + VERSION_TO_COMPARE=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` + # Check if the compared version is not equal to the required version. + # If it is not equal, it means the current version is older. + if [ "$VERSION_TO_COMPARE" != "$OPENSEARCH_REQUIRED_VERSION" ]; then + CREDENTIAL="admin:admin" + else + CREDENTIAL="admin:myStrongPassword123!" + fi fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`