Skip to content

Commit

Permalink
Refactor Constants.PrivateRepoCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Jun 19, 2014
1 parent 4bc4857 commit 8cc996e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void CanCloneWithCredentials()
string clonedRepoPath = Repository.Clone(Constants.PrivateRepoUrl, scd.DirectoryPath,
new CloneOptions()
{
CredentialsProvider = (_url, _user, _cred) => Constants.PrivateRepoCredentials
CredentialsProvider = Constants.PrivateRepoCredentials
});


Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
// Perform the actual fetch
repo.Network.Fetch(remote, new FetchOptions
{
CredentialsProvider = (_url, _user, _credtype) => Constants.PrivateRepoCredentials
CredentialsProvider = Constants.PrivateRepoCredentials
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/NetworkFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void CanListRemoteReferencesWithCredentials()
{
Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);

var references = repo.Network.ListReferences(remote, (_url, _user, _credtype) => Constants.PrivateRepoCredentials);
var references = repo.Network.ListReferences(remote, Constants.PrivateRepoCredentials);

foreach (var directReference in references)
{
Expand Down
13 changes: 9 additions & 4 deletions LibGit2Sharp.Tests/TestHelpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ public static class Constants

// Populate these to turn on live credential tests: set the
// PrivateRepoUrl to the URL of a repository that requires
// authentication. Set PrivateRepoCredentials to an instance of
// authentication. Define PrivateRepoCredentials to return an instance of
// UsernamePasswordCredentials (for HTTP Basic authentication) or
// DefaultCredentials (for NTLM/Negotiate authentication).
//
// For example:
// public const string PrivateRepoUrl = "https://github.com/username/PrivateRepo";
// public static readonly Credentials PrivateRepoCredentials = new UsernamePasswordCredentials { Username = "username", Password = "swordfish" };
// ... return new UsernamePasswordCredentials { Username = "username", Password = "swordfish" };
//
// Or:
// public const string PrivateRepoUrl = "https://tfs.contoso.com/tfs/DefaultCollection/project/_git/project";
// public static readonly Credentials PrivateRepoCredentials = new DefaultCredentials();
// ... return new DefaultCredentials();

public const string PrivateRepoUrl = "";
public static readonly Credentials PrivateRepoCredentials;

public static Credentials PrivateRepoCredentials(string url, string usernameFromUrl,
SupportedCredentialTypes types)
{
return null;
}
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
/// <summary>
/// Delegate definition for the credentials retrieval callback
/// </summary>
/// <param name="usernameFromUrl">Username which was extracted form the url, if any</param>
/// <param name="url">The url</param>
/// <param name="usernameFromUrl">Username which was extracted from the url, if any</param>
/// <param name="types">Credential types which the server accepts</param>
public delegate Credentials CredentialsHandler(string url, string usernameFromUrl, SupportedCredentialTypes types);

Expand Down

0 comments on commit 8cc996e

Please sign in to comment.