diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/requests/api/settings_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/requests/api/settings_spec.rb')
-rw-r--r-- | spec/requests/api/settings_spec.rb | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index 48f5bd114a1..66c0dcaa36c 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -41,10 +41,12 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do expect(json_response['snippet_size_limit']).to eq(50.megabytes) expect(json_response['spam_check_endpoint_enabled']).to be_falsey expect(json_response['spam_check_endpoint_url']).to be_nil + expect(json_response['spam_check_api_key']).to be_nil expect(json_response['wiki_page_max_content_bytes']).to be_a(Integer) expect(json_response['require_admin_approval_after_user_signup']).to eq(true) expect(json_response['personal_access_token_prefix']).to be_nil expect(json_response['admin_mode']).to be(false) + expect(json_response['whats_new_variant']).to eq('all_tiers') end end @@ -121,7 +123,8 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do issues_create_limit: 300, raw_blob_request_limit: 300, spam_check_endpoint_enabled: true, - spam_check_endpoint_url: 'https://example.com/spam_check', + spam_check_endpoint_url: 'grpc://example.com/spam_check', + spam_check_api_key: 'SPAM_CHECK_API_KEY', disabled_oauth_sign_in_sources: 'unknown', import_sources: 'github,bitbucket', wiki_page_max_content_bytes: 12345, @@ -166,7 +169,8 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do expect(json_response['issues_create_limit']).to eq(300) expect(json_response['raw_blob_request_limit']).to eq(300) expect(json_response['spam_check_endpoint_enabled']).to be_truthy - expect(json_response['spam_check_endpoint_url']).to eq('https://example.com/spam_check') + expect(json_response['spam_check_endpoint_url']).to eq('grpc://example.com/spam_check') + expect(json_response['spam_check_api_key']).to eq('SPAM_CHECK_API_KEY') expect(json_response['disabled_oauth_sign_in_sources']).to eq([]) expect(json_response['import_sources']).to match_array(%w(github bitbucket)) expect(json_response['wiki_page_max_content_bytes']).to eq(12345) @@ -459,13 +463,32 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do context "missing spam_check_endpoint_url value when spam_check_endpoint_enabled is true" do it "returns a blank parameter error message" do - put api("/application/settings", admin), params: { spam_check_endpoint_enabled: true } + put api("/application/settings", admin), params: { spam_check_endpoint_enabled: true, spam_check_api_key: "SPAM_CHECK_API_KEY" } expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to eq('spam_check_endpoint_url is missing') end end + context "missing spam_check_api_key value when spam_check_endpoint_enabled is true" do + it "returns a blank parameter error message" do + put api("/application/settings", admin), params: { spam_check_endpoint_enabled: true, spam_check_endpoint_url: "https://example.com/spam_check" } + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['error']).to eq('spam_check_api_key is missing') + end + end + + context "overly long spam_check_api_key" do + it "fails to update the settings with too long spam_check_api_key" do + put api("/application/settings", admin), params: { spam_check_api_key: "0123456789" * 500 } + + expect(response).to have_gitlab_http_status(:bad_request) + message = json_response["message"] + expect(message["spam_check_api_key"]).to include(a_string_matching("is too long")) + end + end + context "personal access token prefix settings" do context "handles validation errors" do it "fails to update the settings with too long prefix" do @@ -485,5 +508,32 @@ RSpec.describe API::Settings, 'Settings', :do_not_mock_admin_mode_setting do end end end + + context 'whats_new_variant setting' do + before do + Gitlab::CurrentSettings.current_application_settings.whats_new_variant_disabled! + end + + it 'updates setting' do + new_value = 'all_tiers' + put api("/application/settings", admin), + params: { + whats_new_variant: new_value + } + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['whats_new_variant']).to eq(new_value) + end + + it 'fails to update setting with invalid value' do + put api("/application/settings", admin), + params: { + whats_new_variant: 'invalid_value' + } + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['error']).to eq('whats_new_variant does not have a valid value') + end + end end end |