@pytest.mark.gen_test
def test_user_tok_acls(session, graph, users, user_admin_perm_to_auditors, http_client, base_url):
    role_user = "role@a.co"
    admin = "zorkian@a.co"
    pleb = "gary@a.co"

    # admin creating token for role user
    fe_url = url(base_url, "/users/{}/tokens/add".format(role_user))
    resp = yield http_client.fetch(fe_url, method="POST",
            headers={"X-Grouper-User": admin}, body=urlencode({"name": "foo"}))
    assert resp.code == 200

    with pytest.raises(HTTPError):
        # non-admin creating token for role user
        resp = yield http_client.fetch(fe_url, method="POST",
                headers={"X-Grouper-User": pleb}, body=urlencode({"name": "foo2"}))

    fe_url = url(base_url, "/users/{}/tokens/add".format(pleb))
    with pytest.raises(HTTPError):
        # admin creating token for normal (non-role) user
        resp = yield http_client.fetch(fe_url, method="POST",
                headers={"X-Grouper-User": admin}, body=urlencode({"name": "foo3"}))
dataset/ETHPy150Open dropbox/grouper/tests/test_users.py/test_user_tok_acls/original