Bump loofah from 2.2.3 to 2.3.1 in /apps/workbench
[arvados.git] / sdk / python / tests / fed-migrate / check.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 users = apiA.users().list().execute()
12
13 assert len(users["items"]) == 11
14
15 by_username = {}
16
17 for i in range(1, 10):
18     found = False
19     for u in users["items"]:
20         if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i):
21             found = True
22             by_username[u["username"]] = u["uuid"]
23     assert found
24
25 found = False
26 for u in users["items"]:
27     if (u["username"] == "case9" and u["email"] == "case9@test" and
28         u["uuid"] == by_username[u["username"]] and u["is_active"] is False):
29         found = True
30 assert found
31
32 users = apiB.users().list().execute()
33 assert len(users["items"]) == 11
34
35 for i in range(2, 10):
36     found = False
37     for u in users["items"]:
38         if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and u["uuid"] == by_username[u["username"]]:
39             found = True
40     assert found
41
42 users = apiC.users().list().execute()
43 assert len(users["items"]) == 8
44
45 for i in (2, 4, 6, 7, 8):
46     found = False
47     for u in users["items"]:
48         if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and u["uuid"] == by_username[u["username"]]:
49             found = True
50     assert found
51
52 # cases 3, 5, 9 involve users that have never accessed cluster C so
53 # there's nothing to migrate.
54 for i in (3, 5, 9):
55     found = False
56     for u in users["items"]:
57         if u["username"] == ("case%d" % i) and u["email"] == ("case%d@test" % i) and u["uuid"] == by_username[u["username"]]:
58             found = True
59     assert not found
60
61 print("Passed checks")