Commit 9e713e25 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'mc/feature/log-failures-denials-external-pipeline-validation' into 'master'

Log events for external pipeline validation

Closes #55694

See merge request gitlab-org/gitlab!27818
parents 1fb2df0c 425ce627
...@@ -13,7 +13,12 @@ module Gitlab ...@@ -13,7 +13,12 @@ module Gitlab
VALIDATION_REQUEST_TIMEOUT = 5 VALIDATION_REQUEST_TIMEOUT = 5
def perform! def perform!
error('External validation failed', drop_reason: :external_validation_failure) unless validate_external pipeline_authorized = validate_external
log_message = pipeline_authorized ? 'authorized' : 'not authorized'
Gitlab::AppLogger.info(message: "Pipeline #{log_message}", project_id: @pipeline.project.id, user_id: @pipeline.user.id)
error('External validation failed', drop_reason: :external_validation_failure) unless pipeline_authorized
end end
def break? def break?
......
...@@ -67,6 +67,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do ...@@ -67,6 +67,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
expect(step.break?).to be false expect(step.break?).to be false
end end
it 'logs the authorization' do
expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline authorized', project_id: project.id, user_id: user.id)
perform!
end
end end
context 'when validation return false' do context 'when validation return false' do
...@@ -86,6 +92,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do ...@@ -86,6 +92,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
expect(step.break?).to be true expect(step.break?).to be true
end end
it 'logs the authorization' do
expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline not authorized', project_id: project.id, user_id: user.id)
perform!
end
end end
end 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