Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2015-06-24 11:36:11 +0300
committerMarius Ungureanu <marius.ungureanu@xamarin.com>2015-06-24 11:43:16 +0300
commit43565ce6a362757c26a2e00a3136307850d918fb (patch)
treeee2264265c8f411318edbf0ff5172b4d425805f7
parent7eb8fd8d75f9d60c7c20a461984c7fb467a85e75 (diff)
Enforce testing of secure password credentialstherzok-secure-string
Fixes #1114
-rw-r--r--LibGit2Sharp.Tests/CloneFixture.cs29
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/Constants.cs2
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();