-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36726 - Non-admin users with the view_smart_proxies permission…
… can now access capsules from the API Added test cases for the capsules controller to enforce permissions handling. Comment cleanup. Fixed broken test cases and queried more edge cases of the capsule controller. Added location support for custom users created in unit tests.
- Loading branch information
Showing
3 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# encoding: utf-8 | ||
|
||
require "katello_test_helper" | ||
|
||
module Katello | ||
class Api::V2::CapsulesControllerTest < ActionController::TestCase | ||
include Support::CapsuleSupport | ||
include Support::ForemanTasks::Task | ||
|
||
def setup | ||
setup_controller_defaults_api | ||
@repository = katello_repositories(:fedora_17_unpublished) | ||
@library_dev_view = ContentView.find(katello_content_views(:library_dev_view).id) | ||
@location = Location.all | ||
@organization = [get_organization] | ||
|
||
proxy_with_pulp.organizations = @organization | ||
proxy_with_pulp.locations = @location | ||
end | ||
|
||
def view_smart_proxies_perms | ||
[[:view_smart_proxies]] | ||
end | ||
|
||
def incorrect_perms | ||
[[:view_capsule_content, :manage_capsule_content]] | ||
end | ||
|
||
def environment | ||
@environment ||= katello_environments(:library) | ||
end | ||
|
||
def test_admin_index | ||
get :index | ||
assert_response :success | ||
end | ||
|
||
def test_admin_show | ||
get :show, params: { :id => proxy_with_pulp.id} | ||
assert_response :success | ||
end | ||
|
||
def test_user_index | ||
assert_protected_action(:index, view_smart_proxies_perms, incorrect_perms) do | ||
get :index | ||
end | ||
end | ||
|
||
def test_user_show | ||
assert_protected_action(:show, view_smart_proxies_perms, incorrect_perms, | ||
@organization, @location) do | ||
get :show, params: { :id => proxy_with_pulp.id} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters