Commit b802c7af authored by Peter Leitzen's avatar Peter Leitzen

Move Tracing controller into Core

This commit moves the Tracing operations controller
from Ultimate to Core exposing the route to the public
but not linking it yet.
parent bfbf0878
# frozen_string_literal: true
module Projects
class TracingsController < Projects::ApplicationController
content_security_policy do |p|
next if p.directives.blank?
global_frame_src = p.frame_src
p.frame_src -> { frame_src_csp_policy(global_frame_src) }
end
before_action :authorize_update_environment!
def show
end
private
def frame_src_csp_policy(global_frame_src)
external_url = @project&.tracing_setting&.external_url
external_url.presence || global_frame_src
end
end
end
......@@ -307,6 +307,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get 'details', on: :member
end
resource :tracing, only: [:show]
post 'incidents/integrations/pagerduty', to: 'incident_management/pager_duty_incidents#create'
resources :incidents, only: [:index]
......@@ -551,6 +553,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
Gitlab::Routing.redirect_legacy_paths(self, :mirror, :tags,
:cycle_analytics, :mattermost, :variables, :triggers,
:environments, :protected_environments, :error_tracking, :alert_management,
:tracing,
:serverless, :clusters, :audit_events, :wikis, :merge_requests,
:vulnerability_feedback, :security, :dependencies, :issues)
end
......
# frozen_string_literal: true
class Projects::TracingsController < Projects::ApplicationController
content_security_policy do |p|
next if p.directives.blank?
global_frame_src = p.frame_src
p.frame_src -> { frame_src_csp_policy(global_frame_src) }
end
before_action :check_license
before_action :authorize_update_environment!
def show
end
private
def check_license
render_404 unless @project.feature_available?(:tracing, current_user)
end
def frame_src_csp_policy(global_frame_src)
external_url = @project&.tracing_setting&.external_url
external_url.presence || global_frame_src
end
end
......@@ -127,8 +127,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resource :tracing, only: [:show]
post '/restore' => '/projects#restore', as: :restore
resource :insights, only: [:show], trailing_slash: true do
......
......@@ -3,21 +3,18 @@
require 'spec_helper'
RSpec.describe 'projects/tracings/show' do
let(:project) { create(:project, :repository) }
let(:error_tracking_setting) { create(:project_error_tracking_setting, project: project) }
let_it_be_with_reload(:project) { create(:project) }
let_it_be(:error_tracking_setting) { create(:project_error_tracking_setting, project: project) }
before do
assign(:project, project)
assign(:repository, project.repository)
allow(view).to receive(:current_ref).and_return('master')
allow(view).to receive(:error_tracking_setting).and_return(error_tracking_setting)
allow(view).to receive(:incident_management_available?) { false }
stub_licensed_features(tracing: true)
allow(view).to receive(:error_tracking_setting)
.and_return(error_tracking_setting)
end
context 'with project.tracing_external_url' do
let(:tracing_url) { 'https://tracing.url' }
let(:tracing_setting) { create(:project_tracing_setting, project: project, external_url: tracing_url) }
let_it_be(:tracing_url) { 'https://tracing.url' }
let_it_be(:tracing_setting) { create(:project_tracing_setting, project: project, external_url: tracing_url) }
before do
allow(view).to receive(:can?).and_return(true)
......
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