Commit f45985a2 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-strip-sentry-dsn' into 'master'

Strip whitespace from Sentry URL

Closes #49621

See merge request gitlab-org/gitlab-ce!21703
parents d2cc536d 8d0767c5
...@@ -219,6 +219,7 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -219,6 +219,7 @@ class ApplicationSetting < ActiveRecord::Base
validate :terms_exist, if: :enforce_terms? validate :terms_exist, if: :enforce_terms?
before_validation :ensure_uuid! before_validation :ensure_uuid!
before_validation :strip_sentry_values
before_save :ensure_runners_registration_token before_save :ensure_runners_registration_token
before_save :ensure_health_check_access_token before_save :ensure_health_check_access_token
...@@ -382,6 +383,11 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -382,6 +383,11 @@ class ApplicationSetting < ActiveRecord::Base
super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) }) super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) })
end end
def strip_sentry_values
sentry_dsn.strip! if sentry_dsn.present?
clientside_sentry_dsn.strip! if clientside_sentry_dsn.present?
end
def performance_bar_allowed_group def performance_bar_allowed_group
Group.find_by_id(performance_bar_allowed_group_id) Group.find_by_id(performance_bar_allowed_group_id)
end end
......
...@@ -305,6 +305,36 @@ describe ApplicationSetting do ...@@ -305,6 +305,36 @@ describe ApplicationSetting do
end end
end end
describe 'setting Sentry DSNs' do
context 'server DSN' do
it 'strips leading and trailing whitespace' do
subject.update(sentry_dsn: ' http://test ')
expect(subject.sentry_dsn).to eq('http://test')
end
it 'handles nil values' do
subject.update(sentry_dsn: nil)
expect(subject.sentry_dsn).to be_nil
end
end
context 'client-side DSN' do
it 'strips leading and trailing whitespace' do
subject.update(clientside_sentry_dsn: ' http://test ')
expect(subject.clientside_sentry_dsn).to eq('http://test')
end
it 'handles nil values' do
subject.update(clientside_sentry_dsn: nil)
expect(subject.clientside_sentry_dsn).to be_nil
end
end
end
describe '#disabled_oauth_sign_in_sources=' do describe '#disabled_oauth_sign_in_sources=' do
before do before do
allow(Devise).to receive(:omniauth_providers).and_return([:github]) allow(Devise).to receive(:omniauth_providers).and_return([:github])
......
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