Commit acc74978 authored by Shinya Maeda's avatar Shinya Maeda

Revert autheticate! in Trigger API

parent 75130a41
......@@ -15,16 +15,16 @@ module API
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
end
post ":id/(ref/:ref/)trigger/pipeline", requirements: { ref: /.+/ } do
authenticate!
authorize! :admin_build, user_project
# validate variables
params[:variables] = params[:variables].to_h
unless params[:variables].all? { |key, value| key.is_a?(String) && value.is_a?(String) }
render_api_error!('variables needs to be a map of key-valued strings', 400)
end
result = Ci::PipelineTriggerService.new(user_project, nil, params).execute
project = find_project(params[:id])
not_found! unless project
result = Ci::PipelineTriggerService.new(project, nil, params).execute
not_found! unless result
if result[:http_status]
......
......@@ -16,16 +16,16 @@ module API
optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
end
post ":id/(ref/:ref/)trigger/builds", requirements: { ref: /.+/ } do
authenticate!
authorize! :admin_build, user_project
# validate variables
params[:variables] = params[:variables].to_h
unless params[:variables].all? { |key, value| key.is_a?(String) && value.is_a?(String) }
render_api_error!('variables needs to be a map of key-valued strings', 400)
end
result = Ci::PipelineTriggerService.new(user_project, nil, params).execute
project = find_project(params[:id])
not_found! unless project
result = Ci::PipelineTriggerService.new(project, nil, params).execute
not_found! unless result
if result[:http_status]
......
......@@ -107,7 +107,7 @@ FactoryGirl.define do
end
trait :triggered do
trigger_request factory: :ci_trigger_request_with_variables
trigger_request factory: :ci_trigger_request_with_variables # TODO:
end
after(:build) do |build, evaluator|
......
......@@ -2,14 +2,13 @@ FactoryGirl.define do
factory :ci_trigger_request, class: Ci::TriggerRequest do
trigger factory: :ci_trigger
# TODO:
# factory :ci_trigger_request_with_variables do
# variables do
# {
# TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
# TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
# }
# end
# end
factory :ci_trigger_request_with_variables do
variables do
{
TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
}
end
end
end
end
......@@ -292,7 +292,7 @@ feature 'Jobs' do
end
feature 'Variables' do
let(:trigger_request) { create(:ci_trigger_request_with_variables) }
let(:trigger_request) { create(:ci_trigger_request_with_variables) } # TODO:
let(:job) do
create :ci_build, pipeline: pipeline, trigger_request: trigger_request
......
......@@ -1492,7 +1492,7 @@ describe Ci::Build do
context 'when build is for triggers' do
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) } # TODO:
let(:user_trigger_variable) do
{ key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1', public: false }
end
......
......@@ -559,7 +559,7 @@ describe API::Runner do
before do
trigger = create(:ci_trigger, project: project)
create(:ci_trigger_request_with_variables, pipeline: pipeline, builds: [job], trigger: trigger)
create(:ci_trigger_request_with_variables, pipeline: pipeline, builds: [job], trigger: trigger) # TODO:
project.variables << Ci::Variable.new(key: 'SECRET_KEY', value: 'secret_value')
end
......
......@@ -37,7 +37,7 @@ describe API::V3::Triggers do
it 'returns unauthorized if token is for different project' do
post v3_api("/projects/#{project2.id}/trigger/builds"), options.merge(ref: 'master')
expect(response).to have_http_status(401)
expect(response).to have_http_status(404)
end
end
......
......@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do
end
describe 'shows trigger variables in sidebar' do
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) } # TODO:
before do
build.trigger_request = trigger_request
......
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