blob: a38309900d38c678a4a12a6c880905c30a9d7630 [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``
Felipe Monteiro1bbf48e2018-07-10 18:43:47 +010065 `credentials`_ for admin APIs and ``os_primary`` for non-admin APIs.
Felipe Monteirof800a1c2018-07-09 00:23:46 -040066 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
Felipe Monteiro1bbf48e2018-07-10 18:43:47 +010074Patrole should be a separate project that specializes in RBAC tests. This
75was agreed upon during `discussion`_ that led to the approval of the RBAC
76testing framework `spec`_, which was the genesis for Patrole.
Felipe Monteirof800a1c2018-07-09 00:23:46 -040077
78Philosophically speaking:
79
80* Tempest supports `API and scenario testing`_. RBAC testing is out of scope.
81* The `OpenStack project structure reform`_ evolved OpenStack "to a more
82 decentralized model where [projects like QA] provide processes and tools to
83 empower projects to do the work themselves". This model resulted in the
84 creation of the `Tempest external plugin interface`_.
85* Tempest supports `plugins`_. Why not use one for RBAC testing?
86
87Practically speaking:
88
89* The Tempest team should not be burdened with having to support Patrole, too.
90 Tempest is a big project and having to absorb RBAC testing is difficult.
91* Tempest already has many in-tree Zuul checks/gates. If Patrole tests lived
92 in Tempest, then adding more Zuul checks/gates for Patrole would only make it
93 harder to get changes merged in Tempest.
94
Felipe Monteiro1bbf48e2018-07-10 18:43:47 +010095.. _credentials: https://docs.openstack.org/tempest/latest/write_tests.html#allocating-credentials
96.. _discussion: https://review.openstack.org/#/c/382672/
97.. _spec: https://specs.openstack.org/openstack/qa-specs/specs/tempest/rbac-policy-testing.html
Felipe Monteirof800a1c2018-07-09 00:23:46 -040098.. _API and scenario testing: https://docs.openstack.org/tempest/latest/overview.html#tempest-the-openstack-integration-test-suite
99.. _OpenStack project structure reform: https://governance.openstack.org/tc/resolutions/20141202-project-structure-reform-spec.html#impact-for-horizontal-teams
100.. _Tempest external plugin interface: https://specs.openstack.org/openstack/qa-specs/specs/tempest/implemented/tempest-external-plugin-interface.html
101.. _plugins: https://docs.openstack.org/tempest/latest/plugin.html
102
Felipe Monteiro443d39c2018-04-08 17:05:33 -0400103
104Scope of these tests
105--------------------
106
107RBAC tests should always use the Tempest implementation of the
108OpenStack API, to take advantage of Tempest's stable library.
109
110Each test should test a specific API endpoint and the related policy.
111
112Each policy should be tested in isolation of one another -- or at least
113as close to this rule as possible -- to ensure proper validation of RBAC.
114
115Each test should be able to work for positive and negative paths.
116
117All tests should be able to be run on their own, not depending on the
118state created by a previous test.