Project

General

Profile

Bug #22430

Plugin permissions are cleared on tests

Added by Daniel Lobato Garcia 7 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Category:
Tests
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

The problem:

- Some tests are removing all plugins (plugin_test, rabl_test, belongs_to_proxy_test) from the registry. This has, among others, one important consequence: the plugin permissions are removed.
- Take an example. Foreman Ansible overrides the Host#form with a list of 'Ansible Roles' to choose.
- When the view for this Host#form is rendered (e.g: a HostController or HostJSTest), the list of 'Ansible Roles' has also to be rendered.
- Since a previous test removed the plugin from the `Foreman::Plugin.all` registry, but the plugin is still installed as a Rails Engine, the overrides by deface still apply.
- Some tests that render the Host form fail to run as rendering is impossible without the 'ansible_roles' permission. These permissions are only loaded in tests if the plugin is registered in Foreman::Plugin*

Foreman::Plugin::RbacRegistry should not be cleared https://github.com/theforeman/foreman/blob/develop/test/fixtures/permissions.yml#L772

To fix this, I suggest adding a helper method to our test_helper to handle removing & restoring.

Associated revisions

Revision 52258efc (diff)
Added by Daniel Lobato Garcia 7 months ago

Fixes #22430 - Plugin permissions are cleared on tests

- Some tests are removing all plugins (plugin_test, rabl_test,
belongs_to_proxy_test) from the registry. This has, among others,
one important consequence: the plugin permissions are removed.

- Take an example. Foreman Ansible overrides the Host#form with a
list of 'Ansible Roles' to choose.

- When the view for this Host#form is rendered (e.g: a
HostController or HostJSTest), the list of 'Ansible Roles' has
also to be rendered.

- Since a previous test removed the plugin from the
`Foreman::Plugin.all` registry, but the plugin is still installed
as a Rails Engine, the overrides by deface still apply.

- Some tests that render the Host form fail to run as rendering is
impossible without the 'ansible_roles' permission. These
permissions are only loaded in tests if the plugin is registered
in Foreman::Plugin*

History

#1 Updated by The Foreman Bot 7 months ago

  • Assignee set to Daniel Lobato Garcia
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5218 added

#2 Updated by Ohad Levy 7 months ago

  • Legacy Backlogs Release (now unused) set to 330

#3 Updated by Anonymous 7 months ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF