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

remote_service_spec.rb « gitaly « spec « ruby - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5dac8a6b4d555bb4aee283b698d1e6bb02063f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'

describe Gitaly::RemoteService do
  include IntegrationClient
  include TestRepo

  subject { gitaly_stub(:RemoteService) }

  describe 'UpdateRemoteMirror' do
    let(:call) { double(metadata: { 'gitaly-storage-path' => '/path/to/storage' }) }
    let(:repo) { gitaly_repo('default', 'foobar.git') }
    let(:remote) { 'my-remote' }

    context 'request does not have ssh_key and known_hosts set' do
      it 'performs the mirroring update with an empty environment' do
        request = Gitaly::UpdateRemoteMirrorRequest.new(repository: repo, ref_name: remote)

        allow(call).to receive(:each_remote_read).and_return(double(next: request, flat_map: []))
        allow(Gitlab::Git::Repository).to receive(:from_gitaly).and_return(repo)
        allow_any_instance_of(Gitlab::Git::RemoteMirror).to receive(:update)
        expect(Gitlab::Git::SshAuth).to receive(:new).with('', '')

        GitalyServer::RemoteService.new.update_remote_mirror(call)
      end
    end

    context 'request has ssh_key and known_hosts set' do
      it 'calls GitlabProjects#fetch_remote with a custom GIT_SSH_COMMAND' do
        request = Gitaly::UpdateRemoteMirrorRequest.new(
          repository: repo,
          ref_name: remote,
          ssh_key: 'SSH KEY',
          known_hosts: 'KNOWN HOSTS'
        )

        allow(call).to receive(:each_remote_read).and_return(double(next: request, flat_map: []))
        allow(Gitlab::Git::Repository).to receive(:from_gitaly).and_return(repo)
        allow_any_instance_of(Gitlab::Git::RemoteMirror).to receive(:update)
        expect(Gitlab::Git::SshAuth).to receive(:new).with('SSH KEY', 'KNOWN HOSTS')

        GitalyServer::RemoteService.new.update_remote_mirror(call)
      end
    end
  end
end