diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-06-07 20:52:30 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-06-07 20:52:30 +0000 |
commit | 4fc02032148b3b6c3628ec221e6b10d287136aa6 (patch) | |
tree | d552c375396dcd1dd2651a2c1588c9dcc1fb35d9 /qa/spec | |
parent | 85b6b56a73c15eff10119de5ced2d36ad9125e86 (diff) | |
download | gitlab-ce-4fc02032148b3b6c3628ec221e6b10d287136aa6.tar.gz |
QA: Redact credentials from URI in git output
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/git/repository_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb new file mode 100644 index 00000000000..ee1f08da238 --- /dev/null +++ b/qa/spec/git/repository_spec.rb @@ -0,0 +1,40 @@ +describe QA::Git::Repository do + let(:repository) { described_class.new } + + before do + cd_empty_temp_directory + set_bad_uri + repository.use_default_credentials + end + + describe '#clone' do + it 'redacts credentials from the URI in output' do + output, _ = repository.clone + + expect(output).to include("fatal: unable to access 'http://****@foo/bar.git/'") + end + end + + describe '#push_changes' do + before do + `git init` # need a repo to push from + end + + it 'redacts credentials from the URI in output' do + output, _ = repository.push_changes + + expect(output).to include("error: failed to push some refs to 'http://****@foo/bar.git'") + end + end + + def cd_empty_temp_directory + tmp_dir = 'tmp/git-repository-spec/' + FileUtils.rm_r(tmp_dir) if File.exist?(tmp_dir) + FileUtils.mkdir_p tmp_dir + FileUtils.cd tmp_dir + end + + def set_bad_uri + repository.uri = 'http://foo/bar.git' + end +end |