diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2018-08-02 11:55:57 +1000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2018-08-02 15:07:17 +1000 |
commit | 4a03bd220d36b09aa1b38840b7304f182d623f59 (patch) | |
tree | 8fa2701ff56f8900b2f972600021dd58a31e2f4e | |
parent | 1e96cc63a931c2665e1cacfd53c42e25c96c3b65 (diff) | |
parent | c6577e0d75f51b017f2f332838b97c3ca5b497c0 (diff) | |
download | gitlab-shell-4a03bd220d36b09aa1b38840b7304f182d623f59.tar.gz |
Merge remote-tracking branch 'origin/master' into ash.mckenzie/srp-refactor
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | lib/action/api_2fa_recovery.rb | 2 | ||||
-rw-r--r-- | lib/action/git_lfs_authenticate.rb | 2 | ||||
-rw-r--r-- | lib/action/gitaly.rb | 11 | ||||
-rw-r--r-- | spec/action/api_2fa_recovery.rb_spec.rb | 2 | ||||
-rw-r--r-- | spec/action/git_lfs_authenticate_spec.rb | 4 | ||||
-rw-r--r-- | spec/action/gitaly_spec.rb | 6 | ||||
-rw-r--r-- | spec/gitlab_access_spec.rb | 13 | ||||
-rw-r--r-- | spec/gitlab_shell_spec.rb | 2 |
10 files changed, 34 insertions, 13 deletions
@@ -1,3 +1,6 @@ +v8.1.0 + - Support Git v2 protocol (!217) + v8.0.0 - SSH certificate support (!207) @@ -1 +1 @@ -8.0.0 +8.1.0 diff --git a/lib/action/api_2fa_recovery.rb b/lib/action/api_2fa_recovery.rb index ad8130f..06f8057 100644 --- a/lib/action/api_2fa_recovery.rb +++ b/lib/action/api_2fa_recovery.rb @@ -34,7 +34,7 @@ module Action return end - resp = api.two_factor_recovery_codes(self) + resp = api.two_factor_recovery_codes(actor) if resp['success'] codes = resp['recovery_codes'].join("\n") $logger.info('API 2FA recovery success', user: actor.log_username) diff --git a/lib/action/git_lfs_authenticate.rb b/lib/action/git_lfs_authenticate.rb index d2e6d76..8c5294d 100644 --- a/lib/action/git_lfs_authenticate.rb +++ b/lib/action/git_lfs_authenticate.rb @@ -11,7 +11,7 @@ module Action def execute(_, _) GitlabMetrics.measure('lfs-authenticate') do $logger.info('Processing LFS authentication', user: actor.log_username) - lfs_access = api.lfs_authenticate(self, repo_name) + lfs_access = api.lfs_authenticate(actor, repo_name) return unless lfs_access puts lfs_access.authentication_payload diff --git a/lib/action/gitaly.rb b/lib/action/gitaly.rb index 569a1b7..b95ff17 100644 --- a/lib/action/gitaly.rb +++ b/lib/action/gitaly.rb @@ -11,10 +11,11 @@ module Action 'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack') }.freeze - def initialize(actor, gl_repository, gl_username, repository_path, gitaly) + def initialize(actor, gl_repository, gl_username, git_protocol, repository_path, gitaly) @actor = actor @gl_repository = gl_repository @gl_username = gl_username + @git_protocol = git_protocol @repository_path = repository_path @gitaly = gitaly end @@ -23,6 +24,7 @@ module Action new(actor, json['gl_repository'], json['gl_username'], + json['git_protocol'], json['repository_path'], json['gitaly']) end @@ -39,6 +41,10 @@ module Action attr_reader :actor, :gl_repository, :gl_username, :repository_path, :gitaly + def git_protocol + @git_protocol || ENV['GIT_PROTOCOL'] # TODO: tidy this up + end + def process(command, args) executable = command args = [repository_path] @@ -91,7 +97,8 @@ module Action 'repository' => gitaly['repository'], 'gl_repository' => gl_repository, 'gl_id' => actor.identifier, - 'gl_username' => gl_username + 'gl_username' => gl_username, + 'git_protocol' => git_protocol } end diff --git a/spec/action/api_2fa_recovery.rb_spec.rb b/spec/action/api_2fa_recovery.rb_spec.rb index bfdadd6..70091e9 100644 --- a/spec/action/api_2fa_recovery.rb_spec.rb +++ b/spec/action/api_2fa_recovery.rb_spec.rb @@ -46,7 +46,7 @@ describe Action::API2FARecovery do before do expect(subject).to receive(:continue?).and_return(true) - expect(api).to receive(:two_factor_recovery_codes).with(subject).and_return(response) + expect(api).to receive(:two_factor_recovery_codes).with(actor).and_return(response) end context 'with a unsuccessful response' do diff --git a/spec/action/git_lfs_authenticate_spec.rb b/spec/action/git_lfs_authenticate_spec.rb index 3c84d0c..07e844f 100644 --- a/spec/action/git_lfs_authenticate_spec.rb +++ b/spec/action/git_lfs_authenticate_spec.rb @@ -21,7 +21,7 @@ describe Action::GitLFSAuthenticate do describe '#execute' do context 'when response from API is not a success' do before do - expect(api).to receive(:lfs_authenticate).with(subject, repo_name).and_return(nil) + expect(api).to receive(:lfs_authenticate).with(actor, repo_name).and_return(nil) end it 'returns nil' do @@ -36,7 +36,7 @@ describe Action::GitLFSAuthenticate do let(:gitlab_lfs_authentication) { GitlabLfsAuthentication.new(username, lfs_token, repository_http_path) } before do - expect(api).to receive(:lfs_authenticate).with(subject, repo_name).and_return(gitlab_lfs_authentication) + expect(api).to receive(:lfs_authenticate).with(actor, repo_name).and_return(gitlab_lfs_authentication) end it 'puts payload to stdout' do diff --git a/spec/action/gitaly_spec.rb b/spec/action/gitaly_spec.rb index 61e4e4b..a5f6f0b 100644 --- a/spec/action/gitaly_spec.rb +++ b/spec/action/gitaly_spec.rb @@ -10,6 +10,7 @@ describe Action::Gitaly do let(:key) { Actor::Key.new(key_id) } let(:gl_repository) { 'project-1' } let(:gl_username) { 'testuser' } + let(:git_protocol) { 'version=2' } let(:tmp_repos_path) { File.join(ROOT_PATH, 'tmp', 'repositories') } let(:repo_name) { 'gitlab-ci.git' } let(:repository_path) { File.join(tmp_repos_path, repo_name) } @@ -36,7 +37,7 @@ describe Action::Gitaly do end subject do - described_class.new(key, gl_repository, gl_username, repository_path, gitaly) + described_class.new(key, gl_repository, gl_username, git_protocol, repository_path, gitaly) end describe '#execute' do @@ -66,7 +67,8 @@ describe Action::Gitaly do 'repository' => gitaly['repository'], 'gl_repository' => gl_repository, 'gl_id' => key_str, - 'gl_username' => gl_username + 'gl_username' => gl_username, + 'git_protocol' => git_protocol } end diff --git a/spec/gitlab_access_spec.rb b/spec/gitlab_access_spec.rb index e529a66..73ebf2e 100644 --- a/spec/gitlab_access_spec.rb +++ b/spec/gitlab_access_spec.rb @@ -7,7 +7,16 @@ describe GitlabAccess do let(:repo_path) { File.join(repository_path, repo_name) + ".git" } let(:api) do double(GitlabNet).tap do |api| - allow(api).to receive(:check_access).and_return(Action::Gitaly.new('key-1', 'project-1', 'testuser', '/home/git/repositories', nil)) + allow(api).to receive(:check_access).and_return( + Action::Gitaly.new( + 'key-1', + 'project-1', + 'testuser', + 'version=2', + '/home/git/repositories', + nil + ) + ) end end subject do @@ -23,7 +32,6 @@ describe GitlabAccess do describe "#exec" do context "access is granted" do - it "returns true" do expect(subject.exec).to be_truthy end @@ -40,7 +48,6 @@ describe GitlabAccess do end context "API connection fails" do - before do allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError) end diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index 201bc62..c46da5d 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -20,6 +20,7 @@ describe GitlabShell do let(:repo_path) { File.join(tmp_repos_path, repo_name) } let(:gl_repository) { 'project-1' } let(:gl_username) { 'testuser' } + let(:git_protocol) { 'version=2' } let(:api) { double(GitlabNet) } let(:config) { double(GitlabConfig) } @@ -28,6 +29,7 @@ describe GitlabShell do actor, gl_repository, gl_username, + git_protocol, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' } , 'address' => 'unix:gitaly.socket' }) } |