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
Fixes #18738 - fixes the sub query #6639
Conversation
@ares, thanks for your PR! By analyzing the history of the files in this pull request, we identified @johnpmitsch, @jlsherrill and @komidore64 to be potential reviewers. |
def test_scoped_search_with_permissions | ||
cv = FactoryGirl.create(:katello_content_view) | ||
setup_current_user_with_permissions(:name => 'view_content_views', :search => "name = #{cv.name}" | ||
@query = ContentView.authorized(:view_content_views) |
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.
unexpected token tIVAR
fd6a145
to
146d62f
Compare
@query = ContentView.authorized(:view_content_views) | ||
params = {} | ||
@controller.stubs(:params).returns(params) | ||
login_user(setup_user_with_permissions(:name => 'view_content_views', :search => "name = #{cv.name}", User.find(users(:restricted).id))) |
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.
unexpected token tRPAREN
fbab4c9
to
9e90c02
Compare
Ok, I've got tests green. The tests does not test it on Activation key but still has some value. The reason why I don't test it on AK is that there's no factory defined for it and I don't feel up to experiment with what it needs. If someone provides the factory to easily create AK, I'm happy to add one more tests. But I hope that this does not block the PR. I'd appreciate if someone could review and test. I don't have write permissions on this repo so whoever ACKs please merge too :-) EDIT: oh too soon, the test seems to fail again |
[test] |
def test_scoped_search_with_permissions | ||
cv = FactoryGirl.create(:katello_content_view) | ||
user = FactoryGirl.create(:user, :organization_ids => [cv.organization_id]) | ||
login_user(setup_user_with_permissions({:name => 'view_content_views', :search => "name = #{cv.name}"}, user.id))) |
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.
unexpected token tRPAREN
@ares this change makes sense, looks like a test is still failing. |
Yeah, honestly I don't know why and I'd appreciate if someone else provides the test or I'll remove it completely. I spent too much time on this already and without deeper knowledge of katello fixtures and factories I'm not sure how to move further within reasonable time. |
301c4e9
to
43436c5
Compare
Tests should be green now, I removed my test that was failing. |
What's the status here? |
@jlsherrill please re-review |
Status was me finding time :) |
@ares doesn't look like the current test actually tests the problem. I had been meaning to help you write a test but hadn't found the time, but here you go:
mind updating to add this test instead? |
Thanks a lot @jlsherrill, patch applied, let's see the test results now. |
ACK thanks @ares! |
I think this has been introduced by this change 142ccd5#diff-56ae1a984a0feed9e676a8e2f8240113R90
I'm not sure but I think it's similarly broken for all katello resources since this is generic method in api_controller. The problem I believe is in the fact the query needs to select only id attribute but it can contain other conditions, like
name = Library
. Doing the pluck introduces one more SQL query but make it safer since it does the (SELECT *) and returns id only, therefore it supports all conditions specified in filters.I'm not familiar enough with katello testing infrastructure, so pointing me to some place where I could add a test for this and tips how to stub data would be appreciated.