Skip to content

Commit

Permalink
Remove trailing LF and spaces from a GitHub token (knative#389)
Browse files Browse the repository at this point in the history
They break the authentication if present.
  • Loading branch information
adrcunha authored and knative-prow-robot committed Jan 14, 2019
1 parent 26a29df commit 4e05cee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/unit/release-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e05cee

Please sign in to comment.