Commit 4a03bd22 authored by Ash McKenzie's avatar Ash McKenzie

Merge remote-tracking branch 'origin/master' into ash.mckenzie/srp-refactor

parents 1e96cc63 c6577e0d
v8.1.0
- Support Git v2 protocol (!217)
v8.0.0 v8.0.0
- SSH certificate support (!207) - SSH certificate support (!207)
......
...@@ -34,7 +34,7 @@ module Action ...@@ -34,7 +34,7 @@ module Action
return return
end end
resp = api.two_factor_recovery_codes(self) resp = api.two_factor_recovery_codes(actor)
if resp['success'] if resp['success']
codes = resp['recovery_codes'].join("\n") codes = resp['recovery_codes'].join("\n")
$logger.info('API 2FA recovery success', user: actor.log_username) $logger.info('API 2FA recovery success', user: actor.log_username)
......
...@@ -11,7 +11,7 @@ module Action ...@@ -11,7 +11,7 @@ module Action
def execute(_, _) def execute(_, _)
GitlabMetrics.measure('lfs-authenticate') do GitlabMetrics.measure('lfs-authenticate') do
$logger.info('Processing LFS authentication', user: actor.log_username) $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 return unless lfs_access
puts lfs_access.authentication_payload puts lfs_access.authentication_payload
......
...@@ -11,10 +11,11 @@ module Action ...@@ -11,10 +11,11 @@ module Action
'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack') 'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack')
}.freeze }.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 @actor = actor
@gl_repository = gl_repository @gl_repository = gl_repository
@gl_username = gl_username @gl_username = gl_username
@git_protocol = git_protocol
@repository_path = repository_path @repository_path = repository_path
@gitaly = gitaly @gitaly = gitaly
end end
...@@ -23,6 +24,7 @@ module Action ...@@ -23,6 +24,7 @@ module Action
new(actor, new(actor,
json['gl_repository'], json['gl_repository'],
json['gl_username'], json['gl_username'],
json['git_protocol'],
json['repository_path'], json['repository_path'],
json['gitaly']) json['gitaly'])
end end
...@@ -39,6 +41,10 @@ module Action ...@@ -39,6 +41,10 @@ module Action
attr_reader :actor, :gl_repository, :gl_username, :repository_path, :gitaly 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) def process(command, args)
executable = command executable = command
args = [repository_path] args = [repository_path]
...@@ -91,7 +97,8 @@ module Action ...@@ -91,7 +97,8 @@ module Action
'repository' => gitaly['repository'], 'repository' => gitaly['repository'],
'gl_repository' => gl_repository, 'gl_repository' => gl_repository,
'gl_id' => actor.identifier, 'gl_id' => actor.identifier,
'gl_username' => gl_username 'gl_username' => gl_username,
'git_protocol' => git_protocol
} }
end end
......
...@@ -46,7 +46,7 @@ describe Action::API2FARecovery do ...@@ -46,7 +46,7 @@ describe Action::API2FARecovery do
before do before do
expect(subject).to receive(:continue?).and_return(true) 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 end
context 'with a unsuccessful response' do context 'with a unsuccessful response' do
......
...@@ -21,7 +21,7 @@ describe Action::GitLFSAuthenticate do ...@@ -21,7 +21,7 @@ describe Action::GitLFSAuthenticate do
describe '#execute' do describe '#execute' do
context 'when response from API is not a success' do context 'when response from API is not a success' do
before 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 end
it 'returns nil' do it 'returns nil' do
...@@ -36,7 +36,7 @@ describe Action::GitLFSAuthenticate do ...@@ -36,7 +36,7 @@ describe Action::GitLFSAuthenticate do
let(:gitlab_lfs_authentication) { GitlabLfsAuthentication.new(username, lfs_token, repository_http_path) } let(:gitlab_lfs_authentication) { GitlabLfsAuthentication.new(username, lfs_token, repository_http_path) }
before do 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 end
it 'puts payload to stdout' do it 'puts payload to stdout' do
......
...@@ -10,6 +10,7 @@ describe Action::Gitaly do ...@@ -10,6 +10,7 @@ describe Action::Gitaly do
let(:key) { Actor::Key.new(key_id) } let(:key) { Actor::Key.new(key_id) }
let(:gl_repository) { 'project-1' } let(:gl_repository) { 'project-1' }
let(:gl_username) { 'testuser' } let(:gl_username) { 'testuser' }
let(:git_protocol) { 'version=2' }
let(:tmp_repos_path) { File.join(ROOT_PATH, 'tmp', 'repositories') } let(:tmp_repos_path) { File.join(ROOT_PATH, 'tmp', 'repositories') }
let(:repo_name) { 'gitlab-ci.git' } let(:repo_name) { 'gitlab-ci.git' }
let(:repository_path) { File.join(tmp_repos_path, repo_name) } let(:repository_path) { File.join(tmp_repos_path, repo_name) }
...@@ -36,7 +37,7 @@ describe Action::Gitaly do ...@@ -36,7 +37,7 @@ describe Action::Gitaly do
end end
subject do 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 end
describe '#execute' do describe '#execute' do
...@@ -66,7 +67,8 @@ describe Action::Gitaly do ...@@ -66,7 +67,8 @@ describe Action::Gitaly do
'repository' => gitaly['repository'], 'repository' => gitaly['repository'],
'gl_repository' => gl_repository, 'gl_repository' => gl_repository,
'gl_id' => key_str, 'gl_id' => key_str,
'gl_username' => gl_username 'gl_username' => gl_username,
'git_protocol' => git_protocol
} }
end end
......
...@@ -7,7 +7,16 @@ describe GitlabAccess do ...@@ -7,7 +7,16 @@ describe GitlabAccess do
let(:repo_path) { File.join(repository_path, repo_name) + ".git" } let(:repo_path) { File.join(repository_path, repo_name) + ".git" }
let(:api) do let(:api) do
double(GitlabNet).tap do |api| 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
end end
subject do subject do
...@@ -23,7 +32,6 @@ describe GitlabAccess do ...@@ -23,7 +32,6 @@ describe GitlabAccess do
describe "#exec" do describe "#exec" do
context "access is granted" do context "access is granted" do
it "returns true" do it "returns true" do
expect(subject.exec).to be_truthy expect(subject.exec).to be_truthy
end end
...@@ -40,7 +48,6 @@ describe GitlabAccess do ...@@ -40,7 +48,6 @@ describe GitlabAccess do
end end
context "API connection fails" do context "API connection fails" do
before do before do
allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError) allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError)
end end
......
...@@ -20,6 +20,7 @@ describe GitlabShell do ...@@ -20,6 +20,7 @@ describe GitlabShell do
let(:repo_path) { File.join(tmp_repos_path, repo_name) } let(:repo_path) { File.join(tmp_repos_path, repo_name) }
let(:gl_repository) { 'project-1' } let(:gl_repository) { 'project-1' }
let(:gl_username) { 'testuser' } let(:gl_username) { 'testuser' }
let(:git_protocol) { 'version=2' }
let(:api) { double(GitlabNet) } let(:api) { double(GitlabNet) }
let(:config) { double(GitlabConfig) } let(:config) { double(GitlabConfig) }
...@@ -28,6 +29,7 @@ describe GitlabShell do ...@@ -28,6 +29,7 @@ describe GitlabShell do
actor, actor,
gl_repository, gl_repository,
gl_username, gl_username,
git_protocol,
repo_path, repo_path,
{ 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' } , 'address' => 'unix:gitaly.socket' }) { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' } , 'address' => 'unix:gitaly.socket' })
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment