Better support for GitHub Enterprise integration tests

- Remove EnterpriseUrl in integration test Helper class, but leave ability to override custom URL (to allow specific use case of targetting regular integration tests at a custom URL)
- Move GitHub Enterprise explicit support to a new integration helper class using new OCTOKIT_GHE_ environment variables for GHE
- Change existing GitHub Enterprise integration tests and EnterpriseTestAttribute to use the new EnterpriseHelper methods
- Enhance configure-intergration-tests.ps1 script to cater for environment variable changes
This commit is contained in:
Ryan Gribble
2016-01-27 00:12:22 +10:00
parent 5f2cc4cb4e
commit 535709c368
7 changed files with 198 additions and 22 deletions
+10 -16
View File
@@ -50,9 +50,9 @@ namespace Octokit.Tests.Integration
return new Credentials(githubUsername, githubPassword);
});
static readonly Lazy<Uri> _gitHubEnterpriseUrl = new Lazy<Uri>(() =>
static readonly Lazy<Uri> _customUrl = new Lazy<Uri>(() =>
{
string uri = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBENTERPRISEURL");
string uri = Environment.GetEnvironmentVariable("OCTOKIT_CUSTOMURL");
if (uri != null)
return new Uri(uri);
@@ -80,7 +80,9 @@ namespace Octokit.Tests.Integration
public static Credentials BasicAuthCredentials { get { return _basicAuthCredentials.Value; } }
public static Uri GitHubEnterpriseUrl { get { return _gitHubEnterpriseUrl.Value; } }
public static Uri CustomUrl { get { return _customUrl.Value; } }
public static Uri TargetUrl { get { return CustomUrl ?? GitHubClient.GitHubApiUrl; } }
public static bool IsUsingToken
{
@@ -98,14 +100,6 @@ namespace Octokit.Tests.Integration
}
}
public static bool IsGitHubEnterprise
{
get
{
return GitHubEnterpriseUrl != null;
}
}
public static string ClientId
{
get { return Environment.GetEnvironmentVariable("OCTOKIT_CLIENTID"); }
@@ -151,7 +145,7 @@ namespace Octokit.Tests.Integration
public static IGitHubClient GetAuthenticatedClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl)
{
Credentials = Credentials
};
@@ -159,7 +153,7 @@ namespace Octokit.Tests.Integration
public static IGitHubClient GetBasicAuthClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl)
{
Credentials = BasicAuthCredentials
};
@@ -167,7 +161,7 @@ namespace Octokit.Tests.Integration
public static GitHubClient GetAuthenticatedApplicationClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl)
{
Credentials = ApplicationCredentials
};
@@ -175,12 +169,12 @@ namespace Octokit.Tests.Integration
public static IGitHubClient GetAnonymousClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl);
return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl);
}
public static IGitHubClient GetBadCredentialsClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitTests"), GitHubEnterpriseUrl ?? GitHubClient.GitHubApiUrl)
return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl)
{
Credentials = new Credentials(Guid.NewGuid().ToString(), "bad-password")
};