diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-09-09 20:29:31 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-09-09 20:29:31 +0000 |
commit | 814d12b8c72b0e8a4f9025ffb1373c11b36a061a (patch) | |
tree | 4015aacfc24b19d0e4bbb733cf0af65306b03aa2 /spec | |
parent | 84b93b67f0c560103914780f05c3871b79476186 (diff) | |
parent | 6b7456017ded3c12751e27fa3839157f0064a0f7 (diff) | |
download | gitlab-ce-814d12b8c72b0e8a4f9025ffb1373c11b36a061a.tar.gz |
Merge branch 'api_settings' into 'master'
Improve application settings API
Closes #58180
See merge request gitlab-org/gitlab-ce!31149
Diffstat (limited to 'spec')
-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 |