From 6490ff1e57872c7f38de58fec4849fb88ee38b07 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 1 Apr 2022 16:43:20 -0400 Subject: [PATCH 1/2] Remove git protocol from test data --- LibGit2Sharp.Tests/CloneFixture.cs | 10 +++------- LibGit2Sharp.Tests/FetchFixture.cs | 10 ++++------ LibGit2Sharp.Tests/NetworkFixture.cs | 13 +++++-------- LibGit2Sharp.Tests/RepositoryFixture.cs | 2 -- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index 0fefabbf6..295fc383e 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -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(); @@ -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(); @@ -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(); @@ -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; @@ -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(() => Repository.Clone(url, null)); diff --git a/LibGit2Sharp.Tests/FetchFixture.cs b/LibGit2Sharp.Tests/FetchFixture.cs index 01c71ebfe..c0c6f0478 100644 --- a/LibGit2Sharp.Tests/FetchFixture.cs +++ b/LibGit2Sharp.Tests/FetchFixture.cs @@ -4,7 +4,6 @@ using System.Linq; using LibGit2Sharp.Tests.TestHelpers; using Xunit; -using Xunit.Extensions; namespace LibGit2Sharp.Tests { @@ -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(); @@ -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(); @@ -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); @@ -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(); @@ -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); diff --git a/LibGit2Sharp.Tests/NetworkFixture.cs b/LibGit2Sharp.Tests/NetworkFixture.cs index 3ac73a2e8..3a3517432 100644 --- a/LibGit2Sharp.Tests/NetworkFixture.cs +++ b/LibGit2Sharp.Tests/NetworkFixture.cs @@ -3,7 +3,6 @@ using System.Linq; using LibGit2Sharp.Tests.TestHelpers; using Xunit; -using Xunit.Extensions; namespace LibGit2Sharp.Tests { @@ -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"; @@ -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(); @@ -94,9 +91,9 @@ public void CanListRemoteReferenceObjects() Remote remote = repo.Network.Remotes[remoteName]; IEnumerable references = repo.Network.ListReferences(remote).ToList(); - var actualRefs = new List>(); + var actualRefs = new List>(); - foreach(Reference reference in references) + foreach (Reference reference in references) { Assert.NotNull(reference.CanonicalName); @@ -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); @@ -226,7 +223,7 @@ public void PullWithoutMergeBranchThrows() { Commands.Pull(repo, Constants.Signature, new PullOptions()); } - catch(MergeFetchHeadNotFoundException ex) + catch (MergeFetchHeadNotFoundException ex) { didPullThrow = true; thrownException = ex; @@ -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"]); } } diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index 5c551fabd..bf27b6091 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -4,7 +4,6 @@ using System.Linq; using LibGit2Sharp.Tests.TestHelpers; using Xunit; -using Xunit.Extensions; namespace LibGit2Sharp.Tests { @@ -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 references = Repository.ListRemoteReferences(url).ToList(); From 4731263c2e1e83b75eb5b278318cc58d32290b6a Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 1 Apr 2022 16:59:12 -0400 Subject: [PATCH 2/2] Comment out Bitbucket tests --- LibGit2Sharp.Tests/CloneFixture.cs | 46 ++++---- .../desktop/SmartSubtransportFixture.cs | 106 +++++++++--------- 2 files changed, 75 insertions(+), 77 deletions(-) diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index 295fc383e..1b26c1226 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -208,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.WorkingDirectory); - 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))] diff --git a/LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs b/LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs index e72c0d7c1..ff4d0fcd6 100644 --- a/LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs +++ b/LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs @@ -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 { @@ -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 registration = null; - - try - { - // Disable server certificate validation for testing. - // Do *NOT* enable this in production. - ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback; - - registration = GlobalSettings.RegisterSmartSubtransport(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 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 registration = null; + + // try + // { + // // Disable server certificate validation for testing. + // // Do *NOT* enable this in production. + // ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback; + + // registration = GlobalSettings.RegisterSmartSubtransport(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 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()