Skip to content

Commit

Permalink
Merge pull request #15417 from lpichler/add_host_aggregates_to_rbac
Browse files Browse the repository at this point in the history
Add HostAggregates to RBAC
  • Loading branch information
gtanzillo authored Jul 25, 2017
2 parents 182b16b + 3df7d91 commit 7d96fb8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Filterer
Flavor
FloatingIp
Host
HostAggregate
LoadBalancer
MiddlewareDatasource
MiddlewareDeployment
Expand Down
32 changes: 23 additions & 9 deletions spec/lib/rbac/filterer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
let(:child_openstack_vm) { FactoryGirl.create(:vm_openstack, :tenant => child_tenant, :miq_group => child_group) }

describe ".search" do
context 'searching for instances of AuthKeyPair with tags' do
let(:role) { FactoryGirl.create(:miq_user_role) }
let(:tagged_group) { FactoryGirl.create(:miq_group, :tenant => Tenant.root_tenant, :miq_user_role => role) }
let(:user) { FactoryGirl.create(:user, :miq_groups => [tagged_group]) }
let!(:auth_key_pair_cloud) { FactoryGirl.create_list(:auth_key_pair_cloud, 2).first }
context 'with tags' do
let(:role) { FactoryGirl.create(:miq_user_role) }
let(:tagged_group) { FactoryGirl.create(:miq_group, :tenant => Tenant.root_tenant, :miq_user_role => role) }
let(:user) { FactoryGirl.create(:user, :miq_groups => [tagged_group]) }

before do
tagged_group.entitlement = Entitlement.new
Expand All @@ -88,11 +87,26 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
tagged_group.save!
end

it 'lists only tagged AuthKeyPairs' do
auth_key_pair_cloud.tag_with('/managed/environment/prod', :ns => '*')
context 'searching for instances of AuthKeyPair' do
let!(:auth_key_pair_cloud) { FactoryGirl.create_list(:auth_key_pair_cloud, 2).first }

results = described_class.search(:class => ManageIQ::Providers::CloudManager::AuthKeyPair, :user => user).first
expect(results).to match_array [auth_key_pair_cloud]
it 'lists only tagged AuthKeyPairs' do
auth_key_pair_cloud.tag_with('/managed/environment/prod', :ns => '*')

results = described_class.search(:class => ManageIQ::Providers::CloudManager::AuthKeyPair, :user => user).first
expect(results).to match_array [auth_key_pair_cloud]
end
end

context 'searching for instances of HostAggregate' do
let!(:host_aggregate) { FactoryGirl.create_list(:host_aggregate, 2).first }

it 'lists only tagged HostAggregates' do
host_aggregate.tag_with('/managed/environment/prod', :ns => '*')

results = described_class.search(:class => HostAggregate, :user => user).first
expect(results).to match_array [host_aggregate]
end
end
end

Expand Down

0 comments on commit 7d96fb8

Please sign in to comment.