-
Notifications
You must be signed in to change notification settings - Fork 279
/
clone_test.rb
71 lines (56 loc) · 2.36 KB
/
clone_test.rb
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
67
68
69
70
71
require 'test_helper'
class OnlineCloneTest < Rugged::OnlineTestCase
def test_clone_over_git
skip unless git_creds?
Dir.mktmpdir do |dir|
repo = Rugged::Repository.clone_at(ENV['GITTEST_REMOTE_GIT_URL'], dir)
assert_instance_of Rugged::Repository, repo
end
end
def test_clone_over_ssh_with_credentials
skip unless Rugged.features.include?(:ssh) && ssh_creds?
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
skip unless Rugged.features.include?(:ssh) && ssh_creds?
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
skip unless Rugged.features.include?(:ssh) && ssh_creds?
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
skip unless Rugged.features.include?(:ssh) && ssh_creds?
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