Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-02 01:56:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-02 01:56:42 +0300
commit05aac11ac90b9157ea39944abfcf6be3fd8f9fb9 (patch)
tree845215e22003e8f19a959bd526f3f5ef6ad81883 /spec/services/projects
parentd40003afdea391c2d1396f3ab6c78705fa6d2a79 (diff)
Add latest changes from gitlab-org/security/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/update_remote_mirror_service_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/projects/update_remote_mirror_service_spec.rb b/spec/services/projects/update_remote_mirror_service_spec.rb
index 09244db8010..6785b71fcc0 100644
--- a/spec/services/projects/update_remote_mirror_service_spec.rb
+++ b/spec/services/projects/update_remote_mirror_service_spec.rb
@@ -56,6 +56,40 @@ RSpec.describe Projects::UpdateRemoteMirrorService do
expect(remote_mirror.last_error).to include('Badly broken')
end
+ context 'when the URL is blocked' do
+ before do
+ allow(Gitlab::UrlBlocker).to receive(:blocked_url?).and_return(true)
+ end
+
+ it 'fails and returns error status' do
+ expect(execute!).to eq(status: :error, message: 'The remote mirror URL is invalid.')
+ end
+ end
+
+ context "when given URLs containing escaped elements" do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:url, :result_status) do
+ "https://user:0a%23@test.example.com/project.git" | :success
+ "https://git.example.com:1%2F%2F@source.developers.google.com/project.git" | :success
+ CGI.escape("git://localhost:1234/some-path?some-query=some-val\#@example.com/") | :error
+ CGI.escape(CGI.escape("https://user:0a%23@test.example.com/project.git")) | :error
+ end
+
+ with_them do
+ before do
+ allow(remote_mirror).to receive(:url).and_return(url)
+ allow(service).to receive(:update_mirror).with(remote_mirror).and_return(true)
+ end
+
+ it "returns expected status" do
+ result = execute!
+
+ expect(result[:status]).to eq(result_status)
+ end
+ end
+ end
+
context 'when the update fails because of a `Gitlab::Git::CommandError`' do
before do
allow(remote_mirror).to receive(:update_repository)