Commit 54ab9bb6df3a2cd9f9384aebae07e0b18acee10b
1 parent
fd01f3aa
Exists in
master
and in
4 other branches
API: return status code 400 if filepath of raw file blob not given
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
lib/api/projects.rb
| ... | ... | @@ -451,6 +451,8 @@ module Gitlab |
| 451 | 451 | get ":id/repository/commits/:sha/blob" do |
| 452 | 452 | authorize! :download_code, user_project |
| 453 | 453 | |
| 454 | + error!("Filepath must be specified", 400) if !params.has_key? :filepath | |
| 455 | + | |
| 454 | 456 | ref = params[:sha] |
| 455 | 457 | |
| 456 | 458 | commit = user_project.repository.commit ref | ... | ... |
spec/requests/api/projects_spec.rb
| ... | ... | @@ -468,7 +468,7 @@ describe Gitlab::API do |
| 468 | 468 | end |
| 469 | 469 | end |
| 470 | 470 | |
| 471 | - describe "GET /projects/:id/:sha/blob" do | |
| 471 | + describe "GET /projects/:id/repository/commits/:sha/blob" do | |
| 472 | 472 | it "should get the raw file contents" do |
| 473 | 473 | get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user) |
| 474 | 474 | response.status.should == 200 |
| ... | ... | @@ -483,5 +483,10 @@ describe Gitlab::API do |
| 483 | 483 | get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.invalid", user) |
| 484 | 484 | response.status.should == 404 |
| 485 | 485 | end |
| 486 | + | |
| 487 | + it "should return a 400 error if filepath is missing" do | |
| 488 | + get api("/projects/#{project.id}/repository/commits/master/blob", user) | |
| 489 | + response.status.should == 400 | |
| 490 | + end | |
| 486 | 491 | end |
| 487 | 492 | end | ... | ... |