Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Libgit2sharp
提交
4731263c
L
Libgit2sharp
项目概览
jobily
/
Libgit2sharp
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
Libgit2sharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4731263c
编写于
4月 01, 2022
作者:
B
Brandon Ording
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Comment out Bitbucket tests
上级
6490ff1e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
77 deletion
+75
-77
LibGit2Sharp.Tests/CloneFixture.cs
LibGit2Sharp.Tests/CloneFixture.cs
+23
-23
LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs
LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs
+52
-54
未找到文件。
LibGit2Sharp.Tests/CloneFixture.cs
浏览文件 @
4731263c
...
...
@@ -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
))]
...
...
LibGit2Sharp.Tests/desktop/SmartSubtransportFixture.cs
浏览文件 @
4731263c
...
...
@@ -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
<
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
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录