Respond with 422 if /auth/github does not get a token

Fix #77
This commit is contained in:
Henrik Hodne 2013-10-23 19:35:03 -05:00
parent e35b7a3301
commit 8f4dd0d2df
2 changed files with 10 additions and 0 deletions

View File

@ -78,6 +78,10 @@ class Travis::Api::App
#
# * **github_token**: GitHub token for checking authorization (required)
post '/github' do
unless params[:github_token]
halt 422, { "error" => "Must pass 'github_token' parameter" }
end
{ 'access_token' => github_to_travis(params[:github_token], app_id: 1, drop_token: true) }
end

View File

@ -64,5 +64,11 @@ describe Travis::Api::App::Endpoint::Authorization do
it 'does not store the token' do
user_for('public repos').github_oauth_token.should_not == 'public repos'
end
it "errors if no token is given" do
post("/auth/github").should_not be_ok
last_response.status.should == 422
body.should_not include("access_token")
end
end
end