Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
[actions] test with expired token
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Jan 17, 2023
1 parent 2d6e6ae commit 78c41af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dev_utils/keys/sign_jwt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sign() {
algo=${1:-RS256}
algo=${algo^^}
header=$(build_header "$algo") || return
payload=${3:-$test_payload}
payload=${4:-$test_payload}
signed_content="$(json <<<"$header" | b64enc).$(json <<<"$payload" | b64enc)"
case $algo in
RS*) sig=$(printf %s "$signed_content" | rs_sign "${algo#RS}" "$secret" | b64enc) ;;
Expand All @@ -53,7 +53,7 @@ sign() {
}

iat=$(date +%s)
exp=$(date --date=tomorrow +%s)
exp=$(date --date="${3:-tomorrow}" +%s)

test_payload='{
"at_hash": "J_fA458SPsXFV6lJQL1l-w",
Expand Down
8 changes: 8 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,12 @@ echo "Trying to change the access logging for a bucket"
s3cmd -c proxyS3 accesslog s3://dummy/ 2>&1 | grep -q "$nobucket"
check_output_status "$?"

token="$(bash keys/sign_jwt.sh ES256 /keys/jwt.key yesterday)"
sed -i "s/^access_token=.*/access_token=$token/" proxyS3

# Test access with expired token
echo "Test access with expired token"
s3cmd -c proxyS3 ls s3://dummy/README.md 2>&1 | grep -q "$unauthorized"
check_output_status "$?"

echo "All tests have passed"

0 comments on commit 78c41af

Please sign in to comment.