Skip to content

Commit

Permalink
Github token has to be set up to trigger builds; sample bigtuna.yml f…
Browse files Browse the repository at this point in the history
…ile added
  • Loading branch information
Michal Bugno committed Dec 1, 2010
1 parent 0687194 commit 7b380be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/hooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def github
payload = JSON.parse(params[:payload])
branch = payload["ref"].split("/").last
project = Project.where(:vcs_source => payload["repository"]["url"], :vcs_branch => branch).first
if project and params[:secure] == BigTuna.github_secure
if BigTuna.github_secure.nil?
render :text => "github secure token is not set up", :status => 403
elsif project and params[:secure] == BigTuna.github_secure
trigger_and_respond(project)
else
render :text => "invalid secure token", :status => 404
Expand Down
3 changes: 3 additions & 0 deletions config/bigtuna.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# production:
# read_only: true # default: false
# github_secure: "think_of_secure_token" # default: nil
13 changes: 13 additions & 0 deletions test/integration/autobuild_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,17 @@ def teardown
assert response.body.include?("invalid secure token")
end
end

test "github token has to be set up" do
old_token = BigTuna.config["github_secure"]
begin
BigTuna.config["github_secure"] = nil
assert_equal nil, BigTuna.github_secure
post "/hooks/build/github/4ff", :payload => "{\"ref\":\"refs/heads/master\",\"repository\":{\"url\":\"https://github.com/appelier/githubhook\"}}"
assert_status_code(403)
assert response.body.include?("github secure token is not set up")
ensure
BigTuna.config["github_secure"] = old_token
end
end
end

0 comments on commit 7b380be

Please sign in to comment.