Changing the hook test action to use POST

This commit is contained in:
Francisco Javier López 2018-06-21 10:38:59 +02:00
parent 65f27de7a2
commit 2408519e08
No known key found for this signature in database
GPG Key ID: A12DF17E9D5DDF3C
6 changed files with 10 additions and 5 deletions

View File

@ -10,7 +10,7 @@ module HooksHelper
trigger_human_name = trigger.to_s.tr('_', ' ').camelize
link_to path, rel: 'nofollow' do
link_to path, rel: 'nofollow', method: :post do
content_tag(:span, trigger_human_name)
end
end

View File

@ -0,0 +1,5 @@
---
title: Adding CSRF protection to Hooks test action
merge_request:
author:
type: security

View File

@ -54,7 +54,7 @@ namespace :admin do
resources :hooks, only: [:index, :create, :edit, :update, :destroy] do
member do
get :test
post :test
end
resources :hook_logs, only: [:show] do

View File

@ -301,7 +301,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
member do
get :test
post :test
end
resources :hook_logs, only: [:show] do

View File

@ -79,7 +79,7 @@ end
# edit_admin_hook GET /admin/hooks/:id(.:format) admin/hooks#edit
describe Admin::HooksController, "routing" do
it "to #test" do
expect(get("/admin/hooks/1/test")).to route_to('admin/hooks#test', id: '1')
expect(post("/admin/hooks/1/test")).to route_to('admin/hooks#test', id: '1')
end
it "to #index" do

View File

@ -389,7 +389,7 @@ describe 'project routing' do
# DELETE /:project_id/hooks/:id(.:format) hooks#destroy
describe Projects::HooksController, 'routing' do
it 'to #test' do
expect(get('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
expect(post('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it_behaves_like 'RESTful project resources' do