Commit bded0855 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'enable-sentry-mask-urls' into 'master'

Add sentry tracking to mask url helper

See merge request gitlab-org/gitlab!70891
parents 6e045bcb 906779e6
......@@ -6,7 +6,8 @@ module Routing
return unless Feature.enabled?(:mask_page_urls, type: :ops)
mask_params(Rails.application.routes.recognize_path(request.original_fullpath))
rescue ActionController::RoutingError, URI::InvalidURIError
rescue ActionController::RoutingError, URI::InvalidURIError => e
Gitlab::ErrorTracking.track_exception(e, url: request.original_fullpath)
nil
end
......
......@@ -129,6 +129,29 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end
end
describe 'when it raises exception' do
context 'calls error tracking' do
before do
controller.request.path = '/dashboard/issues'
controller.request.query_string = 'assignee_username=root'
allow(Rails.application.routes).to receive(:recognize_path).and_return({
controller: 'dashboard',
action: 'issues'
})
end
it 'sends error to sentry and returns nil' do
allow(helper).to receive(:mask_params).with(anything).and_raise(ActionController::RoutingError, 'Some routing error')
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
ActionController::RoutingError,
url: '/dashboard/issues?assignee_username=root').and_call_original
expect(helper.masked_page_url).to be_nil
end
end
end
describe 'when feature flag is disabled' do
before do
stub_feature_flags(mask_page_urls: false)
......
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