Commit 3e4aa81a authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo

Merge branch '327275-foss-project_security_configuration_api_fuzzing_path-undefined' into 'master'

Don't generate security configuration paths in FOSS [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58953
parents fac7694b 160c1fd4
...@@ -7,5 +7,23 @@ module Ci ...@@ -7,5 +7,23 @@ module Ci
def can_view_pipeline_editor?(project) def can_view_pipeline_editor?(project)
can_collaborate_with_project?(project) can_collaborate_with_project?(project)
end end
def js_pipeline_editor_data(project)
{
"ci-config-path": project.ci_config_path_or_default,
"commit-sha" => project.commit ? project.commit.sha : '',
"default-branch" => project.default_branch,
"empty-state-illustration-path" => image_path('illustrations/empty-state/empty-dag-md.svg'),
"initial-branch-name": params[:branch_name],
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => namespace_project_new_merge_request_path,
"project-path" => project.path,
"project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README')
}
end
end end
end end
Ci::PipelineEditorHelper.prepend_if_ee('EE::Ci::PipelineEditorHelper')
- page_title s_('Pipelines|Pipeline Editor') - page_title s_('Pipelines|Pipeline Editor')
#js-pipeline-editor{ data: { "ci-config-path": @project.ci_config_path_or_default, #js-pipeline-editor{ data: js_pipeline_editor_data(@project) }
"commit-sha" => @project.commit ? @project.commit.sha : '',
"default-branch" => @project.default_branch,
"empty-state-illustration-path" => image_path('illustrations/empty-state/empty-dag-md.svg'),
"initial-branch-name": params[:branch_name],
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => namespace_project_new_merge_request_path,
"project-path" => @project.path,
"project-full-path" => @project.full_path,
"project-namespace" => @project.namespace.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README'),
"api-fuzzing-configuration-path" => project_security_configuration_api_fuzzing_path(@project),
} }
# frozen_string_literal: true
module EE
module Ci
module PipelineEditorHelper
extend ::Gitlab::Utils::Override
override :js_pipeline_editor_data
def js_pipeline_editor_data(project)
return super unless project.licensed_feature_available?(:api_fuzzing)
super.merge(
"api-fuzzing-configuration-path" => project_security_configuration_api_fuzzing_path(project)
)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe EE::Ci::PipelineEditorHelper do
let_it_be(:project) { create(:project, :public, :repository) }
describe '#js_pipeline_editor_data' do
before do
allow(helper)
.to receive(:namespace_project_new_merge_request_path)
.and_return('/mock/project/-/merge_requests/new')
allow(helper)
.to receive(:image_path)
.and_return('foo')
end
subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) }
context 'with licensed feature' do
before do
stub_licensed_features(api_fuzzing: true)
end
it 'returns ee specific values' do
expect(pipeline_editor_data.keys).to include('api-fuzzing-configuration-path')
end
end
context 'without licensed feature' do
it 'does not return the API fuzzing path' do
expect(pipeline_editor_data.keys).not_to include('api-fuzzing-configuration-path')
end
end
end
end
...@@ -20,4 +20,36 @@ RSpec.describe Ci::PipelineEditorHelper do ...@@ -20,4 +20,36 @@ RSpec.describe Ci::PipelineEditorHelper do
expect(subject).to be false expect(subject).to be false
end end
end end
describe '#js_pipeline_editor_data' do
let(:project) { create(:project, :repository) }
before do
allow(helper)
.to receive(:namespace_project_new_merge_request_path)
.and_return('/mock/project/-/merge_requests/new')
allow(helper)
.to receive(:image_path)
.and_return('foo')
end
subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) }
it 'returns pipeline editor data' do
expect(pipeline_editor_data).to eq({
"ci-config-path": project.ci_config_path_or_default,
"commit-sha" => project.commit.sha,
"default-branch" => project.default_branch,
"empty-state-illustration-path" => 'foo',
"initial-branch-name": nil,
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => '/mock/project/-/merge_requests/new',
"project-path" => project.path,
"project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README')
})
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ci::PipelineEditorHelper do
let_it_be(:project) { create(:project, :public, :repository) }
describe '#js_pipeline_editor_data' do
before do
allow(helper).to receive(:namespace_project_new_merge_request_path).and_return('/mock/project/-/merge_requests/new')
end
subject { helper.js_pipeline_editor_data(project) }
it {
is_expected.to match({
"ci-config-path": project.ci_config_path_or_default,
"commit-sha" => project.commit.sha,
"default-branch" => project.default_branch,
"empty-state-illustration-path" => match_asset_path("/assets/illustrations/empty-state/empty-dag-md.svg"),
"initial-branch-name": nil,
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'),
"new-merge-request-path" => '/mock/project/-/merge_requests/new',
"project-path" => project.path,
"project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path,
"yml-help-page-path" => help_page_path('ci/yaml/README')
})
}
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