Commit 54ab9bb6 authored by Sebastian Ziebell's avatar Sebastian Ziebell

API: return status code 400 if filepath of raw file blob not given

parent fd01f3aa
...@@ -451,6 +451,8 @@ module Gitlab ...@@ -451,6 +451,8 @@ module Gitlab
get ":id/repository/commits/:sha/blob" do get ":id/repository/commits/:sha/blob" do
authorize! :download_code, user_project authorize! :download_code, user_project
error!("Filepath must be specified", 400) if !params.has_key? :filepath
ref = params[:sha] ref = params[:sha]
commit = user_project.repository.commit ref commit = user_project.repository.commit ref
......
...@@ -468,7 +468,7 @@ describe Gitlab::API do ...@@ -468,7 +468,7 @@ describe Gitlab::API do
end end
end end
describe "GET /projects/:id/:sha/blob" do describe "GET /projects/:id/repository/commits/:sha/blob" do
it "should get the raw file contents" do it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user) get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
response.status.should == 200 response.status.should == 200
...@@ -483,5 +483,10 @@ describe Gitlab::API do ...@@ -483,5 +483,10 @@ describe Gitlab::API do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.invalid", user) get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.invalid", user)
response.status.should == 404 response.status.should == 404
end end
it "should return a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/commits/master/blob", user)
response.status.should == 400
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment