blob: 6f72eec70f08957aec7b417b19942f45c2033ff8 [file] [log] [blame]
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +00001RBAC Testing Validation
2=======================
3
Felipe Monteiro0170c992018-07-31 20:10:05 -04004.. _validation-workflow-overview:
Felipe Monteiro26b7e092018-07-27 22:15:27 +01005
Felipe Monteiro0170c992018-07-31 20:10:05 -04006----------------------------
7Validation Workflow Overview
8----------------------------
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +00009
10RBAC testing validation is broken up into 3 stages:
11
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090012#. "Expected" stage. Determine whether the test should be able to succeed
Mykola Yakovlieve0f35502018-09-26 18:26:57 -050013 or fail based on the test roles defined by ``[patrole] rbac_test_roles``)
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090014 and the policy action that the test enforces.
15#. "Actual" stage. Run the test by calling the API endpoint that enforces
Mykola Yakovlieve0f35502018-09-26 18:26:57 -050016 the expected policy action using the test roles.
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090017#. 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:
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000020
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090021 * Expected result is ``True`` and the test passes.
22 * Expected result is ``False`` and the test fails.
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000023
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090024 For example, a 200 from the API call and a ``True`` result from
25 ``oslo.policy`` or a 403 from the API call and a ``False`` result from
26 ``oslo.policy`` are successful results.
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000027
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090028 "Inconsistent" (or failing) cases include:
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000029
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090030 * Expected result is ``False`` and the test passes. This results in an
Felipe Monteirof16b6b32018-06-28 19:32:59 -040031 :class:`~rbac_exceptions.RbacOverPermissionException` exception
32 getting thrown.
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090033 * Expected result is ``True`` and the test fails. This results in a
Felipe Monteirof16b6b32018-06-28 19:32:59 -040034 :class:`~rbac_exceptions.RbacOverPermissionException` exception
35 getting thrown.
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000036
Masayuki Igawa80b9aab2018-01-09 17:00:45 +090037 For example, a 200 from the API call and a ``False`` result from
38 ``oslo.policy`` or a 403 from the API call and a ``True`` result from
39 ``oslo.policy`` are failing results.
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000040
Felipe Monteiro0170c992018-07-31 20:10:05 -040041.. warning::
42
43 Note that Patrole cannot currently derive the expected policy result for
44 service-specific ``oslo.policy`` `checks`_, like Neutron's `FieldCheck`_,
45 because such checks are contained within the service's code base itself,
46 which Patrole cannot import.
47
48.. _checks: https://docs.openstack.org/oslo.policy/latest/reference/api/oslo_policy.policy.html#generic-checks
49.. _FieldCheck: https://docs.openstack.org/neutron/pike/contributor/internals/policy.html#fieldcheck-verify-resource-attributes
50
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000051-------------------------------
52The RBAC Rule Validation Module
53-------------------------------
54
55High-level module that provides the decorator that wraps around Tempest tests
56and serves as the entry point for RBAC testing validation. The workflow
57described above is ultimately carried out by the decorator.
58
59For more information about this module, please see :ref:`rbac-validation`.
60
61---------------------------
62The Policy Authority Module
63---------------------------
64
65Module called by :ref:`rbac-validation` to verify whether the test
Mykola Yakovlieve0f35502018-09-26 18:26:57 -050066roles are allowed to execute a policy action by querying ``oslo.policy`` with
Felipe Monteiroc8ec1f62017-11-15 08:32:56 +000067required test data. The result is used by :ref:`rbac-validation` as the
68"Expected" result.
69
70For more information about this module, please see :ref:`policy-authority`.
71
72---------------------
73The RBAC Utils Module
74---------------------
75
76This module is responsible for handling role switching, the mechanism by which
77Patrole is able to set up, tear down and execute APIs using the same set
78of credentials. Every RBAC test must perform a role switch even if the role
79that is being switched to is admin.
80
81For more information about this module, please see :ref:`rbac-utils`.