aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/scenario_available/rbac.py
blob: 25c010fdc50b99ea9d4657ecb2b39dc1c2d901a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
pdp_name = "pdp_rbac"
policy_name = "RBAC policy example"
model_name = "RBAC"
policy_genre = "authz"

subjects = {"adminuser": "", "user1": "", }
objects = {"vm0": "", "vm1": "", }
actions = {"start": "", "stop": ""}

subject_categories = {"role": "", }
object_categories = {"id": "", }
action_categories = {"action-type": "", }

subject_data = {"role": {"admin": "", "employee": "", "*": ""}}
object_data = {"id": {"vm0": "", "vm1": "", "*": ""}}
action_data = {"action-type": {"vm-action": "", "*": ""}}

subject_assignments = {
    "adminuser":
        ({"role": "admin"}, {"role": "employee"}, {"role": "*"}),
    "user1":
        ({"role": "employee"}, {"role": "*"}),
}
object_assignments = {
    "vm0":
        ({"id": "vm0"}, {"id": "*"}),
    "vm1":
        ({"id": "vm1"}, {"id": "*"})
}
action_assignments = {
    "start":
        ({"action-type": "vm-action"}, {"action-type": "*"}),
    "stop":
        ({"action-type": "vm-action"}, {"action-type": "*"})
}

meta_rule = {
    "rbac": {"id": "", "value": ("role", "id", "action-type")},
}

rules = {
    "rbac": (
        {
            "rule": ("admin", "vm0", "vm-action"),
            "instructions": (
                {"decision": "grant"},
                # "grant" to immediately exit,
                # "continue" to wait for the result of next policy
            )
        },
        {
            "rule": ("employee", "vm1", "vm-action"),
            "instructions": (
                {"decision": "grant"},
            )
        },
    )
}