Skip to content

Commit

Permalink
Update example for exercising signing keys to wait for cache invalida…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Jared Smith <[email protected]>
  • Loading branch information
jaredsmith committed Apr 26, 2023
1 parent 00df80b commit 7a66072
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/video/exercise-signing-keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from mux_python.rest import NotFoundException
import logger


# Exercises all url signing key operations.

# Authentication Setup
Expand All @@ -29,9 +30,9 @@
list_keys_response = keys_api.list_url_signing_keys()
logger.print_debug(list_keys_response)
assert list_keys_response != None
assert list_keys_response.data[0].id != None
assert list_keys_response.data[0].id == create_key_response.data.id
assert list_keys_response.data[0].private_key == None
assert list_keys_response.data[-1].id != None
assert list_keys_response.data[-1].id == create_key_response.data.id
assert list_keys_response.data[-1].private_key == None
print("list-url-signing-keys OK ✅")

# ========== get-url-signing-key ==========
Expand All @@ -44,6 +45,14 @@
# ========== delete-url-signing-key ==========
keys_api.delete_url_signing_key(create_key_response.data.id)
try:
print("Sleeping for 60 seconds to ensure key cache is invalidated ⏳")
for remaining in range(60, 0, -1):
sys.stdout.write("\r")
sys.stdout.write("{:2d} seconds remaining.".format(remaining))
sys.stdout.flush()
time.sleep(1)

sys.stdout.write("\rSleep complete! ⏳ \n")
keys_api.get_url_signing_key(create_key_response.data.id)
print("Should have 404'd when getting deleted signing key ❌ ")
sys.exit(1)
Expand Down

0 comments on commit 7a66072

Please sign in to comment.