8000 Enforce testing of secure password credentials · coding2233/libgit2sharp4unity3d@43565ce · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 43565ce

Browse files
committed
Enforce testing of secure password credentials
Fixes libgit2#1114
1 parent 7eb8fd8 commit 43565ce

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,34 @@ public void CanCloneWithCredentials()
195195
}
196196
}
197197

198+
static Credentials CreateUsernamePasswordCredentials (string user, string pass, bool secure)
199+
{
200+
if (secure)
201+
{
202+
return new SecureUsernamePasswordCredentials
203+
{
204+
Username = user,
205+
Password = Constants.StringToSecureString(pass),
206+
};
207+
}
208+
209+
return new UsernamePasswordCredentials
210+
{
211+
Username = user,
212+
Password = pass,
213+
};
214+
}
215+
198216
[Theory]
199-
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
200-
public void CanCloneFromBBWithCredentials(string url, string user, string pass)
217+
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
218+
[InlineData("https://libgit2@bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3", false)]
219+
public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
201220
{
202221
var scd = BuildSelfCleaningDirectory();
203222

204223
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
205224
{
206-
CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
207-
{
208-
Username = user,
209-
Password = pass,
210-
}
225+
CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials (user, pass, secure)
211226
});
212227

213228
using (var repo = new Repository(clonedRepoPath))

LibGit2Sharp.Tests/TestHelpers/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static string UnwrapUnixTempPath()
9494
}
9595

9696
// To help with creating secure strings to test with.
97-
private static SecureString StringToSecureString(string str)
97+
internal static SecureString StringToSecureString(string str)
9898
{
9999
var chars = str.ToCharArray();
100100

0 commit comments

Comments
 (0)
0