-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathexercise-signing-keys.py
More file actions
61 lines (51 loc) · 2.06 KB
/
Copy pathexercise-signing-keys.py
File metadata and controls
61 lines (51 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# coding: utf-8
import os
import sys
import time
import mux_python
from mux_python.rest import NotFoundException
import logger
# Exercises all url signing key operations.
# Authentication Setup
configuration = mux_python.Configuration()
configuration.username = os.environ['MUX_TOKEN_ID']
configuration.password = os.environ['MUX_TOKEN_SECRET']
# API Client Initialization
keys_api = mux_python.URLSigningKeysApi(mux_python.ApiClient(configuration))
# ========== create-url-signing-key ==========
create_key_response = keys_api.create_url_signing_key()
logger.print_debug(create_key_response)
assert create_key_response != None
assert create_key_response.data.id != None
assert create_key_response.data.private_key != None
print("create-url-signing-key OK ✅")
# ========== list-url-signing-keys ==========
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[-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 ==========
get_key_response = keys_api.get_url_signing_key(create_key_response.data.id)
logger.print_debug(get_key_response)
assert get_key_response != None
assert get_key_response.data.private_key == None
print("get-url-signing-key OK ✅")
# ========== 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)
except NotFoundException as e:
assert e != None
print("delete-url-signing-key OK ✅")