-
Notifications
You must be signed in to change notification settings - Fork 916
Add tenancy scoping to Switches #22843
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
Conversation
Switches were not filtering on tenant Unfortunately, switches do not have a tenant_id so we needed to add a little extra code to find the tenant through the ems (which is through the host... sorry)
|
Checked commit kbrock@497aa9c with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
Fryguy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but since switches are also scoped to hosts when coming from the other direction, I'm not sure if this handles both directions, since the tests only test with a VM. It should, since the tenancy scoping is on the EMS which is shared.
Would like @agrare also to review.
|
This change looks good for something we'd backport to morohy, but moving forward we should make it work the way the other TenancyMixin'd models work, which is by adding a tenant_id column, and then just using TenancyMixin. This also eliminates the changes to rbac filterer. |
|
@kbrock A conflict occurred during the backport of this pull request to If this pull request is based on another pull request that has not been marked for backport, add the appropriate labels to the other pull request. Otherwise, please create a new pull request direct to the Conflict details: diff --cc lib/rbac/filterer.rb
index 7720299ea7,7f98250ee4..0000000000
--- a/lib/rbac/filterer.rb
+++ b/lib/rbac/filterer.rb
@@@ -139,6 -152,10 +139,13 @@@ module Rba
'Service' => :descendant_ids,
'ServiceTemplate' => :ancestor_ids,
'ServiceTemplateCatalog' => :ancestor_ids,
++<<<<<<< HEAD
++=======
+ 'SecurityGroup' => :descendant_ids,
+ 'SecurityPolicy' => :descendant_ids,
+ 'SecurityPolicyRule' => :descendant_ids,
+ 'Switch' => :descendant_ids,
++>>>>>>> 758d157711 (Merge pull request #22843 from kbrock/rbac_switches)
'Tenant' => :descendant_ids,
'User' => :descendant_ids,
'Vm' => :descendant_ids
diff --cc spec/lib/rbac/filterer_spec.rb
index 68af23b544,cf9b908103..0000000000
--- a/spec/lib/rbac/filterer_spec.rb
+++ b/spec/lib/rbac/filterer_spec.rb
@@@ -832,11 -836,12 +835,18 @@@ RSpec.describe Rbac::Filterer d
end
end
++<<<<<<< HEAD
+ context "with accessible_tenant_ids filtering (strategy = :parent_ids)" do
+ it "can see parent tenant's EMS" do
+ ems = FactoryBot.create(:ems_vmware, :tenant => owner_tenant)
++=======
+ context "with accessible_tenant_ids filtering (strategy = :ancestor_ids)" do
+ it "can see parent and own tenant's EMS" do
+ owned_ems
+ child_ems
++>>>>>>> 758d157711 (Merge pull request #22843 from kbrock/rbac_switches)
results = described_class.search(:class => "ExtManagementSystem", :miq_group => child_group).first
- expect(results).to match_array [ems]
+ expect(results).to match_array [owned_ems, child_ems]
end
it "can't see descendant tenant's EMS" do |
|
Manual backport tp |
|
Backported to |
Add tenancy scoping to Switches (cherry picked from commit 758d157)
This adds tenant filtering to Switches
depends upon:
see also:
aside
Unfortunately, switches do not have a tenant_id
so we needed to add a little extra code to find the tenant through the ems (which is through the host)