10000 Remove git protocol from test data by bording · Pull Request #1956 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Remove git protocol from test data #1956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2022
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
56 changes: 26 additions & 30 deletions LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class CloneFixture : BaseFixture
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository")]
//[InlineData("git@github.com:libgit2/TestGitRepository")]
public void CanClone(string url)
{
var scd = BuildSelfCleaningDirectory();
Expand Down Expand Up @@ -102,8 +100,6 @@ public void CanCloneALocalRepositoryFromANewlyCreatedTemporaryPath()
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository")]
//[InlineData("git@github.com:libgit2/TestGitRepository")]
public void CanCloneBarely(string url)
{
var scd = BuildSelfCleaningDirectory();
Expand All @@ -126,7 +122,7 @@ public void CanCloneBarely(string url)
}

[Theory]
[InlineData("git://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
public void WontCheckoutIfAskedNotTo(string url)
{
var scd = BuildSelfCleaningDirectory();
Expand All @@ -143,7 +139,7 @@ public void WontCheckoutIfAskedNotTo(string url)
}

[Theory]
[InlineData("git://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
public void CallsProgressCallbacks(string url)
{
bool transferWasCalled = false;
Expand Down Expand Up @@ -212,29 +208,29 @@ static Credentials CreateUsernamePasswordCredentials(string user, string pass, b
};
}

[Theory]
[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) => CreateUsernamePasswordCredentials(user, pass, secure)
});

using (var repo = new Repository(clonedRepoPath))
{
string dir = repo.Info.Path;
Assert.True(Path.IsPathRooted(dir));
Assert.True(Directory.Exists(dir));

Assert.NotNull(repo.Info.WorkingDirec 8000 tory);
Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
Assert.False(repo.Info.IsBare);
}
}
//[Theory]
//[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) => CreateUsernamePasswordCredentials(user, pass, secure)
// });

// using (var repo = new Repository(clonedRepoPath))
// {
// string dir = repo.Info.Path;
// Assert.True(Path.IsPathRooted(dir));
// Assert.True(Directory.Exists(dir));

// Assert.NotNull(repo.Info.WorkingDirectory);
// Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
// Assert.False(repo.Info.IsBare);
// }
//}

[SkippableTheory]
[InlineData("https://github.com/libgit2/TestGitRepository.git", "github.com", typeof(CertificateX509))]
Expand Down Expand Up @@ -301,7 +297,7 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
}

[Theory]
[InlineData("git://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
public void CloningWithoutWorkdirPathThrows(string url)
{
Assert.Throws<ArgumentNullException>(() => Repository.Clone(url, null));
Expand Down
10 changes: 4 additions & 6 deletions LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand All @@ -15,7 +14,6 @@ public class FetchFixture : BaseFixture
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanFetchIntoAnEmptyRepository(string url)
{
string path = InitNewRepository();
Expand Down Expand Up @@ -74,7 +72,6 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanFetchAllTagsIntoAnEmptyRepository(string url)
{
string path = InitNewRepository();
Expand All @@ -101,7 +98,8 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
}

// Perform the actual fetch
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions
{
TagFetchMode = TagFetchMode.All,
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler
}, null);
Expand All @@ -117,7 +115,6 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository", "test-branch", "master")]
[InlineData("https://github.com/libgit2/TestGitRepository", "master", "master")]
[InlineData("git://github.com/libgit2/TestGitRepository.git", "master", "first-merge")]
public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string localBranchName, string remoteBranchName)
{
string path = InitNewRepository();
Expand Down Expand Up @@ -147,7 +144,8 @@ public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string local
}

// Perform the actual fetch
Commands.Fetch(repo, remoteName, new string[] { refSpec }, new FetchOptions {
Commands.Fetch(repo, remoteName, new string[] { refSpec }, new FetchOptions
{
TagFetchMode = TagFetchMode.None,
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler
}, null);
Expand Down
13 changes: 5 additions & 8 deletions LibGit2Sharp.Tests/NetworkFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand All @@ -12,7 +11,6 @@ public class NetworkFixture : BaseFixture
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanListRemoteReferences(string url)
{
string remoteName = "testRemote";
Expand Down Expand Up @@ -49,7 +47,6 @@ public void CanListRemoteReferences(string url)
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanListRemoteReferencesFromUrl(string url)
{
string repoPath = InitNewRepository();
Expand Down Expand Up @@ -94,9 +91,9 @@ public void CanListRemoteReferenceObjects()
Remote remote = repo.Network.Remotes[remoteName];
IEnumerable<Reference> references = repo.Network.ListReferences(remote).ToList();

var actualRefs = new List<Tuple<string,string>>();
var actualRefs = new List<Tuple<string, string>>();

foreach(Reference reference in references)
foreach (Reference reference in references)
{
Assert.NotNull(reference.CanonicalName);

Expand Down Expand Up @@ -166,7 +163,7 @@ public void CanPull(FastForwardStrategy fastForwardStrategy)

MergeResult mergeResult = Commands.Pull(repo, Constants.Signature, pullOptions);

if(fastForwardStrategy == FastForwardStrategy.Default || fastForwardStrategy == FastForwardStrategy.FastForwardOnly)
if (fastForwardStrategy == FastForwardStrategy.Default || fastForwardStrategy == FastForwardStrategy.FastForwardOnly)
{
Assert.Equal(MergeStatus.FastForward, mergeResult.Status);
Assert.Equal(mergeResult.Commit, repo.Branches["refs/remotes/origin/master"].Tip);
Expand Down Expand Up @@ -226,7 +223,7 @@ public void PullWithoutMergeBranchThrows()
{
Commands.Pull(repo, Constants.Signature, new PullOptions());
}
catch(MergeFetchHeadNotFoundException ex)
catch (MergeFetchHeadNotFoundException ex)
{
didPullThrow = true;
thrownException = ex;
Expand Down Expand Up @@ -293,7 +290,7 @@ public void CanPruneRefs()
Assert.NotNull(repo.Refs["refs/remotes/pruner/master"]);

// but we do when asked by the user
Commands.Fetch(repo, "pruner", new string[0], new FetchOptions { Prune = true}, null);
Commands.Fetch(repo, "pruner", new string[0], new FetchOptions { Prune = true }, null);
Assert.Null(repo.Refs["refs/remotes/pruner/master"]);
}
}
Expand Down
2 changes: 0 additions & 2 deletions LibGit2Sharp.Tests/RepositoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -709,7 +708,6 @@ public void CanListRemoteReferencesWithCredentials()
[Theory]
[InlineData("http://github.com/libgit2/TestGitRepository")]
[InlineData("https://github.com/libgit2/TestGitRepository")]
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanListRemoteReferences(string url)
{
IEnumerable<Reference> references = Repository.ListRemoteReferences(url).ToList();
Expand Down
106 changes: 52 additions & 54 deletions LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Net;
using System.Net.Security;
using LibGit2Sharp.Tests.TestHelpers;
using LibGit2Sharp.Core;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -79,58 +77,58 @@ public void CustomSmartSubtransportTest(string scheme, string url)
}
}

[Theory]
[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
public void CanUseCredentials(string scheme, string url, string user, string pass)
{
string remoteName = "testRemote";

var scd = BuildSelfCleaningDirectory();
Repository.Init(scd.RootedDirectoryPath);

SmartSubtransportRegistration<MockSmartSubtransport> registration = null;

try
{
// Disable server certificate validation for testing.
// Do *NOT* enable this in production.
ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback;

registration = GlobalSettings.RegisterSmartSubtransport<MockSmartSubtransport>(scheme);
Assert.NotNull(registration);

using (var repo = new Repository(scd.DirectoryPath))
{
repo.Network.Remotes.Add(remoteName, url);

// Set up structures for the expected results
// and verifying the RemoteUpdateTips callback.
TestRemoteInfo expectedResults = TestRemoteInfo.TestRemoteInstance;
ExpectedFetchState expectedFetchState = new ExpectedFetchState(remoteName);

// Add expected branch objects
foreach (KeyValuePair<string, ObjectId> kvp in expectedResults.BranchTips)
{
expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
}

// Perform the actual fetch
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler, TagFetchMode = TagFetchMode.Auto,
CredentialsProvider = (_user, _valid, _hostname) => new UsernamePasswordCredentials() { Username = user, Password = pass },
}, null);

// Verify the expected
expectedFetchState.CheckUpdatedReferences(repo);
}
}
finally
{
GlobalSettings.UnregisterSmartSubtransport(registration);

ServicePointManager.ServerCertificateValidationCallback -= certificateValidationCallback;
}
}
//[Theory]
//[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
//public void CanUseCredentials(string scheme, string url, string user, string pass)
//{
// string remoteName = "testRemote";

// var scd = BuildSelfCleaningDirectory();
// Repository.Init(scd.RootedDirectoryPath);

// SmartSubtransportRegistration<MockSmartSubtransport> registration = null;

// try
// {
// // Disable server certificate validation for testing.
// // Do *NOT* enable this in production.
// ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback;

// registration = GlobalSettings.RegisterSmartSubtransport<MockSmartSubtransport>(scheme);
// Assert.NotNull(registration);

// using (var repo = new Repository(scd.DirectoryPath))
// {
// repo.Network.Remotes.Add(remoteName, url);

// // Set up structures for the expected results
// // and verifying the RemoteUpdateTips callback.
// TestRemoteInfo expectedResults = TestRemoteInfo.TestRemoteInstance;
// ExpectedFetchState expectedFetchState = new ExpectedFetchState(remoteName);

// // Add expected branch objects
// foreach (KeyValuePair<string, ObjectId> kvp in expectedResults.BranchTips)
// {
// expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
// }

// // Perform the actual fetch
// Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
// OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler, TagFetchMode = TagFetchMode.Auto,
// CredentialsProvider = (_user, _valid, _hostname) => new UsernamePasswordCredentials() { Username = user, Password = pass },
// }, null);

// // Verify the expected
// expectedFetchState.CheckUpdatedReferences(repo);
// }
// }
// finally
// {
// GlobalSettings.UnregisterSmartSubtransport(registration);

// ServicePointManager.ServerCertificateValidationCallback -= certificateValidationCallback;
// }
//}

[Fact]
public void CannotReregisterScheme()
Expand Down
0