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

Make all public images be visible for provisioning. #17058

Merged
merged 1 commit into from Jul 3, 2018

Conversation

alexander-demicev
Copy link

This PR makes all public images visible for tenants. The issue is that when we have MiQ user with visibility to 1 cloud tenant public images of admin user are not visible.
https://bugzilla.redhat.com/show_bug.cgi?id=1524368

ping @aufi

@miq-bot miq-bot added the wip label Feb 27, 2018
@alexander-demicev
Copy link
Author

@lpichler Can you take a look to it?

@lpichler
Copy link
Contributor

lpichler commented Mar 7, 2018

@alexander-demichev so far looks good but can you add some specs to see RBAC cases ?
thanks!

@alexander-demicev
Copy link
Author

alexander-demicev commented Mar 7, 2018

@lpichler Sure, I will do it

@alexander-demicev
Copy link
Author

@lpichler Hi, I added some tests, is it ok now?

@alexander-demicev alexander-demicev changed the title [WIP] Make all public images be visible for provisioning. Make all public images be visible for provisioning. Mar 12, 2018
@miq-bot miq-bot removed the wip label Mar 12, 2018
@miq-bot
Copy link
Member

miq-bot commented Apr 4, 2018

This pull request is not mergeable. Please rebase and repush.

@alexander-demicev alexander-demicev force-pushed the public-images-tenants branch 2 times, most recently from 0194b99 to a2f4837 Compare April 10, 2018 16:43
@mansam
Copy link
Contributor

mansam commented Apr 10, 2018

Hi @lpichler, is there anything else @alexander-demichev needs to do on this? Thanks! :)

@lpichler
Copy link
Contributor

lpichler commented Apr 11, 2018

Hi @alexander-demichev, your test are good but as you nicely built objects user - group - role, can you also add some test with RBAC call ? (you will need to create some template cloud )
I mean:

 let (:cloud_template_1) { } 
 let (:cloud_template_2) { } 

  it 'returns all cloud templates when user is admin ' do 

      results  = described_class.search(:class => CloudTemplate, :user => any_user)
      expect(results).to (CloudTemplate.all)
  end

  it 'returns only cloud templates related to restricted user is admin' do 
    ... 
  end

and such specs what I am suggesting are placed usually in filterer_spec.rb

@miq-bot
Copy link
Member

miq-bot commented Jun 7, 2018

This pull request is not mergeable. Please rebase and repush.

@JPrause
Copy link
Member

JPrause commented Jun 22, 2018

@alexander-demichev are there further review/edits needed?
Who can merged is all is good. (although I see it's unmergable now)

@@ -122,6 +122,13 @@ def self.display_name(number = 1)
n_('Image', 'Images', number)
end

def self.tenant_id_clause(user_or_group)
template_tenant_ids = MiqTemplate.accessible_tenant_ids(user_or_group, Rbac.accessible_tenant_ids_strategy(MiqTemplate))
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be just

accessible_tenant_ids(user_or_group, Rbac.accessible_tenant_ids_strategy(self))

let!(:cloud_template) { FactoryGirl.create(:template_cloud, :tenant => tenant_3, :publicly_available => true) }

context "returns all public cloud templates" do
it "" do
Copy link
Contributor

Choose a reason for hiding this comment

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

missing description for it ""

let(:tenant_3) { FactoryGirl.create(:tenant, :parent => tenant_2) } # T3
let!(:cloud_template) { FactoryGirl.create(:template_cloud, :tenant => tenant_3, :publicly_available => true) }

context "returns all public cloud templates" do
Copy link
Contributor

Choose a reason for hiding this comment

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

context is not needed here, it looks like that message should in related 'it'

Copy link
Contributor

Choose a reason for hiding this comment

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

you can learn more here: http://www.betterspecs.org


context "ignores private cloud templates" do
let!(:cloud_template) { FactoryGirl.create(:template_cloud, :tenant => tenant_3, :publicly_available => false) }
it "" do
Copy link
Contributor

Choose a reason for hiding this comment

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

missing description

@lpichler
Copy link
Contributor

@alexander-demichev I put some comments here, otherwise LGTM 👍

@miq-bot assign @gtanzillo

@miq-bot
Copy link
Member

miq-bot commented Jul 2, 2018

Checked commit alexander-demicev@e5d2edd with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@Fryguy
Copy link
Member

Fryguy commented Jul 2, 2018

Something about this API feels off...I don't understand why a model would have clause like this as opposed to an ActiveRecord scope. @NickLaMuro @kbrock Thoughts here?

@NickLaMuro
Copy link
Member

@Fryguy at first glance, I have seen this before:

https://github.com/ManageIQ/manageiq/blob/6627b3ba/app/models/mixins/cloud_tenancy_mixin.rb#L16-L18

So it is a method in this case as well, but defined in a mixin in this case.

I mean, as far as whether it is a scope or not, I guess I don't have an opinion (since one is just an shorthand for the other). And I think you are more concerned about the pattern that is in place for tenancy plus RBAC, and for that, I don't know what I think without giving it some more thought.

This seems to be be at least following the pattern in place for the TenancyCommonMixin:

https://github.com/ManageIQ/manageiq/blob/6627b3ba704820e9cd540dfbfc8ef48aa197f784/app/models/mixins/tenancy_common_mixin.rb

But unsure if that pattern is a good thing overall.

@gtanzillo
Copy link
Member

As @NickLaMuro pointed out, that is the pattern we've been using for cases where the generic tenant access doesn't fit a particular class. It may not be ideal but we've done this for a handful of classes already.

@gtanzillo gtanzillo added this to the Sprint 89 Ending Jul 2, 2018 milestone Jul 3, 2018
@gtanzillo gtanzillo merged commit 178f498 into ManageIQ:master Jul 3, 2018
@simaishi
Copy link
Contributor

simaishi commented Jul 5, 2018

@alexander-demichev @gtanzillo Can this be gaprindashvili/yes ?

@gtanzillo
Copy link
Member

@simaishi, Yes, I think so. I'll set the label

simaishi pushed a commit that referenced this pull request Jul 6, 2018
Make all public images be visible for provisioning.
(cherry picked from commit 178f498)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1598520
@simaishi
Copy link
Contributor

simaishi commented Jul 6, 2018

Thanks @gtanzillo

Gaprindashvili backport details:

$ git log -1
commit 3f9e0e78e3f84f81a990862224e46002c62c52fe
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Tue Jul 3 05:16:55 2018 -0400

    Merge pull request #17058 from alexander-demichev/public-images-tenants
    
    Make all public images be visible for provisioning.
    (cherry picked from commit 178f498dd0a4e62e2d80c100504b55bf347ebc22)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1598520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants