Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HostAggregates to RBAC #15417

Merged
merged 3 commits into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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