blob: d2f4af070194de4e298014ed1bd3e6e6c8016d13 [file] [log] [blame]
Felipe Monteiro443d39c2018-04-08 17:05:33 -04001.. _rbac_field_guide:
2
3Patrole Field Guide to RBAC Tests
4=================================
5
6
7What are these tests?
8---------------------
9
10Patrole's primary responsibility is to ensure that your OpenStack cloud
11has properly configured Role-Based Access Control (RBAC). All Patrole
12tests cases are devoted to this responsibility. Tempest API clients
13and utility functions are leveraged to accomplish this goal, but such
14functionality is secondary to RBAC validation.
15
16Like Tempest, Patrole not only tests expected positive paths for RBAC
17validation, but also -- and more importantly -- negative paths. While
18Patrole could be thought of as validating RBAC, it more importantly
19verifies that your OpenStack cloud is secure from the perspective of
20RBAC (there are many gotchas when it comes to security, not just RBAC).
21
22Negative paths are arguably more important than positive paths when it
23comes to RBAC and by extension security, because it is essential that
24your cloud be secure from unauthorized access. For example, while it is
25important to verify that the admin role has access to admin-level
26functionality, it is of critical importance to verify that non-admin roles
27*do not* have access to such functionality.
28
29Unlike Tempest, Patrole accomplishes negative testing implicitly -- by
30abstracting it away in the background. Patrole dynamically determines
31whether a role should have access to an API depending on your cloud's
32policy configuration and then confirms whether that is true or false.
33
34
35Why are these tests in Patrole?
36-------------------------------
37
38These tests constitute the core mission in Patrole: to verify RBAC. These
39tests are mainly intended to validate RBAC, but can also *unofficially*
40be used to discover the policy-to-API mapping for an OpenStack component.
41
42It could be argued that some of these tests could be implemented in
43the projects themselves, but that approach has the following shortcomings:
44
45* The projects do not validate RBAC from an integration testing perspective.
46* By extension, RBAC across cross-service communication is not usually
47 validated.
48* The projects' tests do not pass all the metadata to ``oslo.policy`` that is
49 in reality passed by the deployed server to that library to determine
50 whether a given user is authorized to perform an API action.
51* The projects do not exhaustively do RBAC testing for all positive and
52 negative paths.
53* Patrole is designed to work with any role via configuration settings, but
54 on the other hand the projects handpick which roles to test.
55
Felipe Monteirof800a1c2018-07-09 00:23:46 -040056Why not use Patrole framework on Tempest tests?
57^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58
59The Patrole framework can't be applied to existing Tempest tests via
60:ref:`rbac-validation`, because:
61
62* Tempest tests aren't factored the right way: They're not granular enough.
63 They call too many APIs and too many policies are enforced by each test.
64* Tempest tests assume default policy rules: Tempest uses ``os_admin``
65 credentials for admin APIs and ``os_primary`` for non-admin APIs.
66 This breaks for custom policy overrides.
67* Tempest doesn't have tests that enforce all the policy actions, regardless.
68 Some RBAC tests require that tests be written a very precise way for the
69 server to authorize the expected policy actions.
70
71Why are these tests not in Tempest?
72^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
74Patrole should be a separate project that specializes in RBAC tests.
75
76Philosophically speaking:
77
78* Tempest supports `API and scenario testing`_. RBAC testing is out of scope.
79* The `OpenStack project structure reform`_ evolved OpenStack "to a more
80 decentralized model where [projects like QA] provide processes and tools to
81 empower projects to do the work themselves". This model resulted in the
82 creation of the `Tempest external plugin interface`_.
83* Tempest supports `plugins`_. Why not use one for RBAC testing?
84
85Practically speaking:
86
87* The Tempest team should not be burdened with having to support Patrole, too.
88 Tempest is a big project and having to absorb RBAC testing is difficult.
89* Tempest already has many in-tree Zuul checks/gates. If Patrole tests lived
90 in Tempest, then adding more Zuul checks/gates for Patrole would only make it
91 harder to get changes merged in Tempest.
92
93.. _API and scenario testing: https://docs.openstack.org/tempest/latest/overview.html#tempest-the-openstack-integration-test-suite
94.. _OpenStack project structure reform: https://governance.openstack.org/tc/resolutions/20141202-project-structure-reform-spec.html#impact-for-horizontal-teams
95.. _Tempest external plugin interface: https://specs.openstack.org/openstack/qa-specs/specs/tempest/implemented/tempest-external-plugin-interface.html
96.. _plugins: https://docs.openstack.org/tempest/latest/plugin.html
97
Felipe Monteiro443d39c2018-04-08 17:05:33 -040098
99Scope of these tests
100--------------------
101
102RBAC tests should always use the Tempest implementation of the
103OpenStack API, to take advantage of Tempest's stable library.
104
105Each test should test a specific API endpoint and the related policy.
106
107Each policy should be tested in isolation of one another -- or at least
108as close to this rule as possible -- to ensure proper validation of RBAC.
109
110Each test should be able to work for positive and negative paths.
111
112All tests should be able to be run on their own, not depending on the
113state created by a previous test.