aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/scenario_available/session.py
blob: 97d7aec3d720c2ea38dde926d39acfe37b406299 (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
pdp_name = "pdp1"
policy_name = "Session policy example"
model_name = "Session"
policy_genre = "session"

subjects = {"user0": "", "user1": "", }
objects = {"admin": "", "employee": "", }
actions = {"activate": "", "deactivate": ""}

subject_categories = {"subjectid": "", }
object_categories = {"role": "", }
action_categories = {"session-action": "", }

subject_data = {"subjectid": {"user0": "", "user1": ""}}
object_data = {"role": {"admin": "", "employee": "", "*": ""}}
action_data = {"session-action": {"activate": "", "deactivate": "", "*": ""}}

subject_assignments = {"user0": ({"subjectid": "user0"}, ), "user1": ({"subjectid": "user1"}, ), }
object_assignments = {"admin": ({"role": "admin"}, {"role": "*"}),
                      "employee": ({"role": "employee"}, {"role": "employee"})
                      }
action_assignments = {"activate": ({"session-action": "activate"}, {"session-action": "*"}, ),
                      "deactivate": ({"session-action": "deactivate"}, {"session-action": "*"}, )
                      }

meta_rule = {
    "session": {"id": "", "value": ("subjectid", "role", "session-action")},
}

rules = {
    "session": (
        {
            "rule": ("user0", "employee", "*"),
            "instructions": (
                {
                    "update": {
                        "operation": "add",
                        "target": "rbac:role:admin"  # add the role admin to the current user
                    }
                },
                {"chain": {"name": "rbac"}}  # chain with the meta_rule named rbac
            )
        },
        {
            "rule": ("user1", "employee", "*"),
            "instructions": (
                {
                    "update": {
                        "operation": "delete",
                        "target": "rbac:role:employee"  # delete the role employee from the current user
                    }
                },
                {"chain": {"name": "rbac"}}  # chain with the meta_rule named rbac
            )
        },
    )
}