Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,34 @@ public void CanCloneWithCredentials()
}
}

static Credentials CreateUsernamePasswordCredentials (string user, string pass, bool secure)
{
if (secure)
{
return new SecureUsernamePasswordCredentials
{
Username = user,
Password = Constants.StringToSecureString(pass),
};
}

return new UsernamePasswordCredentials
{
Username = user,
Password = pass,
};
}

[Theory]
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
public void CanCloneFromBBWithCredentials(string url, string user, string pass)
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", false)]
public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
{
var scd = BuildSelfCleaningDirectory();

string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
{
CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
{
Username = user,
Password = pass,
}
CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials (user, pass, secure)
});

using (var repo = new Repository(clonedRepoPath))
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/TestHelpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static string UnwrapUnixTempPath()
}

// To help with creating secure strings to test with.
private static SecureString StringToSecureString(string str)
internal static SecureString StringToSecureString(string str)
{
var chars = str.ToCharArray();

Expand Down