diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2019-04-11 18:26:16 +0300 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2019-05-29 14:03:50 +0300 |
commit | 3d4821a8e76d49b388b218824714d3bcb8c54dbf (patch) | |
tree | eca97cf51cb76b05fb335ac8f1b172f44965751e /spec/controllers/concerns | |
parent | aa8e75916ad8cf3f8481bc740519676205dd0082 (diff) | |
download | gitlab-ce-3d4821a8e76d49b388b218824714d3bcb8c54dbf.tar.gz |
Hide password on import by url form
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r-- | spec/controllers/concerns/import_url_params_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/controllers/concerns/import_url_params_spec.rb b/spec/controllers/concerns/import_url_params_spec.rb new file mode 100644 index 00000000000..fc5dfb5263f --- /dev/null +++ b/spec/controllers/concerns/import_url_params_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ImportUrlParams do + let(:import_url_params) do + controller = OpenStruct.new(params: params).extend(described_class) + controller.import_url_params + end + + context 'url and password separately provided' do + let(:params) do + ActionController::Parameters.new(project: { + import_url: 'https://url.com', + import_url_user: 'user', import_url_password: 'password' + }) + end + + describe '#import_url_params' do + it 'returns hash with import_url' do + expect(import_url_params).to eq( + import_url: "https://user:password@url.com" + ) + end + end + end + + context 'url with provided empty credentials' do + let(:params) do + ActionController::Parameters.new(project: { + import_url: 'https://user:password@url.com', + import_url_user: '', import_url_password: '' + }) + end + + describe '#import_url_params' do + it 'does not change the url' do + expect(import_url_params).to eq( + import_url: "https://user:password@url.com" + ) + end + end + end +end |