From e4973600d8849f3ec1169187d8082759023e601e Mon Sep 17 00:00:00 2001 From: lpichler Date: Mon, 10 Sep 2018 18:45:22 +0200 Subject: [PATCH] Add Lan and Switch model to RBAC in filterer --- lib/rbac/filterer.rb | 1 + spec/lib/rbac/filterer_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/rbac/filterer.rb b/lib/rbac/filterer.rb index 8579fb70fb29..4ab52b99d0c5 100644 --- a/lib/rbac/filterer.rb +++ b/lib/rbac/filterer.rb @@ -51,6 +51,7 @@ class Filterer Service ServiceTemplate Storage + Switch VmOrTemplate ) diff --git a/spec/lib/rbac/filterer_spec.rb b/spec/lib/rbac/filterer_spec.rb index e38e800fdbe4..b9c3f9b41925 100644 --- a/spec/lib/rbac/filterer_spec.rb +++ b/spec/lib/rbac/filterer_spec.rb @@ -194,6 +194,24 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt tagged_group.save! end + context 'searching for instances of Switches' do + let!(:switch) { FactoryGirl.create_list(:switch, 2).first } + + before do + switch.tag_with('/managed/environment/prod', :ns => '*') + end + + it 'lists only tagged Switches' do + results = described_class.search(:class => Switch, :user => user).first + expect(results).to match_array [switch] + end + + it 'lists only all Switches' do + results = described_class.search(:class => Switch, :user => admin_user).first + expect(results).to match_array Switch.all + end + end + context 'searching for instances of ConfigurationScriptSource' do let!(:configuration_script_source) { FactoryGirl.create_list(:embedded_ansible_configuration_script_source, 2).first }