Commit f1ba1127 authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Bob Van Landuyt

Remove use of term whitelist

Uses preferred terminology 'allowed' instead.
parent 3dcc435c
......@@ -3,12 +3,12 @@
module SafeUrl
extend ActiveSupport::Concern
def safe_url(usernames_whitelist: [])
def safe_url(allowed_usernames: [])
return if url.nil?
uri = URI.parse(url)
uri.password = '*****' if uri.password
uri.user = '*****' if uri.user && !usernames_whitelist.include?(uri.user)
uri.user = '*****' if uri.user && allowed_usernames.exclude?(uri.user)
uri.to_s
rescue URI::Error
end
......
......@@ -207,7 +207,7 @@ class RemoteMirror < ApplicationRecord
end
def safe_url
super(usernames_whitelist: %w[git])
super(allowed_usernames: %w[git])
end
def bare_url
......
......@@ -26,14 +26,16 @@ RSpec.describe SafeUrl do
context 'when URL contains credentials' do
let(:url) { 'http://foo:bar@example.com' }
it { is_expected.to eq('http://*****:*****@example.com')}
it 'masks username and password' do
is_expected.to eq('http://*****:*****@example.com')
end
context 'when username is whitelisted' do
subject { test_class.safe_url(usernames_whitelist: usernames_whitelist) }
context 'when username is allowed' do
subject { test_class.safe_url(allowed_usernames: usernames) }
let(:usernames_whitelist) { %w[foo] }
let(:usernames) { %w[foo] }
it 'does expect the whitelisted username not to be masked' do
it 'masks the password, but not the username' do
is_expected.to eq('http://foo:*****@example.com')
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