Skip to content

Commit

Permalink
Enable tagging for Tenant model in RBAC
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Feb 28, 2018
1 parent ced33a4 commit ebb5b7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Filterer
VmOrTemplate
)

TAGGABLE_FILTER_CLASSES = CLASSES_THAT_PARTICIPATE_IN_RBAC - %w(EmsFolder) + %w(MiqGroup User)
TAGGABLE_FILTER_CLASSES = CLASSES_THAT_PARTICIPATE_IN_RBAC - %w(EmsFolder) + %w(MiqGroup User Tenant)

NETWORK_MODELS_FOR_BELONGSTO_FILTER = %w(
CloudNetwork
Expand Down Expand Up @@ -499,6 +499,9 @@ def scope_targets(klass, scope, rbac_filters, user, miq_group)
scope_by_parent_ids(associated_class, scope, filtered_ids)
elsif [MiqUserRole, MiqGroup, User].include?(klass)
scope_for_user_role_group(klass, scope, miq_group, user, rbac_filters['managed'])
elsif klass == Tenant
filtered_ids = pluck_ids(get_managed_filter_object_ids(scope, rbac_filters['managed']))
scope_by_ids(scope, filtered_ids)
else
scope
end
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/rbac/filterer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
expect(results).to match_array [host_aggregate]
end
end

context "searching for tenants" do
before do
owner_tenant.tag_with('/managed/environment/prod', :ns => '*')
end

it 'list tagged tenants' do
results = described_class.search(:class => Tenant, :user => user).first
expect(results).to match_array [owner_tenant]
end
end
end

context 'with virtual custom attributes' do
Expand Down

0 comments on commit ebb5b7f

Please sign in to comment.