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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
require 'test_helper'
class OnlineCloneTest < Rugged::OnlineTestCase
if git_creds?
def test_clone_over_git
Dir.mktmpdir do |dir|
repo = Rugged::Repository.clone_at(ENV['GITTEST_REMOTE_GIT_URL'], dir)
assert_instance_of Rugged::Repository, repo
end
end
end
if Rugged.features.include?(:ssh) && ssh_creds?
def test_clone_over_ssh_with_credentials
Dir.mktmpdir do |dir|
repo = Rugged::Repository.clone_at(ENV['GITTEST_REMOTE_SSH_URL'], dir, {
credentials: ssh_key_credential
})
assert_instance_of Rugged::Repository, repo
end
end
def test_clone_over_ssh_with_credentials_from_agent
Dir.mktmpdir do |dir|
repo = Rugged::Repository.clone_at(ENV['GITTEST_REMOTE_SSH_URL'], dir, {
credentials: ssh_key_credential_from_agent
})
assert_instance_of Rugged::Repository, repo
end
end
def test_clone_over_ssh_with_credentials_callback
Dir.mktmpdir do |dir|
repo = Rugged::Repository.clone_at(ENV['GITTEST_REMOTE_SSH_URL'], dir, {
credentials: lambda { |url, username, allowed_types|
return ssh_key_credential
}
})
assert_instance_of Rugged::Repository, repo
end
end
def test_clone_callback_args_with_username
Dir.mktmpdir do |dir|
url, username, allowed_types = nil, nil, nil
assert_raises Rugged::SshError do
Rugged::Repository.clone_at("git@github.com:libgit2/TestGitRepository", dir, {
credentials: lambda { |*args|
url, username, allowed_types = *args
return nil
}
})
end
assert_equal "git@github.com:libgit2/TestGitRepository", url
assert_equal "git", username
assert_equal [:ssh_key].sort, allowed_types.sort
end
end
end
end
|