diff options
author | Mathieu Parent <math.parent@gmail.com> | 2019-07-25 15:10:30 +0200 |
---|---|---|
committer | Mathieu Parent <math.parent@gmail.com> | 2019-09-09 15:14:52 +0200 |
commit | 85776fa3ffba6f641cf981cb0107f0e4ba882f3e (patch) | |
tree | dd571294c8ee15639c371c1a0f6a71799eea632e /spec/requests/api/settings_spec.rb | |
parent | ea14d17da4d3625eaf6a70a3b38660e5753c5f77 (diff) | |
download | gitlab-ce-85776fa3ffba6f641cf981cb0107f0e4ba882f3e.tar.gz |
Settings API: domain_{black,white}list should be arrays
As in documentation.
Fixes: #58180.
Also remove the requirement between domain_blacklist_enabled and domain_blacklist.
Diffstat (limited to 'spec/requests/api/settings_spec.rb')
-rw-r--r-- | spec/requests/api/settings_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index 048d04cdefd..d98b9be726a 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -252,5 +252,43 @@ describe API::Settings, 'Settings' do expect(json_response['asset_proxy_whitelist']).to eq(['example.com', '*.example.com', 'localhost']) end end + + context 'domain_blacklist settings' do + it 'rejects domain_blacklist_enabled when domain_blacklist is empty' do + put api('/application/settings', admin), + params: { + domain_blacklist_enabled: true, + domain_blacklist: [] + } + + expect(response).to have_gitlab_http_status(400) + message = json_response["message"] + expect(message["domain_blacklist"]).to eq(["Domain blacklist cannot be empty if Blacklist is enabled."]) + end + + it 'allows array for domain_blacklist' do + put api('/application/settings', admin), + params: { + domain_blacklist_enabled: true, + domain_blacklist: ['domain1.com', 'domain2.com'] + } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain_blacklist_enabled']).to be(true) + expect(json_response['domain_blacklist']).to eq(['domain1.com', 'domain2.com']) + end + + it 'allows a string for domain_blacklist' do + put api('/application/settings', admin), + params: { + domain_blacklist_enabled: true, + domain_blacklist: 'domain3.com, *.domain4.com' + } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain_blacklist_enabled']).to be(true) + expect(json_response['domain_blacklist']).to eq(['domain3.com', '*.domain4.com']) + end + end end end |