-
Notifications
You must be signed in to change notification settings - Fork 441
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
WIP: Always use backend response for requests to source/:project_name #16955
base: master
Are you sure you want to change the base?
Changes from all commits
457bebe
4dde082
63e715a
6a64e22
9795084
c61695c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ class SourceProjectController < SourceController | |
# GET /source/:project | ||
def show | ||
project_name = params[:project] | ||
if params.key?(:deleted) | ||
unless Project.find_by_name(project_name) || Project.is_remote_project?(project_name) | ||
# project is deleted or not accessible | ||
validate_visibility_of_deleted_project(project_name) | ||
end | ||
|
||
if params[:deleted] == '1' && !(Project.find_by_name(project_name) || Project.is_remote_project?(project_name)) | ||
# project is deleted or not accessible | ||
validate_visibility_of_deleted_project(project_name) | ||
# We have to pass it to the backend at this point, because the rest | ||
# of the method expects an existing project | ||
pass_to_backend | ||
return | ||
end | ||
|
@@ -19,43 +20,43 @@ def show | |
return | ||
end | ||
|
||
# This implicitly also checks if the user can access the project (for hidden projects). | ||
# We have to make sure to initialize the project already at this | ||
# point, even we dont need the object in most cases because of that fact. | ||
# TODO: Don't implicitly use the finder logic to authorize! | ||
@project = Project.find_by_name(project_name) | ||
raise Project::UnknownObjectError, "Project not found: #{project_name}" unless @project | ||
|
||
# we let the backend list the packages after we verified the project is visible | ||
if params.key?(:view) | ||
case params[:view] | ||
when 'verboseproductlist' | ||
@products = Product.all_products(@project, params[:expand]) | ||
render 'source/verboseproductlist', formats: [:xml] | ||
return | ||
when 'productlist' | ||
@products = Product.all_products(@project, params[:expand]) | ||
render 'source/productlist', formats: [:xml] | ||
return | ||
when 'issues' | ||
render_project_issues | ||
when 'info' | ||
pass_to_backend | ||
else | ||
raise InvalidParameterError, "'#{params[:view]}' is not a valid 'view' parameter value." | ||
end | ||
unless params.key?(:view) | ||
pass_to_backend | ||
return | ||
end | ||
|
||
render_project_packages | ||
raise InvalidParameterError, "'#{params[:view]}' is not a valid 'view' parameter value." unless params[:view].in?(%w[verboseproductlist productlist issues info]) | ||
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. Where do we show this message? |
||
|
||
# rubocop:disable Style/RedundantReturn | ||
case params[:view] | ||
when 'verboseproductlist' | ||
@products = Product.all_products(@project, params[:expand]) | ||
render 'source/verboseproductlist', formats: [:xml] | ||
return | ||
when 'productlist' | ||
@products = Product.all_products(@project, params[:expand]) | ||
render 'source/productlist', formats: [:xml] | ||
return | ||
when 'issues' | ||
render_project_issues | ||
when 'info' | ||
pass_to_backend | ||
end | ||
# rubocop:enable Style/RedundantReturn | ||
end | ||
|
||
def render_project_issues | ||
set_issues_defaults | ||
render partial: 'source/project_issues', formats: [:xml] | ||
end | ||
|
||
def render_project_packages | ||
@packages = params.key?(:expand) ? @project.expand_all_packages : @project.packages.pluck(:name) | ||
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. the |
||
render locals: { expand: params.key?(:expand) }, formats: [:xml] | ||
end | ||
|
||
# DELETE /source/:project | ||
def delete | ||
project = Project.get_by_name(params[:project]) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,6 +35,9 @@ def resubmit_all_fixtures | |||||||||
assert_response :success | ||||||||||
packages = Xmlhash.parse(@response.body) | ||||||||||
packages.elements('entry') do |p| | ||||||||||
# skip multibuild flavors | ||||||||||
next if p['name'].include?(':') | ||||||||||
Comment on lines
37
to
+39
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. Try to use functional approaches when possible. It moves out the complexity from inside each iteration:
Suggested change
|
||||||||||
|
||||||||||
get "/source/#{name}/#{p['name']}/_meta" | ||||||||||
assert_response :success | ||||||||||
r = @response.body | ||||||||||
|
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.
Tracking this here https://trello.com/c/rKlWGIdR/203-dont-use-projectfindbyname-for-implicit-authorization