1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
9 j = json.load(open(sys.argv[1]))
11 apiA = arvados.api(host=j["arvados_api_hosts"][0], token=j["superuser_tokens"][0], insecure=True)
12 tok = apiA.api_client_authorizations().current().execute()
13 v2_token = "v2/%s/%s" % (tok["uuid"], tok["api_token"])
15 apiB = arvados.api(host=j["arvados_api_hosts"][1], token=v2_token, insecure=True)
16 apiC = arvados.api(host=j["arvados_api_hosts"][2], token=v2_token, insecure=True)
19 ### Check users on API server "A" (the LoginCluster) ###
23 assert len(users["items"]) == 11
25 for i in range(1, 10):
27 for u in users["items"]:
28 if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and u["first_name"] == ("Case%d" % i) and u["last_name"] == "Testuser":
30 by_username[u["username"]] = u["uuid"]
34 for i in (1, 2, 3, 4, 5, 6, 7, 8):
36 for u in users["items"]:
37 if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and u["is_active"] is True:
39 assert found, "Not found case%i" % i
41 # case9 should not be active
43 for u in users["items"]:
44 if (u["username"] == "case9" and u["email"] == "case9@test" and
45 u["uuid"] == by_username[u["username"]] and u["is_active"] is False):
49 users = apiA.users().list().execute()
52 users = apiA.users().list(bypass_federation=True).execute()
56 ### Check users on API server "B" (federation member) ###
59 # check for expected migrations on B
60 users = apiB.users().list(bypass_federation=True).execute()
61 assert len(users["items"]) == 11
65 for u in users["items"]:
66 if (u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and
67 u["first_name"] == ("Case%d" % i) and u["last_name"] == "Testuser" and
68 u["uuid"] == by_username[u["username"]] and u["is_active"] is True):
70 assert found, "Not found case%i" % i
73 for u in users["items"]:
74 if (u["username"] == "case9" and u["email"] == "case9@test" and
75 u["first_name"] == "Case9" and u["last_name"] == "Testuser" and
76 u["uuid"] == by_username[u["username"]] and u["is_active"] is False):
80 # check that federated user listing works
81 users = apiB.users().list().execute()
85 ### Check users on API server "C" (federation member) ###
88 # check for expected migrations on C
89 users = apiC.users().list(bypass_federation=True).execute()
90 assert len(users["items"]) == 8
92 for i in (2, 4, 6, 7, 8):
94 for u in users["items"]:
95 if (u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and
96 u["first_name"] == ("Case%d" % i) and u["last_name"] == "Testuser" and
97 u["uuid"] == by_username[u["username"]] and u["is_active"] is True):
101 # cases 3, 5, 9 involve users that have never accessed cluster C so
102 # there's nothing to migrate.
105 for u in users["items"]:
106 if (u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and
107 u["first_name"] == ("Case%d" % i) and u["last_name"] == "Testuser" and
108 u["uuid"] == by_username[u["username"]] and u["is_active"] is True):
112 # check that federated user listing works
113 users = apiC.users().list().execute()
116 print("Passed checks")