diff options
-rw-r--r-- | LibGit2Sharp.Tests/CloneFixture.cs | 29 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/TestHelpers/Constants.cs | 2 |
2 files changed, 23 insertions, 8 deletions
diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index 7fb05048..46ef2ef4 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -195,19 +195,34 @@ namespace LibGit2Sharp.Tests } } + 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)) diff --git a/LibGit2Sharp.Tests/TestHelpers/Constants.cs b/LibGit2Sharp.Tests/TestHelpers/Constants.cs index 51d9f697..334b61dc 100644 --- a/LibGit2Sharp.Tests/TestHelpers/Constants.cs +++ b/LibGit2Sharp.Tests/TestHelpers/Constants.cs @@ -94,7 +94,7 @@ namespace LibGit2Sharp.Tests.TestHelpers } // 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(); |