Skip to content

Commit

Permalink
fix: bash avoiding newline when Base64 encoding a long string (#2437)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Oct 22, 2024
1 parent 022c35f commit ec01d2f
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Base/check-grid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e

HOST="localhost"
PORT="4444"
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

echoerr() { echo "$@" 1>&2; }

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ chart_test_autoscaling_job:

chart_test_autoscaling_playwright_connect_grid:
PLATFORMS=$(PLATFORMS) CHART_ENABLE_TRACING=true CHART_ENABLE_BASIC_AUTH=true MATRIX_TESTS=CDPTests \
BASIC_AUTH_USERNAME=docker-selenium BASIC_AUTH_PASSWORD=2NMI4jdBi6k7bENoeUfV25295VvzwAE9chM24a+2VL95uOHozo \
SECURE_INGRESS_ONLY_DEFAULT=true SECURE_USE_EXTERNAL_CERT=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=$$(hostname -i) SELENIUM_GRID_PORT=443 \
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) \
TEMPLATE_OUTPUT_FILENAME="k8s_playwright_connect_grid_basicAuth_secureIngress_ingressPublicIP_autoScaling_patchKEDA.yaml" \
Expand Down
2 changes: 1 addition & 1 deletion Video/validate_endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ graphql_endpoint=${2:-false}
max_time=1
process_name="endpoint.checks"

BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ "${graphql_endpoint}" = "true" ]; then
endpoint_checks=$(curl --noproxy "*" -m ${max_time} -k -X POST \
Expand Down
2 changes: 1 addition & 1 deletion Video/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else
fi

/opt/bin/validate_endpoint.sh "${NODE_STATUS_ENDPOINT}"
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ -d "${VIDEO_FOLDER}" ]; then
echo "$(date +%FT%T%Z) [${process_name}] - Video folder exists: ${VIDEO_FOLDER}"
Expand Down
2 changes: 1 addition & 1 deletion Video/video_graphQLQuery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [[ -n ${GRAPHQL_ENDPOINT} ]] && [[ ! ${GRAPHQL_ENDPOINT} == */graphql ]]; the
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}/graphql"
fi

BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

VIDEO_CAP_NAME=${VIDEO_CAP_NAME:-"se:recordVideo"}
TEST_NAME_CAP=${TEST_NAME_CAP:-"se:name"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"}
ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/bin"}

GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh)
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ -z "${GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now."
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/configs/node/nodeGridUrl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

max_time=3

BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ "${SE_SUB_PATH}" = "/" ]; then
SE_SUB_PATH=""
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/configs/node/nodePreStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function signal_hub_to_drain_node() {
return_list=($(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh))
grid_url=${return_list[0]}
grid_check=${return_list[1]}
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"
if [ -n "${grid_url}" ]; then
if [ "${grid_check}" = "401" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Hub/Router requires authentication. Please check SE_ROUTER_USERNAME and SE_ROUTER_PASSWORD."
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/configs/node/nodeProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE
return_list=($(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh))
grid_url=${return_list[0]}
grid_check=${return_list[1]}
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ -n "${grid_url}" ]; then
if [ "${grid_check}" = "401" ]; then
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/configs/router/routerProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"}
ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/bin"}

GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh)
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64 -w0)"

if [ -z "${GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now."
Expand Down
2 changes: 1 addition & 1 deletion tests/CDPTests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SELENIUM_REMOTE_URL="${SELENIUM_GRID_PROTOCOL}://${SELENIUM_GRID_HOST}:${SELENIU
echo "SELENIUM_REMOTE_URL=${SELENIUM_REMOTE_URL}" > .env

if [ -n ${SELENIUM_GRID_USERNAME} ] && [ -n ${SELENIUM_GRID_PASSWORD} ]; then
BASIC_AUTH="$(echo -n "${SELENIUM_GRID_USERNAME}:${SELENIUM_GRID_PASSWORD}" | base64)"
BASIC_AUTH="$(echo -en "${SELENIUM_GRID_USERNAME}:${SELENIUM_GRID_PASSWORD}" | base64 -w0)"
echo "SELENIUM_REMOTE_HEADERS={\"Authorization\": \"Basic ${BASIC_AUTH}\"}" >> .env
fi

Expand Down

0 comments on commit ec01d2f

Please sign in to comment.