diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 07cae5024e..4cd52f8aac 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -48,7 +48,17 @@ public static class Helper return null; return new Credentials(githubUsername, githubPassword); - }); + }); + + static readonly Lazy _gitHubEnterpriseUrl = new Lazy(() => + { + string uri = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBENTERPRISEURL"); + + if (uri != null) + return new Uri(uri); + + return null; + }); static Helper() { @@ -67,6 +77,8 @@ static Helper() 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 @@ public static Stream LoadFixture(string fileName) 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 @@ public static IGitHubClient GetAuthenticatedClient() 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 @@ public static IGitHubClient GetBasicAuthClient() 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 @@ public static GitHubClient GetAuthenticatedApplicationClient() 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") }; diff --git a/script/configure-integration-tests.ps1 b/script/configure-integration-tests.ps1 index 7f55d42c19..5592c3e495 100644 --- a/script/configure-integration-tests.ps1 +++ b/script/configure-integration-tests.ps1 @@ -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 \ No newline at end of file