Skip to content

Commit

Permalink
add quotes to fix `Double quote to prevent globbing and word splittin…
Browse files Browse the repository at this point in the history
…g.` error in repo health pipeline

Signed-off-by: ayush-billore <ayush.billore@progress.com>
  • Loading branch information
ayush-billore committed Jul 17, 2023
1 parent 4cbfc26 commit c07b530
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions .studio/chef-server-collection
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,15 @@ test_if_login_working_with_correct_credentials() {
bootstrap_chef_user_data || return 1
local url="https://${chef_server_hostname}/id/auth/chef/callback"

res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" $url \
res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" "$url" \
--header 'x-requested-with: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'utf8=✓' \
--data-urlencode "username=$chef_server_test_admin_user_email" \
--data-urlencode "password=$chef_server_test_user_password" \
--data-urlencode 'commit=Sign+In')

if [ $res_code == 200 ]; then
if [ "$res_code" == 200 ]; then
echo "User Logged In"
else
echo "Error Logging in with test admin user"
Expand All @@ -427,15 +427,15 @@ test_if_login_failing_with_incorrect_credentials() {
local url="https://${chef_server_hostname}/id/auth/chef/callback"
local incorrect_password='incorrect-password'

res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" $url \
res_code=$(hab_curl --insecure -H -s -o /dev/null -w "%{http_code}" "$url" \
--header 'x-requested-with: XMLHttpRequest' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'utf8=✓' \
--data-urlencode "username=$chef_server_test_admin_user_email" \
--data-urlencode "password=$incorrect_password" \
--data-urlencode 'commit=Sign+In')

if [ $res_code == 302 ]; then
if [ "$res_code" == 302 ]; then
echo "Login call returns HTTP STATUS 302 as expected for invalid credentials"
else
echo "Login call did not return HTTP STATUS 302 for invalid credentials"
Expand All @@ -450,21 +450,21 @@ test_if_env_vars_are_configured() {
ocid_config_file_path="$(hab pkg path chef/oc_id)/oc_id/config/settings/production.yml"

# Get values from in settings/production.yml
endpoint=$(awk '/endpoint:/ {print $2}' $ocid_config_file_path)
superuser=$(awk '/superuser:/ {print $2}' $ocid_config_file_path)
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' $ocid_config_file_path)
endpoint=$(awk '/endpoint:/ {print $2}' "$ocid_config_file_path")
superuser=$(awk '/superuser:/ {print $2}' "$ocid_config_file_path")
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' "$ocid_config_file_path")

errors=()

if [ $endpoint != "https://127.0.0.1:443" ]; then
if [ "$endpoint" != "https://127.0.0.1:443" ]; then
errors+=("Chef-Server endpoint is not configured properly.")
fi

if [ $superuser != "pivotal" ]; then
if [ "$superuser" != "pivotal" ]; then
errors+=("Chef-Server superuser is not configured properly.")
fi

if [ $ssl_verify_mode != "verify_none" ]; then
if [ "$ssl_verify_mode" != "verify_none" ]; then
errors+=("Chef-Server SSL certificate verification mode is not configured properly.")
fi

Expand Down Expand Up @@ -504,7 +504,7 @@ test_if_webui_key_is_patched() {

# elem variable hold the value 'chef-server', we opted for this syntax becz chef-server needs to be
# to be treated as string as it contains `-`, which is not a valid JSON character
ocid_webui_key="$(jq --arg elem "chef-server" -r '.[$elem]."webui_key"' < $ocid_secrets_file_path)"
ocid_webui_key="$(jq --arg elem "chef-server" -r '.[$elem]."webui_key"' < "$ocid_secrets_file_path")"

# Create a temporary file with the ocid_webui_key content
echo "$ocid_webui_key" > temp_ocid_webui_key.pem
Expand Down Expand Up @@ -549,17 +549,17 @@ test_if_env_vars_are_configured_after_patch() {
ocid_config_file_path="$(hab pkg path chef/oc_id)/oc_id/config/settings/production.yml"

# Get values from in settings/production.yml
endpoint=$(awk '/endpoint:/ {print $2}' $ocid_config_file_path)
superuser=$(awk '/superuser:/ {print $2}' $ocid_config_file_path)
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' $ocid_config_file_path)
endpoint=$(awk '/endpoint:/ {print $2}' "$ocid_config_file_path")
superuser=$(awk '/superuser:/ {print $2}' "$ocid_config_file_path")
ssl_verify_mode=$(awk '/ssl_verify_mode:/ {print $2}' "$ocid_config_file_path")

errors=()

if [ $endpoint != "https://test-url.com:443" ]; then
if [ "$endpoint" != "https://test-url.com:443" ]; then
errors+=("Chef-Server endpoint is not configured properly.")
fi

if [ $superuser != "testuser" ]; then
if [ "$superuser" != "testuser" ]; then
errors+=("Chef-Server superuser is not configured properly.")
fi

Expand Down Expand Up @@ -589,11 +589,11 @@ test_if_oauthapps_are_patched_correctly() {

errors=()

if [ $name != "test-supermarket" ]; then
if [ "$name" != "test-supermarket" ]; then
errors+=("Registered OAuth application's name is not patched correctly.")
fi

if [ $redirect_uri != "https://sampleurl.com/auth/chef_oauth2/callback" ]; then
if [ "$redirect_uri" != "https://sampleurl.com/auth/chef_oauth2/callback" ]; then
errors+=("Registered OAuth application's redirect URI is not configured correctly.")
fi

Expand Down

0 comments on commit c07b530

Please sign in to comment.