From c3aecda2288e63fac4966afecfbe193fa51cbb06 Mon Sep 17 00:00:00 2001 From: lpichler Date: Wed, 21 Jun 2017 13:44:36 +0200 Subject: [PATCH 1/3] Add context with tags, wrap AuthKey test to context and move the creating the model of factory to the context --- spec/lib/rbac/filterer_spec.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/lib/rbac/filterer_spec.rb b/spec/lib/rbac/filterer_spec.rb index cad43d20652..189304554c6 100644 --- a/spec/lib/rbac/filterer_spec.rb +++ b/spec/lib/rbac/filterer_spec.rb @@ -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 + 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]) } - let!(:auth_key_pair_cloud) { FactoryGirl.create_list(:auth_key_pair_cloud, 2).first } before do tagged_group.entitlement = Entitlement.new @@ -88,11 +87,15 @@ 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 end From bcc85c5bc370f1e8ace2cb3538895f19f0be72d0 Mon Sep 17 00:00:00 2001 From: lpichler Date: Wed, 21 Jun 2017 13:57:41 +0200 Subject: [PATCH 2/3] add specs for host aggregate --- spec/lib/rbac/filterer_spec.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/spec/lib/rbac/filterer_spec.rb b/spec/lib/rbac/filterer_spec.rb index 189304554c6..b9a5891cd7c 100644 --- a/spec/lib/rbac/filterer_spec.rb +++ b/spec/lib/rbac/filterer_spec.rb @@ -76,9 +76,9 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt describe ".search" do 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]) } + 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 @@ -97,6 +97,17 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt 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 context 'with virtual custom attributes' do From 3df7d91b62fee440d88bb965cae9c43497bc0b20 Mon Sep 17 00:00:00 2001 From: lpichler Date: Wed, 21 Jun 2017 13:58:08 +0200 Subject: [PATCH 3/3] add HostAggregate model to RBAC --- lib/rbac/filterer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rbac/filterer.rb b/lib/rbac/filterer.rb index 3459fc27e0b..7329a470641 100644 --- a/lib/rbac/filterer.rb +++ b/lib/rbac/filterer.rb @@ -32,6 +32,7 @@ class Filterer Flavor FloatingIp Host + HostAggregate LoadBalancer MiddlewareDatasource MiddlewareDeployment