CWL spec -> CWL standards
[arvados.git] / sdk / python / tests / fed-migrate / create_users.py
1 import arvados
2 import json
3 import sys
4
5 j = json.load(open(sys.argv[1]))
6
7 apiA = arvados.api(host=j["arvados_api_hosts"][0], token=j["superuser_tokens"][0], insecure=True)
8 apiB = arvados.api(host=j["arvados_api_hosts"][1], token=j["superuser_tokens"][1], insecure=True)
9 apiC = arvados.api(host=j["arvados_api_hosts"][2], token=j["superuser_tokens"][2], insecure=True)
10
11 def maketoken(newtok):
12     return 'v2/' + newtok["uuid"] + '/' + newtok["api_token"]
13
14 # case 1
15 # user only exists on cluster A
16 apiA.users().create(body={"user": {"email": "case1@test", "is_active": True}}).execute()
17
18 # case 2
19 # user exists on cluster A and has remotes on B and C
20 case2 = apiA.users().create(body={"user": {"email": "case2@test", "is_active": True}}).execute()
21 newtok = apiA.api_client_authorizations().create(body={
22     "api_client_authorization": {'owner_uuid': case2["uuid"]}}).execute()
23 arvados.api(host=j["arvados_api_hosts"][1], token=maketoken(newtok), insecure=True).users().current().execute()
24 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtok), insecure=True).users().current().execute()
25
26 # case 3
27 # user only exists on cluster B
28 case3 = apiB.users().create(body={"user": {"email": "case3@test", "is_active": True}}).execute()
29
30 # case 4
31 # user only exists on cluster B and has remotes on A and C
32 case4 = apiB.users().create(body={"user": {"email": "case4@test", "is_active": True}}).execute()
33 newtok = apiB.api_client_authorizations().create(body={
34     "api_client_authorization": {'owner_uuid': case4["uuid"]}}).execute()
35 arvados.api(host=j["arvados_api_hosts"][0], token=maketoken(newtok), insecure=True).users().current().execute()
36 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtok), insecure=True).users().current().execute()
37
38
39 # case 5
40 # user exists on both cluster A and B
41 case5 = apiA.users().create(body={"user": {"email": "case5@test", "is_active": True}}).execute()
42 case5 = apiB.users().create(body={"user": {"email": "case5@test", "is_active": True}}).execute()
43
44 # case 6
45 # user exists on both cluster A and B, with remotes on A, B and C
46 case6_A = apiA.users().create(body={"user": {"email": "case6@test", "is_active": True}}).execute()
47 newtokA = apiA.api_client_authorizations().create(body={
48     "api_client_authorization": {'owner_uuid': case6_A["uuid"]}}).execute()
49 arvados.api(host=j["arvados_api_hosts"][1], token=maketoken(newtokA), insecure=True).users().current().execute()
50 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtokA), insecure=True).users().current().execute()
51
52 case6_B = apiB.users().create(body={"user": {"email": "case6@test", "is_active": True}}).execute()
53 newtokB = apiB.api_client_authorizations().create(body={
54     "api_client_authorization": {'owner_uuid': case6_B["uuid"]}}).execute()
55 arvados.api(host=j["arvados_api_hosts"][0], token=maketoken(newtokB), insecure=True).users().current().execute()
56 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtokB), insecure=True).users().current().execute()
57
58 # case 7
59 # user exists on both cluster B and A, with remotes on A, B and C
60 case7_B = apiB.users().create(body={"user": {"email": "case7@test", "is_active": True}}).execute()
61 newtokB = apiB.api_client_authorizations().create(body={
62     "api_client_authorization": {'owner_uuid': case7_B["uuid"]}}).execute()
63 arvados.api(host=j["arvados_api_hosts"][0], token=maketoken(newtokB), insecure=True).users().current().execute()
64 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtokB), insecure=True).users().current().execute()
65
66 case7_A = apiA.users().create(body={"user": {"email": "case7@test", "is_active": True}}).execute()
67 newtokA = apiA.api_client_authorizations().create(body={
68     "api_client_authorization": {'owner_uuid': case7_A["uuid"]}}).execute()
69 arvados.api(host=j["arvados_api_hosts"][1], token=maketoken(newtokA), insecure=True).users().current().execute()
70 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtokA), insecure=True).users().current().execute()
71
72 # case 8
73 # user exists on both cluster B and C, with remotes on A, B and C
74 case8_B = apiB.users().create(body={"user": {"email": "case8@test", "is_active": True}}).execute()
75 newtokB = apiB.api_client_authorizations().create(body={
76     "api_client_authorization": {'owner_uuid': case8_B["uuid"]}}).execute()
77 arvados.api(host=j["arvados_api_hosts"][0], token=maketoken(newtokB), insecure=True).users().current().execute()
78 arvados.api(host=j["arvados_api_hosts"][2], token=maketoken(newtokB), insecure=True).users().current().execute()
79
80 case8_C = apiC.users().create(body={"user": {"email": "case8@test", "is_active": True}}).execute()
81 newtokC = apiC.api_client_authorizations().create(body={
82     "api_client_authorization": {'owner_uuid': case8_C["uuid"]}}).execute()
83 arvados.api(host=j["arvados_api_hosts"][0], token=maketoken(newtokC), insecure=True).users().current().execute()
84 arvados.api(host=j["arvados_api_hosts"][1], token=maketoken(newtokC), insecure=True).users().current().execute()
85
86 # case 9
87 # user only exists on cluster B, but is inactive
88 case9 = apiB.users().create(body={"user": {"email": "case9@test", "is_active": False}}).execute()