summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@gitlab.com>2016-04-25 09:26:58 +0000
committerRobert Speicher <rspeicher@gmail.com>2016-04-27 13:32:55 -0400
commit0624d6a7f1bafca283df630659dcf28ba3edd35e (patch)
tree3fdb6e6c8eb7c3795f89c6bb0412f0bd887dccae /spec
parentd2d36d5e1c80b095b1768dca6b1443e43ba850a4 (diff)
downloadgitlab-ce-0624d6a7f1bafca283df630659dcf28ba3edd35e.tar.gz
Merge branch 'fix-project-hook-delete-permissions' into 'master'
Prevent users from deleting Webhooks via API they do not own Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15576 See merge request !1959
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/project_hooks_spec.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index 142b637d291..ffb93bbb120 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -148,14 +148,24 @@ describe API::API, 'ProjectHooks', api: true do
expect(response.status).to eq(200)
end
- it "should return success when deleting non existent hook" do
+ it "should return a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user)
- expect(response.status).to eq(200)
+ expect(response.status).to eq(404)
end
it "should return a 405 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user)
expect(response.status).to eq(405)
end
+
+ it "shold return a 404 if a user attempts to delete project hooks he/she does not own" do
+ test_user = create(:user)
+ other_project = create(:project)
+ other_project.team << [test_user, :master]
+
+ delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
+ expect(response.status).to eq(404)
+ expect(WebHook.exists?(hook.id)).to be_truthy
+ end
end
end