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:
@@ -48,7 +48,17 @@ namespace Octokit.Tests.Integration
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new Credentials(githubUsername, githubPassword);
|
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()
|
static Helper()
|
||||||
{
|
{
|
||||||
@@ -67,6 +77,8 @@ namespace Octokit.Tests.Integration
|
|||||||
|
|
||||||
public static Credentials BasicAuthCredentials { get { return _basicAuthCredentials.Value; } }
|
public static Credentials BasicAuthCredentials { get { return _basicAuthCredentials.Value; } }
|
||||||
|
|
||||||
|
public static Uri GitHubEnterpriseUrl { get { return _gitHubEnterpriseUrl.Value; } }
|
||||||
|
|
||||||
public static bool IsUsingToken
|
public static bool IsUsingToken
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -128,7 +140,7 @@ namespace Octokit.Tests.Integration
|
|||||||
|
|
||||||
public static IGitHubClient GetAuthenticatedClient()
|
public static IGitHubClient GetAuthenticatedClient()
|
||||||
{
|
{
|
||||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||||
{
|
{
|
||||||
Credentials = Credentials
|
Credentials = Credentials
|
||||||
};
|
};
|
||||||
@@ -136,7 +148,7 @@ namespace Octokit.Tests.Integration
|
|||||||
|
|
||||||
public static IGitHubClient GetBasicAuthClient()
|
public static IGitHubClient GetBasicAuthClient()
|
||||||
{
|
{
|
||||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||||
{
|
{
|
||||||
Credentials = BasicAuthCredentials
|
Credentials = BasicAuthCredentials
|
||||||
};
|
};
|
||||||
@@ -144,7 +156,7 @@ namespace Octokit.Tests.Integration
|
|||||||
|
|
||||||
public static GitHubClient GetAuthenticatedApplicationClient()
|
public static GitHubClient GetAuthenticatedApplicationClient()
|
||||||
{
|
{
|
||||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
|
||||||
{
|
{
|
||||||
Credentials = ApplicationCredentials
|
Credentials = ApplicationCredentials
|
||||||
};
|
};
|
||||||
@@ -152,12 +164,12 @@ namespace Octokit.Tests.Integration
|
|||||||
|
|
||||||
public static IGitHubClient GetAnonymousClient()
|
public static IGitHubClient GetAnonymousClient()
|
||||||
{
|
{
|
||||||
return new GitHubClient(new ProductHeaderValue("OctokitTests"));
|
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IGitHubClient GetBadCredentialsClient()
|
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")
|
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 "organization name" "OCTOKIT_GITHUBORGANIZATION" $true
|
||||||
|
|
||||||
|
VerifyEnvironmentVariable "GitHub Enterprise Server URL" "OCTOKIT_GITHUBENTERPRISEURL" $true
|
||||||
|
|
||||||
VerifyEnvironmentVariable "application ClientID" "OCTOKIT_CLIENTID" $true
|
VerifyEnvironmentVariable "application ClientID" "OCTOKIT_CLIENTID" $true
|
||||||
VerifyEnvironmentVariable "application Secret" "OCTOKIT_CLIENTSECRET" $true
|
VerifyEnvironmentVariable "application Secret" "OCTOKIT_CLIENTSECRET" $true
|
||||||
Reference in New Issue
Block a user