Skip to content

Commit 0ff4838

Browse files
authored
Merge pull request #1956 from libgit2/clean-up-test-data
Remove git protocol from test data
2 parents 1e6da83 + 4731263 commit 0ff4838

File tree

5 files changed

+87
-100
lines changed

5 files changed

+87
-100
lines changed

Diff for: LibGit2Sharp.Tests/CloneFixture.cs

+26-30
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public class CloneFixture : BaseFixture
1313
[Theory]
1414
[InlineData("http://github.com/libgit2/TestGitRepository")]
1515
[InlineData("https://github.com/libgit2/TestGitRepository")]
16-
[InlineData("git://github.com/libgit2/TestGitRepository")]
17-
//[InlineData("[email protected]:libgit2/TestGitRepository")]
1816
public void CanClone(string url)
1917
{
2018
var scd = BuildSelfCleaningDirectory();
@@ -102,8 +100,6 @@ public void CanCloneALocalRepositoryFromANewlyCreatedTemporaryPath()
102100
[Theory]
103101
[InlineData("http://github.com/libgit2/TestGitRepository")]
104102
[InlineData("https://github.com/libgit2/TestGitRepository")]
105-
[InlineData("git://github.com/libgit2/TestGitRepository")]
106-
//[InlineData("[email protected]:libgit2/TestGitRepository")]
107103
public void CanCloneBarely(string url)
108104
{
109105
var scd = BuildSelfCleaningDirectory();
@@ -126,7 +122,7 @@ public void CanCloneBarely(string url)
126122
}
127123

128124
[Theory]
129-
[InlineData("git://github.com/libgit2/TestGitRepository")]
125+
[InlineData("https://github.com/libgit2/TestGitRepository")]
130126
public void WontCheckoutIfAskedNotTo(string url)
131127
{
132128
var scd = BuildSelfCleaningDirectory();
@@ -143,7 +139,7 @@ public void WontCheckoutIfAskedNotTo(string url)
143139
}
144140

145141
[Theory]
146-
[InlineData("git://github.com/libgit2/TestGitRepository")]
142+
[InlineData("https://github.com/libgit2/TestGitRepository")]
147143
public void CallsProgressCallbacks(string url)
148144
{
149145
bool transferWasCalled = false;
@@ -212,29 +208,29 @@ static Credentials CreateUsernamePasswordCredentials(string user, string pass, b
212208
};
213209
}
214210

215-
[Theory]
216-
[InlineData("https://[email protected]/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
217-
[InlineData("https://[email protected]/libgit2/testgitrepository.git", "libgit3", "libgit3", false)]
218-
public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
219-
{
220-
var scd = BuildSelfCleaningDirectory();
221-
222-
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
223-
{
224-
CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials(user, pass, secure)
225-
});
226-
227-
using (var repo = new Repository(clonedRepoPath))
228-
{
229-
string dir = repo.Info.Path;
230-
Assert.True(Path.IsPathRooted(dir));
231-
Assert.True(Directory.Exists(dir));
232-
233-
Assert.NotNull(repo.Info.WorkingDirectory);
234-
Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
235-
Assert.False(repo.Info.IsBare);
236-
}
237-
}
211+
//[Theory]
212+
//[InlineData("https://[email protected]/libgit2/testgitrepository.git", "libgit3", "libgit3", true)]
213+
//[InlineData("https://[email protected]/libgit2/testgitrepository.git", "libgit3", "libgit3", false)]
214+
//public void CanCloneFromBBWithCredentials(string url, string user, string pass, bool secure)
215+
//{
216+
// var scd = BuildSelfCleaningDirectory();
217+
218+
// string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
219+
// {
220+
// CredentialsProvider = (_url, _user, _cred) => CreateUsernamePasswordCredentials(user, pass, secure)
221+
// });
222+
223+
// using (var repo = new Repository(clonedRepoPath))
224+
// {
225+
// string dir = repo.Info.Path;
226+
// Assert.True(Path.IsPathRooted(dir));
227+
// Assert.True(Directory.Exists(dir));
228+
229+
// Assert.NotNull(repo.Info.WorkingDirectory);
230+
// Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
231+
// Assert.False(repo.Info.IsBare);
232+
// }
233+
//}
238234

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

303299
[Theory]
304-
[InlineData("git://github.com/libgit2/TestGitRepository")]
300+
[InlineData("https://github.com/libgit2/TestGitRepository")]
305301
public void CloningWithoutWorkdirPathThrows(string url)
306302
{
307303
Assert.Throws<ArgumentNullException>(() => Repository.Clone(url, null));

Diff for: LibGit2Sharp.Tests/FetchFixture.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -15,7 +14,6 @@ public class FetchFixture : BaseFixture
1514
[Theory]
1615
[InlineData("http://github.com/libgit2/TestGitRepository")]
1716
[InlineData("https://github.com/libgit2/TestGitRepository")]
18-
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
1917
public void CanFetchIntoAnEmptyRepository(string url)
2018
{
2119
string path = InitNewRepository();
@@ -74,7 +72,6 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
7472
[Theory]
7573
[InlineData("http://github.com/libgit2/TestGitRepository")]
7674
[InlineData("https://github.com/libgit2/TestGitRepository")]
77-
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
7875
public void CanFetchAllTagsIntoAnEmptyRepository(string url)
7976
{
8077
string path = InitNewRepository();
@@ -101,7 +98,8 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
10198
}
10299

103100
// Perform the actual fetch
104-
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
101+
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions
102+
{
105103
TagFetchMode = TagFetchMode.All,
106104
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler
107105
}, null);
@@ -117,7 +115,6 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
117115
[Theory]
118116
[InlineData("http://github.com/libgit2/TestGitRepository", "test-branch", "master")]
119117
[InlineData("https://github.com/libgit2/TestGitRepository", "master", "master")]
120-
[InlineData("git://github.com/libgit2/TestGitRepository.git", "master", "first-merge")]
121118
public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string localBranchName, string remoteBranchName)
122119
{
123120
string path = InitNewRepository();
@@ -147,7 +144,8 @@ public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string local
147144
}
148145

149146
// Perform the actual fetch
150-
Commands.Fetch(repo, remoteName, new string[] { refSpec }, new FetchOptions {
147+
Commands.Fetch(repo, remoteName, new string[] { refSpec }, new FetchOptions
148+
{
151149
TagFetchMode = TagFetchMode.None,
152150
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler
153151
}, null);

Diff for: LibGit2Sharp.Tests/NetworkFixture.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using LibGit2Sharp.Tests.TestHelpers;
55
using Xunit;
6-
using Xunit.Extensions;
76

87
namespace LibGit2Sharp.Tests
98
{
@@ -12,7 +11,6 @@ public class NetworkFixture : BaseFixture
1211
[Theory]
1312
[InlineData("http://github.com/libgit2/TestGitRepository")]
1413
[InlineData("https://github.com/libgit2/TestGitRepository")]
15-
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
1614
public void CanListRemoteReferences(string url)
1715
{
1816
string remoteName = "testRemote";
@@ -49,7 +47,6 @@ public void CanListRemoteReferences(string url)
4947
[Theory]
5048
[InlineData("http://github.com/libgit2/TestGitRepository")]
5149
[InlineData("https://github.com/libgit2/TestGitRepository")]
52-
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
5350
public void CanListRemoteReferencesFromUrl(string url)
5451
{
5552
string repoPath = InitNewRepository();
@@ -94,9 +91,9 @@ public void CanListRemoteReferenceObjects()
9491
Remote remote = repo.Network.Remotes[remoteName];
9592
IEnumerable<Reference> references = repo.Network.ListReferences(remote).ToList();
9693

97-
var actualRefs = new List<Tuple<string,string>>();
94+
var actualRefs = new List<Tuple<string, string>>();
9895

99-
foreach(Reference reference in references)
96+
foreach (Reference reference in references)
10097
{
10198
Assert.NotNull(reference.CanonicalName);
10299

@@ -166,7 +163,7 @@ public void CanPull(FastForwardStrategy fastForwardStrategy)
166163

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

169-
if(fastForwardStrategy == FastForwardStrategy.Default || fastForwardStrategy == FastForwardStrategy.FastForwardOnly)
166+
if (fastForwardStrategy == FastForwardStrategy.Default || fastForwardStrategy == FastForwardStrategy.FastForwardOnly)
170167
{
171168
Assert.Equal(MergeStatus.FastForward, mergeResult.Status);
172169
Assert.Equal(mergeResult.Commit, repo.Branches["refs/remotes/origin/master"].Tip);
@@ -226,7 +223,7 @@ public void PullWithoutMergeBranchThrows()
226223
{
227224
Commands.Pull(repo, Constants.Signature, new PullOptions());
228225
}
229-
catch(MergeFetchHeadNotFoundException ex)
226+
catch (MergeFetchHeadNotFoundException ex)
230227
{
231228
didPullThrow = true;
232229
thrownException = ex;
@@ -293,7 +290,7 @@ public void CanPruneRefs()
293290
Assert.NotNull(repo.Refs["refs/remotes/pruner/master"]);
294291

295292
// but we do when asked by the user
296-
Commands.Fetch(repo, "pruner", new string[0], new FetchOptions { Prune = true}, null);
293+
Commands.Fetch(repo, "pruner", new string[0], new FetchOptions { Prune = true }, null);
297294
Assert.Null(repo.Refs["refs/remotes/pruner/master"]);
298295
}
299296
}

Diff for: LibGit2Sharp.Tests/RepositoryFixture.cs

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -709,7 +708,6 @@ public void CanListRemoteReferencesWithCredentials()
709708
[Theory]
710709
[InlineData("http://github.com/libgit2/TestGitRepository")]
711710
[InlineData("https://github.com/libgit2/TestGitRepository")]
712-
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
713711
public void CanListRemoteReferences(string url)
714712
{
715713
IEnumerable<Reference> references = Repository.ListRemoteReferences(url).ToList();

Diff for: LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs

+52-54
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
using System.Net;
55
using System.Net.Security;
66
using LibGit2Sharp.Tests.TestHelpers;
7-
using LibGit2Sharp.Core;
87
using Xunit;
9-
using Xunit.Extensions;
108

119
namespace LibGit2Sharp.Tests
1210
{
@@ -79,58 +77,58 @@ public void CustomSmartSubtransportTest(string scheme, string url)
7977
}
8078
}
8179

82-
[Theory]
83-
[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
84-
public void CanUseCredentials(string scheme, string url, string user, string pass)
85-
{
86-
string remoteName = "testRemote";
87-
88-
var scd = BuildSelfCleaningDirectory();
89-
Repository.Init(scd.RootedDirectoryPath);
90-
91-
SmartSubtransportRegistration<MockSmartSubtransport> registration = null;
92-
93-
try
94-
{
95-
// Disable server certificate validation for testing.
96-
// Do *NOT* enable this in production.
97-
ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback;
98-
99-
registration = GlobalSettings.RegisterSmartSubtransport<MockSmartSubtransport>(scheme);
100-
Assert.NotNull(registration);
101-
102-
using (var repo = new Repository(scd.DirectoryPath))
103-
{
104-
repo.Network.Remotes.Add(remoteName, url);
105-
106-
// Set up structures for the expected results
107-
// and verifying the RemoteUpdateTips callback.
108-
TestRemoteInfo expectedResults = TestRemoteInfo.TestRemoteInstance;
109-
ExpectedFetchState expectedFetchState = new ExpectedFetchState(remoteName);
110-
111-
// Add expected branch objects
112-
foreach (KeyValuePair<string, ObjectId> kvp in expectedResults.BranchTips)
113-
{
114-
expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
115-
}
116-
117-
// Perform the actual fetch
118-
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
119-
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler, TagFetchMode = TagFetchMode.Auto,
120-
CredentialsProvider = (_user, _valid, _hostname) => new UsernamePasswordCredentials() { Username = user, Password = pass },
121-
}, null);
122-
123-
// Verify the expected
124-
expectedFetchState.CheckUpdatedReferences(repo);
125-
}
126-
}
127-
finally
128-
{
129-
GlobalSettings.UnregisterSmartSubtransport(registration);
130-
131-
ServicePointManager.ServerCertificateValidationCallback -= certificateValidationCallback;
132-
}
133-
}
80+
//[Theory]
81+
//[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
82+
//public void CanUseCredentials(string scheme, string url, string user, string pass)
83+
//{
84+
// string remoteName = "testRemote";
85+
86+
// var scd = BuildSelfCleaningDirectory();
87+
// Repository.Init(scd.RootedDirectoryPath);
88+
89+
// SmartSubtransportRegistration<MockSmartSubtransport> registration = null;
90+
91+
// try
92+
// {
93+
// // Disable server certificate validation for testing.
94+
// // Do *NOT* enable this in production.
95+
// ServicePointManager.ServerCertificateValidationCallback = certificateValidationCallback;
96+
97+
// registration = GlobalSettings.RegisterSmartSubtransport<MockSmartSubtransport>(scheme);
98+
// Assert.NotNull(registration);
99+
100+
// using (var repo = new Repository(scd.DirectoryPath))
101+
// {
102+
// repo.Network.Remotes.Add(remoteName, url);
103+
104+
// // Set up structures for the expected results
105+
// // and verifying the RemoteUpdateTips callback.
106+
// TestRemoteInfo expectedResults = TestRemoteInfo.TestRemoteInstance;
107+
// ExpectedFetchState expectedFetchState = new ExpectedFetchState(remoteName);
108+
109+
// // Add expected branch objects
110+
// foreach (KeyValuePair<string, ObjectId> kvp in expectedResults.BranchTips)
111+
// {
112+
// expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
113+
// }
114+
115+
// // Perform the actual fetch
116+
// Commands.Fetch(repo, remoteName, new string[0], new FetchOptions {
117+
// OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler, TagFetchMode = TagFetchMode.Auto,
118+
// CredentialsProvider = (_user, _valid, _hostname) => new UsernamePasswordCredentials() { Username = user, Password = pass },
119+
// }, null);
120+
121+
// // Verify the expected
122+
// expectedFetchState.CheckUpdatedReferences(repo);
123+
// }
124+
// }
125+
// finally
126+
// {
127+
// GlobalSettings.UnregisterSmartSubtransport(registration);
128+
129+
// ServicePointManager.ServerCertificateValidationCallback -= certificateValidationCallback;
130+
// }
131+
//}
134132

135133
[Fact]
136134
public void CannotReregisterScheme()

0 commit comments

Comments
 (0)