Skip to content

Commit d021811

Browse files
authored
Merge pull request #111 from DrDaveD/add-exchange-test
add minsecsexchange test
2 parents dafc55a + be0c5d6 commit d021811

File tree

1 file changed

+24
-0
lines changed
  • tests/008-minsecsexchange

1 file changed

+24
-0
lines changed

tests/008-minsecsexchange/main

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# assumes vault token is already present and assumes any access token
2+
# cached in vault is not close to its expiration
3+
set -e
4+
# make sure there's an exchanged token
5+
htgettoken --nooidc --nokerberos --nossh -a $VAULTSERVER -i $ISSUER --scopes="$TESTSCOPES"
6+
EXPTIME="$(htdecodetoken|jq -r .exp)"
7+
# make sure that the same token is returned from cache the second try
8+
htgettoken --nooidc --nokerberos --nossh -a $VAULTSERVER -i $ISSUER --scopes="$TESTSCOPES"
9+
EXPTIME2="$(htdecodetoken|jq -r .exp)"
10+
if [ "$EXPTIME" != "$EXPTIME2" ]; then
11+
echo "The same token was not received twice from vault!"
12+
exit 1
13+
fi
14+
# make sure that we don't request minsecs longer than the access token lifetime
15+
# by waiting a couple of seconds
16+
sleep 2
17+
NOW="$(date +%s)"
18+
let MINSECS=$EXPTIME-$NOW+1
19+
htgettoken --nooidc --nokerberos --nossh -a $VAULTSERVER -i $ISSUER --minsecs=$MINSECS --scopes="$TESTSCOPES"
20+
EXPTIME3="$(htdecodetoken|jq -r .exp)"
21+
if [ "$EXPTIME" = "$EXPTIME3" ]; then
22+
echo "The access token was not renewed!"
23+
exit 1
24+
fi

0 commit comments

Comments
 (0)