Skip to content

Commit

Permalink
10-clone.t: Added tests for bad credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesg committed Apr 26, 2014
1 parent 760ab4e commit 9828b10
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions t/10-clone.t
Expand Up @@ -154,6 +154,38 @@ rmtree abs_path('t/test_repo_remote_name');
my $remote_path = File::Spec -> rel2abs('t/test_repo');
my $remote_url = "ssh://$ENV{USER}\@localhost$remote_path";
$path = File::Spec -> rel2abs('t/test_repo_ssh');

# Die'ing inside the callback
ok (!eval { $repo = Git::Raw::Repository -> clone($remote_url, $path, {
'callbacks' => {
'credentials' => sub { die "Shouldn't break!" }
}
});
});
rmtree abs_path('t/test_repo_ssh');

# Returning undef inside the callback
ok (!eval { $repo = Git::Raw::Repository -> clone($remote_url, $path, {
'callbacks' => {
'credentials' => sub { return undef; }
}
});
});
rmtree abs_path('t/test_repo_ssh');

# Invalid key files
ok (!eval { $repo = Git::Raw::Repository -> clone($remote_url, $path, {
'callbacks' => {
'credentials' => sub {
my ($url, $user) = @_;
return Git::Raw::Cred -> sshkey(
$user, 'invalid', 'invalid');
}
}
});
});
rmtree abs_path('t/test_repo_ssh');

$repo = Git::Raw::Repository -> clone($remote_url, $path, {
'callbacks' => {
'credentials' => sub {
Expand Down

0 comments on commit 9828b10

Please sign in to comment.