desc = '### create non-admin user & session ###' res = r.create_user("chris", "dee") is_success(desc, res) r.session = '' res = r.login_to_session("chris", "dee") non_admin_session = res.cookies """" ---Signin as admin--- """ r.session = admin_session desc = "### create 3 resources with tags ###" res = r.create_resource("r1", "r1", "free", 1000, 0, 1) resource1 = get_id(res) is_success(desc, res) res = r.add_tag(resource1, ["resource1", "a resource"]) is_success(desc, res) res = r.create_resource("r2", "r2", "free", 1000, 0, 1) resource2 = get_id(res) is_success(desc, res) res = r.add_tag(resource2, ["resource2", "a resource"]) is_success(desc, res) res = r.create_resource("r2", "r2", "free", 1000, 0, 1) resource3 = get_id(res) is_success(desc, res) res = r.add_tag(resource3, ["resource3"]) is_success(desc, res) desc = "### check that the tag filter sees 4 resources as admin (including root) ###" res = r.filter_tags([], [], 0, 99999999) is_success(desc, res)
desc = '#### get all users in DB, make sure theres only 1 and that the username == admin ####' res = r.get_all_users() test_print(desc, len(r.json.loads(res.content)['results']) == 1) test_print(desc, r.json.loads(res.content)['results'][0]['email_address'] == '*****@*****.**') desc = '#### create restricted resource ###' res = r.create_resource("restricted", "restricted", "restricted", 1, 0, 1) test_print(desc, res.status_code < 300) restricted_id = r.json.loads(res.content)['insertId'] desc = '#### create resource with tags ####' res = r.create_resource("server1", "this is a server", 'free', 1, 0, 1) test_print(desc, res.status_code < 300) resource_id = r.json.loads(res.content)['insertId'] res = r.add_tag(resource_id, ['tag1', 'tag2']) test_print(desc, res.status_code < 300) desc = '#### Check all tags created ####' res = r.get_all_tags() test_print(desc, len(r.json.loads(res.content)["results"]) == 2) desc = '#### get permissions for resource with tags and make that the admin user has permission ####' res = r.get_group_permission_to_resource(resource_id) test_print(desc, res.status_code < 300) test_print(desc, len(r.json.loads(res.content)['results']) == 1) desc = '#### create resource without tags ####' res = r.create_resource("notags", "notags", 'free', 1, 0, 1) test_print(desc, res.status_code < 300) no_tags_id = r.json.loads(res.content)['insertId']