def test_permissions_aliased_permissions(mocker, session, standard_graph, http_client, base_url): proxy = PluginProxy([PermissionAliasesPlugin()]) mocker.patch('grouper.graph.get_plugin_proxy', return_value=proxy) # Force graph update Counter.incr(session, "updates") standard_graph.update_from_db(session) api_url = url(base_url, '/permissions/ssh') resp = yield http_client.fetch(api_url) body = json.loads(resp.body) permissions = [(group, p['argument']) for group, g in body['data']['groups'].iteritems() for p in g['permissions']] assert ('sad-team', 'owner=sad-team') in permissions
def test_users_aliased_permissions( mocker, session, standard_graph, http_client, base_url # noqa: F811 ): proxy = PluginProxy([TestPermissionAliasesPlugin()]) mocker.patch("grouper.graph.get_plugin_proxy", return_value=proxy) # Force graph update Counter.incr(session, "updates") standard_graph.update_from_db(session) api_url = url(base_url, "/users/[email protected]") resp = yield http_client.fetch(api_url) body = json.loads(resp.body) perms = [(p["permission"], p["argument"]) for p in body["data"]["permissions"]] assert ("owner", "sad-team") in perms assert ("ssh", "owner=sad-team") in perms assert ("sudo", "sad-team") in perms