aboutsummaryrefslogtreecommitdiffstats
path: root/moon_interface/tests/unit_python/api/test_authz.py
blob: 84605203f007d75f15aaa979dcaa9f148c5672ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json


def get_json(data):
    return json.loads(data.decode("utf-8"))


def test_authz_true(context):
    import moon_interface.server
    server = moon_interface.server.create_server()
    client = server.app.test_client()
    req = client.get("/authz/{p_id}/{s_id}/{o_id}/{a_id}".format(
        p_id=context["project_id"],
        s_id=context["subject_name"],
        o_id=context["object_name"],
        a_id=context["action_name"],
    ))
    assert req.status_code == 200
    data = get_json(req.data)
    assert data
    assert "result" in data
    assert data['result'] == True