From 4e05cee6f044bab8af13e7608167b58a89c2030d Mon Sep 17 00:00:00 2001 From: Adriano Cunha <35786489+adrcunha@users.noreply.github.com> Date: Mon, 14 Jan 2019 10:28:30 -0800 Subject: [PATCH] Remove trailing LF and spaces from a GitHub token (#389) They break the authentication if present. --- scripts/release.sh | 3 ++- test/unit/release-tests.sh | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index f71fb85cc8..839d53d87c 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -194,7 +194,8 @@ function parse_flags() { case ${parameter} in --github-token) [[ ! -f "$1" ]] && abort "file $1 doesn't exist" - GITHUB_TOKEN="$(cat $1)" + # Remove any trailing newline/space from token + GITHUB_TOKEN="$(echo -n $(cat $1))" [[ -n "${GITHUB_TOKEN}" ]] || abort "file $1 is empty" ;; --release-gcr) diff --git a/test/unit/release-tests.sh b/test/unit/release-tests.sh index 168340b607..1451676409 100755 --- a/test/unit/release-tests.sh +++ b/test/unit/release-tests.sh @@ -61,6 +61,10 @@ test_function ${SUCCESS} "" parse_flags --release-gcs a --publish test_function ${FAILURE} "error: missing parameter" initialize --release-gcr test_function ${SUCCESS} "" parse_flags --release-gcr a --publish +token_file=$(mktemp) +echo -e "abc " > ${token_file} +test_function ${SUCCESS} ":abc:" call_function_post "echo :\$GITHUB_TOKEN:" initialize --github-token ${token_file} + echo ">> Testing GCR/GCS values" test_function ${SUCCESS} "GCR flag is ignored" initialize --release-gcr foo