Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #889 from libgit2/cmn/remote-test-ssh
Use the local ssh for `check_connection` and stop hiding online `skip`s
- Loading branch information
Showing
6 changed files
with
212 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,71 @@ | ||
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) | ||
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 | ||
assert_instance_of Rugged::Repository, repo | ||
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 | ||
}) | ||
def test_clone_over_ssh_with_credentials | ||
skip unless Rugged.features.include?(:ssh) && ssh_creds? | ||
|
||
assert_instance_of Rugged::Repository, repo | ||
end | ||
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 | ||
}) | ||
def test_clone_over_ssh_with_credentials_from_agent | ||
skip unless Rugged.features.include?(:ssh) && ssh_creds? | ||
|
||
assert_instance_of Rugged::Repository, repo | ||
end | ||
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 | ||
} | ||
}) | ||
def test_clone_over_ssh_with_credentials_callback | ||
skip unless Rugged.features.include?(:ssh) && ssh_creds? | ||
|
||
assert_instance_of Rugged::Repository, repo | ||
end | ||
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 | ||
def test_clone_callback_args_with_username | ||
skip unless Rugged.features.include?(:ssh) && ssh_creds? | ||
|
||
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 | ||
Dir.mktmpdir do |dir| | ||
url, username, allowed_types = nil, nil, nil | ||
|
||
assert_equal "git@github.com:libgit2/TestGitRepository", url | ||
assert_equal "git", username | ||
assert_equal [:ssh_key].sort, allowed_types.sort | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.