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 tests for rbac on ansible playbooks and authentications #17528

Merged
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
39 changes: 38 additions & 1 deletion 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 Expand Up @@ -271,7 +308,7 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
{
"ExtManagementSystem" => :ems_vmware,
"MiqAeDomain" => :miq_ae_domain,
# "MiqRequest" => :miq_request, # MiqRequest can't be instantuated, it is an abstract class
# "MiqRequest" => :miq_request, # MiqRequest can't be instantiated, it is an abstract class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"MiqRequestTask" => :miq_request_task,
"Provider" => :provider,
"Service" => :service,
Expand Down