Commit 32a9c85b authored by Alexis Reigel's avatar Alexis Reigel Committed by Alexis Reigel

revert support for v3 api

parent 850e327c
......@@ -54,7 +54,6 @@ module API
forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner associated with more than one project") if runner.projects.count > 1
forbidden!("Runner associated with more that one group") if runner.groups.count > 1
forbidden!("No access granted") unless user_can_access_runner?(runner)
end
......
......@@ -8,16 +8,10 @@ describe API::V3::Runners do
let(:project) { create(:project, creator_id: user.id) }
let(:project2) { create(:project, creator_id: user.id) }
let(:group) { create(:group).tap { |group| group.add_owner(user) } }
let(:group2) { create(:group).tap { |group| group.add_owner(user) } }
let!(:group_runner) { create(:ci_runner, description: 'Group runner', groups: [group]) }
let!(:two_groups_runner) { create(:ci_runner, description: 'Two groups runner', groups: [group, group2]) }
let!(:shared_runner) { create(:ci_runner, :shared) }
let!(:unused_specific_runner) { create(:ci_runner) }
let!(:project_runner) do
let!(:specific_runner) do
create(:ci_runner).tap do |runner|
create(:ci_runner_project, runner: runner, project: project)
end
......@@ -57,17 +51,9 @@ describe API::V3::Runners do
end.to change { Ci::Runner.specific.count }.by(-1)
end
it 'deletes used project runner' do
it 'deletes used runner' do
expect do
delete v3_api("/runners/#{project_runner.id}", admin)
expect(response).to have_http_status(200)
end.to change { Ci::Runner.specific.count }.by(-1)
end
it 'deletes used group runner' do
expect do
delete v3_api("/runners/#{group_runner.id}", admin)
delete v3_api("/runners/#{specific_runner.id}", admin)
expect(response).to have_gitlab_http_status(200)
end.to change { Ci::Runner.specific.count }.by(-1)
......@@ -91,31 +77,18 @@ describe API::V3::Runners do
context 'when runner is not shared' do
it 'does not delete runner without access to it' do
delete v3_api("/runners/#{project_runner.id}", user2)
delete v3_api("/runners/#{specific_runner.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
it 'does not delete project runner with more than one associated project' do
it 'does not delete runner with more than one associated project' do
delete v3_api("/runners/#{two_projects_runner.id}", user)
expect(response).to have_gitlab_http_status(403)
end
it 'deletes project runner for one owned project' do
it 'deletes runner for one owned project' do
expect do
delete v3_api("/runners/#{group_runner.id}", user)
expect(response).to have_http_status(200)
end.to change { Ci::Runner.specific.count }.by(-1)
end
it 'does not delete group runner with more than one associated project' do
delete v3_api("/runners/#{two_groups_runner.id}", user)
expect(response).to have_http_status(403)
end
it 'deletes group runner for one owned project' do
expect do
delete v3_api("/runners/#{project_runner.id}", user)
delete v3_api("/runners/#{specific_runner.id}", user)
expect(response).to have_gitlab_http_status(200)
end.to change { Ci::Runner.specific.count }.by(-1)
......@@ -124,14 +97,8 @@ describe API::V3::Runners do
end
context 'unauthorized user' do
it 'does not delete project runner' do
delete v3_api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401)
end
it 'does not delete group runner' do
delete v3_api("/runners/#{group_runner.id}")
it 'does not delete runner' do
delete v3_api("/runners/#{specific_runner.id}")
expect(response).to have_gitlab_http_status(401)
end
......@@ -153,7 +120,7 @@ describe API::V3::Runners do
context 'when runner have one associated projects' do
it "does not disable project's runner" do
expect do
delete v3_api("/projects/#{project.id}/runners/#{project_runner.id}", user)
delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(403)
end
......@@ -168,7 +135,7 @@ describe API::V3::Runners do
context 'authorized user without permissions' do
it "does not disable project's runner" do
delete v3_api("/projects/#{project.id}/runners/#{project_runner.id}", user2)
delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
......@@ -176,7 +143,7 @@ describe API::V3::Runners do
context 'unauthorized user' do
it "does not disable project's runner" do
delete v3_api("/projects/#{project.id}/runners/#{project_runner.id}")
delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}")
expect(response).to have_gitlab_http_status(401)
end
......
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