Commit d455bcf1 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/security/gitlab@13-10-stable-ee

parent b8cacd68
...@@ -32,6 +32,8 @@ module Projects ...@@ -32,6 +32,8 @@ module Projects
if fork_network = @project.root_of_fork_network if fork_network = @project.root_of_fork_network
fork_network.update(root_project: nil, deleted_root_project_name: @project.full_name) fork_network.update(root_project: nil, deleted_root_project_name: @project.full_name)
end end
@project.leave_pool_repository
end end
# rubocop: disable Cop/InBatches # rubocop: disable Cop/InBatches
......
---
title: Leave pool repository on fork unlinking
merge_request:
author:
type: security
---
title: Require POST request to trigger system hooks
merge_request:
author:
type: security
...@@ -88,7 +88,7 @@ Example response: ...@@ -88,7 +88,7 @@ Example response:
## Test system hook ## Test system hook
```plaintext ```plaintext
GET /hooks/:id POST /hooks/:id
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -98,7 +98,7 @@ GET /hooks/:id ...@@ -98,7 +98,7 @@ GET /hooks/:id
Example request: Example request:
```shell ```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/2" curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks/1"
``` ```
Example response: Example response:
......
...@@ -47,7 +47,7 @@ module API ...@@ -47,7 +47,7 @@ module API
params do params do
requires :id, type: Integer, desc: 'The ID of the system hook' requires :id, type: Integer, desc: 'The ID of the system hook'
end end
get ":id" do post ":id" do
hook = SystemHook.find(params[:id]) hook = SystemHook.find(params[:id])
data = { data = {
event_name: "project_create", event_name: "project_create",
......
...@@ -6,7 +6,7 @@ FactoryBot.define do ...@@ -6,7 +6,7 @@ FactoryBot.define do
state { :none } state { :none }
before(:create) do |pool| before(:create) do |pool|
pool.source_project = create(:project, :repository) pool.source_project ||= create(:project, :repository)
pool.source_project.update!(pool_repository: pool) pool.source_project.update!(pool_repository: pool)
end end
......
...@@ -103,15 +103,15 @@ RSpec.describe API::SystemHooks do ...@@ -103,15 +103,15 @@ RSpec.describe API::SystemHooks do
end end
end end
describe "GET /hooks/:id" do describe 'POST /hooks/:id' do
it "returns hook by id" do it "returns and trigger hook by id" do
get api("/hooks/#{hook.id}", admin) post api("/hooks/#{hook.id}", admin)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:created)
expect(json_response['event_name']).to eq('project_create') expect(json_response['event_name']).to eq('project_create')
end end
it "returns 404 on failure" do it "returns 404 on failure" do
get api("/hooks/404", admin) post api("/hooks/404", admin)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -403,7 +403,7 @@ RSpec.describe Projects::ForkService do ...@@ -403,7 +403,7 @@ RSpec.describe Projects::ForkService do
end end
context 'when forking with object pools' do context 'when forking with object pools' do
let(:fork_from_project) { create(:project, :public) } let(:fork_from_project) { create(:project, :repository, :public) }
let(:forker) { create(:user) } let(:forker) { create(:user) }
context 'when no pool exists' do context 'when no pool exists' do
......
...@@ -207,6 +207,17 @@ RSpec.describe Projects::UnlinkForkService, :use_clean_rails_memory_store_cachin ...@@ -207,6 +207,17 @@ RSpec.describe Projects::UnlinkForkService, :use_clean_rails_memory_store_cachin
end end
end end
context 'a project with pool repository' do
let(:project) { create(:project, :public, :repository) }
let!(:pool_repository) { create(:pool_repository, :ready, source_project: project) }
subject { described_class.new(project, user) }
it 'when unlinked leaves pool repository' do
expect { subject.execute }.to change { project.reload.has_pool_repository? }.from(true).to(false)
end
end
context 'when given project is not part of a fork network' do context 'when given project is not part of a fork network' do
let!(:project_without_forks) { create(:project, :public) } let!(:project_without_forks) { create(:project, :public) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment