Skip to content

Commit

Permalink
Merge pull request #13395 from lpichler/add_list_of_providers_to_rbac…
Browse files Browse the repository at this point in the history
…_on_catalog_items

Add list of providers to RBAC on catalog items
  • Loading branch information
gtanzillo authored Jan 10, 2017
2 parents a90d9dc + ec4bf51 commit 2909905
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/orchestration_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def parameter_groups

# List managers that may be able to deploy this template
def self.eligible_managers
ExtManagementSystem.where(:type => eligible_manager_types.collect(&:name))
Rbac::Filterer.filtered(ExtManagementSystem, :where_clause => {:type => eligible_manager_types})
end

delegate :eligible_managers, :to => :class
Expand Down
20 changes: 17 additions & 3 deletions spec/models/orchestration_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,31 @@
end

describe "#eligible_managers" do
let!(:miq_server) { EvmSpecHelper.local_miq_server }
let(:user_admin) { FactoryGirl.create(:user_admin) }
let(:tenant) { FactoryGirl.create(:tenant) }
let(:other_tenant) { FactoryGirl.create(:tenant) }
let!(:user) { FactoryGirl.create(:user_with_group, :tenant => tenant) }

before do
allow(OrchestrationTemplate).to receive_messages(:eligible_manager_types =>
[ManageIQ::Providers::Amazon::CloudManager,
ManageIQ::Providers::Openstack::CloudManager])
@template = FactoryGirl.create(:orchestration_template)
@aws = FactoryGirl.create(:ems_amazon)
@openstack = FactoryGirl.create(:ems_openstack)
@aws = FactoryGirl.create(:ems_amazon, :tenant => other_tenant)
@openstack = FactoryGirl.create(:ems_openstack, :tenant => tenant)
end

it "lists all eligible managers for a template" do
expect(@template.eligible_managers).to match_array([@aws, @openstack])
User.with_user(user_admin) do
expect(@template.eligible_managers).to match_array([@aws, @openstack])
end
end

it "lists all eligible managers for a template regard to user's tenant" do
User.with_user(user) do
expect(@template.eligible_managers).to match_array([@openstack])
end
end
end

Expand Down

0 comments on commit 2909905

Please sign in to comment.