Skip to content

Commit

Permalink
Add tests for RBAC on ansible playbooks and auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Jun 5, 2018
1 parent 086c465 commit 5acc3ec
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spec/lib/rbac/filterer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,43 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
end
end

%w(
automation_manager_authentication ManageIQ::Providers::AutomationManager::Authentication
embedded_automation_manager_authentication ManageIQ::Providers::EmbeddedAutomationManager::Authentication
).slice(2) do |factory, klass|
context "searching for instances of #{klass}" do
let!(:automation_manager_authentication) { FactoryGirl.create(factory) }
automation_manager_authentication.tag_with('/managed/environment/prod', :ns => '*')

results = described_class.search(:class => automation_manager_authentication.class.name, :user => user).first
expect(results.first).to eq(automation_manager_authentication)
end
end

it "tag entitled playbook with no tagged authentications" do
auth = FactoryGirl.create(:automation_manager_authentication)
playbook = FactoryGirl.create(:ansible_playbook, :authentications => [auth])
playbook.tag_with('/managed/environment/prod', :ns => '*')

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

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

it "tag entitled ansible authentications without a playbook for it" do
auth = FactoryGirl.create(:automation_manager_authentication)
playbook = FactoryGirl.create(:ansible_playbook, :authentications => [auth])
auth.tag_with('/managed/environment/prod', :ns => '*')

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

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

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

Expand Down

0 comments on commit 5acc3ec

Please sign in to comment.