Skip to content

Commit c088406

Browse files
carlosmnnulltoken
authored andcommitted
Add Clone() test leveraging authentication
1 parent 6eee53c commit c088406

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,31 @@ public void CanCloneWithCredentials()
155155
});
156156

157157

158+
using (var repo = new Repository(clonedRepoPath))
159+
{
160+
string dir = repo.Info.Path;
161+
Assert.True(Path.IsPathRooted(dir));
162+
Assert.True(Directory.Exists(dir));
163+
164+
Assert.NotNull(repo.Info.WorkingDirectory);
165+
Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
166+
Assert.False(repo.Info.IsBare);
167+
}
168+
}
169+
170+
[Theory]
171+
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
172+
public void CanCloneFromBBWithCredentials(string url, string user, string pass)
173+
{
174+
var scd = BuildSelfCleaningDirectory();
175+
176+
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions() {
177+
CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials {
178+
Username = user,
179+
Password = pass,
180+
}
181+
});
182+
158183
using (var repo = new Repository(clonedRepoPath))
159184
{
160185
string dir = repo.Info.Path;

0 commit comments

Comments
 (0)