mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Merge pull request #1004 from TattsGroup/github-enterprise-testhelper
Add support to run integration tests against GitHub Enterprise
This commit is contained in:
@@ -50,6 +50,16 @@ namespace Octokit.Tests.Integration
|
||||
return new Credentials(githubUsername, githubPassword);
|
||||
});
|
||||
|
||||
static readonly Lazy<Uri> _gitHubEnterpriseUrl = new Lazy<Uri>(() =>
|
||||
{
|
||||
string uri = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBENTERPRISEURL");
|
||||
|
||||
if (uri != null)
|
||||
return new Uri(uri);
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
static Helper()
|
||||
{
|
||||
// Force reading of environment variables.
|
||||
@@ -67,6 +77,8 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
public static Credentials BasicAuthCredentials { get { return _basicAuthCredentials.Value; } }
|
||||
|
||||
public static Uri GitHubEnterpriseUrl { get { return _gitHubEnterpriseUrl.Value; } }
|
||||
|
||||
public static bool IsUsingToken
|
||||
{
|
||||
get
|
||||
@@ -128,7 +140,7 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
public static IGitHubClient GetAuthenticatedClient()
|
||||
{
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||
{
|
||||
Credentials = Credentials
|
||||
};
|
||||
@@ -136,7 +148,7 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
public static IGitHubClient GetBasicAuthClient()
|
||||
{
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||
{
|
||||
Credentials = BasicAuthCredentials
|
||||
};
|
||||
@@ -144,7 +156,7 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
public static GitHubClient GetAuthenticatedApplicationClient()
|
||||
{
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||
{
|
||||
Credentials = ApplicationCredentials
|
||||
};
|
||||
@@ -152,12 +164,12 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
public static IGitHubClient GetAnonymousClient()
|
||||
{
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"));
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl);
|
||||
}
|
||||
|
||||
public static IGitHubClient GetBadCredentialsClient()
|
||||
{
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||
{
|
||||
Credentials = new Credentials(Guid.NewGuid().ToString(), "bad-password")
|
||||
};
|
||||
|
||||
@@ -75,5 +75,7 @@ AskYesNoQuestion "Do you have private repositories associated with your test acc
|
||||
|
||||
VerifyEnvironmentVariable "organization name" "OCTOKIT_GITHUBORGANIZATION" $true
|
||||
|
||||
VerifyEnvironmentVariable "GitHub Enterprise Server URL" "OCTOKIT_GITHUBENTERPRISEURL" $true
|
||||
|
||||
VerifyEnvironmentVariable "application ClientID" "OCTOKIT_CLIENTID" $true
|
||||
VerifyEnvironmentVariable "application Secret" "OCTOKIT_CLIENTSECRET" $true
|
||||
Reference in New Issue
Block a user