-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpytest-tokens.py
More file actions
35 lines (31 loc) · 1.21 KB
/
pytest-tokens.py
File metadata and controls
35 lines (31 loc) · 1.21 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
#!/usr/bin/env python3
import os
import auth_code_acceptor
print("""
NOTE:
In order to properly run pytest without ROPC, we will need you to sign into
Keycloak three times with the given credentials. Please use a new incognito
window for each
""")
admin_username = os.getenv("CANDIG_SITE_ADMIN_USER", "your site admin username")
admin_token = auth_code_acceptor.run(
admin_username,
os.getenv("CANDIG_SITE_ADMIN_PASSWORD", "your site admin password"))
user1_username = os.getenv("CANDIG_NOT_ADMIN_USER")
user1_token = auth_code_acceptor.run(
user1_username, os.getenv("CANDIG_NOT_ADMIN_PASSWORD")
)
user2_username = os.getenv("CANDIG_NOT_ADMIN2_USER")
user2_token = auth_code_acceptor.run(
user2_username, os.getenv("CANDIG_NOT_ADMIN2_PASSWORD")
)
# NB: Grabbing a new admin token will invalidate the existing one, so we need to
# write over the site-admin-refresh-token file as well
with open(f"tmp/site-admin-refresh-token", "w") as f:
f.write(admin_token)
with open(f"tmp/pytest-{admin_username}-token", "w") as f:
f.write(admin_token)
with open(f"tmp/pytest-{user1_username}-token", "w") as f:
f.write(user1_token)
with open(f"tmp/pytest-{user2_username}-token", "w") as f:
f.write(user2_token)