-
Notifications
You must be signed in to change notification settings - Fork 71
Fixes #39318 - Allow creating bookmarks for arf_reports controller #610
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
Merged
+20
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/unit/concerns/bookmark_controller_validator_extensions_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| require 'test_plugin_helper' | ||
|
|
||
| class BookmarkControllerValidatorExtensionsTest < ActiveSupport::TestCase | ||
| # All controllers including AutoCompleteSearch, except ComplianceDashboardController which is broken anyway | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Well, not really? |
||
| [ArfReportsController, ScapContentsController, | ||
| PoliciesController, TailoringFilesController].each do |controller_class| | ||
| test "#{controller_class.controller_name} should be a valid bookmark controller" do | ||
| controller = controller_class.controller_name | ||
| bookmark = FactoryBot.build_stubbed(:bookmark, :name => "#{controller} bookmark", | ||
| :controller => controller, | ||
| :query => 'search query', | ||
| :public => true) | ||
| assert bookmark.valid?, "#{controller} should be a valid bookmark controller, errors: #{bookmark.errors.full_messages}" | ||
| end | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
I kinda agree with the copilot, but
uniqwon't remove the values that are with prefixes.What I mean is:
controllerswill have thoseforeman_openscap[/_]prefixed values and then we add the new stripped values, which makes me wonder what is actually expected and why don't we have that already or at least why do we keep "unexpected" values (if they actually unexpected though). Have we considered a different approach? I mean, the bookmark component sends controller name based onauto_complete_controller_name, but the only place we override it is in templates_controller. Now I wonder if it's something forgotten or we actually want to havevalid_controllers_listwithsuperandprependlogic, which tends to have issues over time.The patch is fine, it fixes the issue, it's just weird to have this way of validation which just confuses the hell out of me right now (especially with Katello's values)
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.
The validator by default looks at db table names and resources through their permissions and collects them in a single big list.
Db table names doesn't work here because arf reports live in the reports table.
Resources through permissions is sort of weird, in this case we're looking at
ForemanOpenscap::ArfReportthat gets turned by#tableizeintoforeman_openscap/arf_reports. The arf reports controller itself isn't namespaced, so its name is "just"arf_reports_controller.An alternative would be namespacing the controller or un-namespacing arf reports.
Katello seems to have their own autocomplete controller concern that works with api paths instead of controller names?
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.
I get that, it's just we send controller's name from UI, but we "validate" the value though db table names and permissions? That's what I find weird.
I'm afraid I didn't check what's going on there, just from high level overview of the patches it gives me creeps how weird is the current state is.
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.
Not exactly. We send the resource name in plural (arf_reports, hosts, foreman_tasks_tasks), so the table name/resource checking makes sense. Saving that value in a
controllercolumn is weird though.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.
But with
controllerflavor? Why is controller even mentioned then (either in variables or error message)?Those are mostly rhetorical. It's just seems we're fine with workarounds once again and it pains me a little.
Named as a controller, checked against table or resource. Although those three are not always the same :/
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.
True, true, filed https://projects.theforeman.org/issues/39333 as we won't be able to solve all the problems here.