blob: ccaf3c85b4def6b4c1e891aac72303cdabde2f39 [file] [log] [blame]
Felipe Monteiro88a5bab2017-08-31 04:00:32 +01001.. _rbac-validation:
2
3RBAC Testing Validation
4=======================
5
6--------
7Overview
8--------
9
10RBAC Testing Validation is broken up into 3 stages:
11
12 1. "Expected" stage. Determine whether the test should be able to succeed
13 or fail based on the test role defined by ``[patrole] rbac_test_role``)
14 and the policy action that the test enforces.
15 2. "Actual" stage. Run the test by calling the API endpoint that enforces
16 the expected policy action using the test role.
17 3. Comparing the outputs from both stages for consistency. A "consistent"
18 result is treated as a pass and an "inconsistent" result is treated
19 as a failure. "Consistent" (or successful) cases include:
20
21 * Expected result is ``True`` and the test passes.
22 * Expected result is ``False`` and the test fails.
23
24 "Inconsistent" (or failing) cases include:
25
26 * Expected result is ``False`` and the test passes. This results in an
27 ``RbacOverPermission`` exception getting thrown.
28 * Expected result is ``True`` and the test fails. This results in a
29 ``Forbidden`` exception getting thrown.
30
31 For example, a 200 from the API call and a ``True`` result from
32 ``oslo.policy`` or a 403 from the API call and a ``False`` result from
33 ``oslo.policy`` are successful results.
34
35-------------------------------
36The RBAC Rule Validation Module
37-------------------------------
38
39High-level module that implements decorator inside which the "Expected" stage
40is initiated.
41
42.. automodule:: patrole_tempest_plugin.rbac_rule_validation
43 :members:
44
45---------------------------
46The Policy Authority Module
47---------------------------
48
49Using the Policy Authority Module, policy verification is performed by:
50
511. Pooling together the default `in-code` policy rules.
522. Overriding the defaults with custom policy rules located in a policy.json,
53 if the policy file exists and the custom policy definition is explicitly
54 defined therein.
553. Confirming that the policy action -- for example, "list_users" -- exists.
56 (``oslo.policy`` otherwise claims that role "foo" is allowed to
57 perform policy action "bar", for example, because it defers to the
58 "default" policy rule and oftentimes the default can be "anyone allowed").
594. Performing a call with all necessary data to ``oslo.policy`` and returning
60 the expected result back to ``rbac_rule_validation`` decorator.
61
62.. automodule:: patrole_tempest_plugin.policy_authority
63 :members:
64 :special-members: