theforeman / foreman_fog_proxmox

Foreman plugin to add Proxmox compute resource based on fog-proxmox gem
GNU General Public License v3.0
105 stars 31 forks source link

Test fails with permissions not found for ostemplates and isos #129

Closed Manisha15 closed 4 years ago

Manisha15 commented 4 years ago

I am trying to mock proxmox compute_resource for foreman_snapshot_management with Fog. The compute resource is of type ForemanFogProxmox::Proxmox. Test in travis-ci for my plugin are running fine but travis also runs

rake test TEST="test/unit/foreman/access_permissions_test.rb"

which fails for foreman_fog_proxmox with error

AccessPermissionsTest#test_0788_route foreman_fog_proxmox/compute_resources/isos should have a permission that grants access = 0.01 s = F

Failure:
AccessPermissionsTest#test_0788_route foreman_fog_proxmox/compute_resources/isos should have a permission that grants access [/home/travis/build/ATIX-AG/foreman/test/unit/shared/access_permissions_test_base.rb:29]:
permission for foreman_fog_proxmox/compute_resources/isos not found, check access_permissions.rb.
Expected [] to not be empty.

bin/rails test test/unit/shared/access_permissions_test_base.rb:18

AccessPermissionsTest#test_0789_route foreman_fog_proxmox/compute_resources/ostemplates should have a permission that grants access = 0.00 s = F

Failure:
AccessPermissionsTest#test_0789_route foreman_fog_proxmox/compute_resources/ostemplates should have a permission that grants access [/home/travis/build/ATIX-AG/foreman/test/unit/shared/access_permissions_test_base.rb:29]:
permission for foreman_fog_proxmox/compute_resources/ostemplates not found, check access_permissions.rb.
Expected [] to not be empty.

bin/rails test test/unit/shared/access_permissions_test_base.rb:18

To reproduce the error in foreman: rake test TEST="test/unit/foreman/access_permissions_test.rb"

tristanrobert commented 4 years ago

The test is related to core foreman features. I don't know if it could/should be applied to plugins. I need more help and more documentation to know what to do.

Manisha15 commented 4 years ago

You added two actions in controller, namely ostemplates and isos, they should be mapped to foreman-permissions. See doc: https://github.com/theforeman/foreman/blob/develop/developer_docs/how_to_create_a_plugin.asciidoc#adding-permission

Something like this in engine:

security_block :foreman_fog_proxmox do
          permission :view_compute_resource, {:'foreman_fog_proxmox/compute_resources' => 
          [:ostemplates, :isos] }
end
tristanrobert commented 4 years ago

Thank you so much @Manisha15. I can work on it.