Introduce generic access spec matchers and refactor existing ones
What does this MR do?
Until now, two kinds of access test matchers existed: AccessMatchers
for feature specs and AccessMatchersForController
for controller specs. There was almost no code reuse between them and there were no truly generic access matchers that could be used with service classes' specs, API endpoints' specs, etc.
This MR introduces 3 kinds of access matchers:
-
AccessMatchers
for generic access tests; these matchers don't leverage session or any other auth mechanisms, they just patch the concrete example group scope with a stub user -
AccessMatchersForController
stay mostly the same -
AccessMatchersForSystemTest
are formerAccessMatchers
for feature specs, renamed.
Also, common functionality shared by these modules is extracted into AccessMatchersHelpers
module for better code reuse.
This MR is an extract from !19531 (merged) where these matchers' changes were introduced and used in-place by Vulnerabilities API specs. But the maintainer has recommended that this refactoring should come as a separate MR and I agree with him. The !19531 (merged) will receive a copy of AccessMatchers
from this MR under a different module name. Later on, I will resolve merge conflicts and preserve the matchers' modules naming of this MR.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team