Change syntax for routes with filename
Previously, the filename was URL-encoded, thus each / was replaced with %2F. This caused issues with some Apache2 configuration, smartly mingling with the URL to either encode it a second time (resulting in %252F) or decoding it (generating a real /). However, for authenticated file downloads with the JWT, we hardly require a byte-by-byte matching. With these changes, the URL parameter is no longer URL-encoded, so that Apache2 won't break our implementation any longer. Further, we use this opportunity to get rid of the unnecessary .json extension for those filename routes, simplifying the routes generated and doing some further cleanup.
This commit is contained in:

committed by
Sebastian Serth

parent
65212c4b4b
commit
17dd8b1267
@ -279,19 +279,9 @@ RSpec.describe SubmissionsController do
|
||||
expect_assigns(submission: :submission)
|
||||
expect_http_status(:ok)
|
||||
|
||||
%i[run test].each do |action|
|
||||
describe "##{action}_url" do
|
||||
let(:url) { response.parsed_body.with_indifferent_access.fetch("#{action}_url") }
|
||||
|
||||
it "starts like the #{action} path" do
|
||||
filename = File.basename(__FILE__)
|
||||
expect(url).to start_with(Rails.application.routes.url_helpers.send(:"#{action}_submission_path", submission, filename).sub(filename, ''))
|
||||
end
|
||||
|
||||
it 'ends with a placeholder' do
|
||||
expect(url).to end_with("#{Submission::FILENAME_URL_PLACEHOLDER}.json")
|
||||
end
|
||||
end
|
||||
it 'includes the desired fields' do
|
||||
expect(response.parsed_body.keys).to include('id', 'files')
|
||||
expect(response.parsed_body['files'].first.keys).to include('id', 'file_id')
|
||||
end
|
||||
|
||||
describe '#render_url' do
|
||||
@ -307,14 +297,6 @@ RSpec.describe SubmissionsController do
|
||||
expect(url).to include '?token='
|
||||
end
|
||||
end
|
||||
|
||||
describe '#score_url' do
|
||||
let(:url) { response.parsed_body.with_indifferent_access.fetch('score_url') }
|
||||
|
||||
it 'corresponds to the score path' do
|
||||
expect(url).to eq(Rails.application.routes.url_helpers.score_submission_path(submission, format: :json))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #test' do
|
||||
|
Reference in New Issue
Block a user