Skip to content

Commit

Permalink
test/suites: Test token prune task for certificate add token operations.
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Laing <[email protected]>
  • Loading branch information
markylaing committed Oct 25, 2024
1 parent e66dc6f commit 5e95847
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/suites/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ test_remote_url_with_token() {
# Try adding remote. This should fail.
! lxc_remote remote add test "${token}" || false

# Check token prune task
lxc config trust add --name foo --quiet # Create a token
[ "$(lxc operation list --format csv | grep -cF 'TOKEN,Executing operation,RUNNING')" -eq 1 ] # Expect only one token operation to be running
running_token_operation_uuid="$(lxc operation list --format csv | grep -F 'TOKEN,Executing operation,RUNNING' | cut -d, -f1)" # Get the operation UUID
sleep 2 # Wait for token to expire (expiry still set to 2 seconds)
lxc query --request POST /internal/testing/prune-tokens # Prune tokens
[ "$(lxc query "/1.0/operations/${running_token_operation_uuid}" | jq -r '.status')" = "Cancelled" ] # Expect the operation to be cancelled

# Unset token expiry
lxc config unset core.remote_token_expiry

Expand Down

0 comments on commit 5e95847

Please sign in to comment.