Skip to content

Commit

Permalink
Add Lan and Swithc model to RBAC in filterer
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Sep 10, 2018
1 parent 85265cd commit 705ec0e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Filterer
FloatingIp
Host
HostAggregate
Lan
LoadBalancer
MiddlewareDatasource
MiddlewareDeployment
Expand All @@ -51,6 +52,7 @@ class Filterer
Service
ServiceTemplate
Storage
Switch
VmOrTemplate
)

Expand Down
36 changes: 36 additions & 0 deletions spec/lib/rbac/filterer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,42 @@ 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 Lans' do
let!(:lan) { FactoryGirl.create_list(:lan, 2).first }

before do
lan.tag_with('/managed/environment/prod', :ns => '*')
end

it 'lists only tagged Lans' do
results = described_class.search(:class => Lan, :user => user).first
expect(results).to match_array [lan]
end

it 'lists only all Lans' do
results = described_class.search(:class => Lan, :user => admin_user).first
expect(results).to match_array Lan.all
end
end

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

Expand Down

0 comments on commit 705ec0e

Please sign in to comment.