From 672952bc21bc710ec599c085752938628564e89f Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 2 Nov 2018 09:10:24 -0400 Subject: [PATCH 1/4] Removing commentary --- src/BCC.Web/Services/GitHub/GitHubAppModelService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BCC.Web/Services/GitHub/GitHubAppModelService.cs b/src/BCC.Web/Services/GitHub/GitHubAppModelService.cs index a1ffe66..547dca0 100644 --- a/src/BCC.Web/Services/GitHub/GitHubAppModelService.cs +++ b/src/BCC.Web/Services/GitHub/GitHubAppModelService.cs @@ -175,8 +175,6 @@ private static NewCheckRunAnnotation CreateNewCheckRunAnnotation(Annotation anno newCheckRunAnnotation.Title = annotation.Title; } - newCheckRunAnnotation.RawDetails = "##Even More PlainText\r\n- No Markdown Here.\r\n- What? Why?"; - return newCheckRunAnnotation; } From ba38b91f67b124b7922959f98dd30ab801d747bb Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 2 Nov 2018 15:47:36 -0400 Subject: [PATCH 2/4] Increase window in test --- src/BCC.Web.Tests/Services/AccessTokenServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BCC.Web.Tests/Services/AccessTokenServiceTests.cs b/src/BCC.Web.Tests/Services/AccessTokenServiceTests.cs index 69358c0..4fb3dd4 100644 --- a/src/BCC.Web.Tests/Services/AccessTokenServiceTests.cs +++ b/src/BCC.Web.Tests/Services/AccessTokenServiceTests.cs @@ -143,7 +143,7 @@ public async Task CreateValidTokenTest() jsonWebToken.GetPayloadValue(JwtRegisteredClaimNames.Aud).Should().Be(".Api"); jsonWebToken.GetPayloadValue(JwtRegisteredClaimNames.Jti).Should().Be(accessToken.Id.ToString()); DateTimeOffset.FromUnixTimeSeconds(jsonWebToken.GetPayloadValue(JwtRegisteredClaimNames.Iat)).Should() - .BeCloseTo(DateTimeOffset.UtcNow, 1000); + .BeCloseTo(DateTimeOffset.UtcNow, 2000); jsonWebToken.GetPayloadValue("urn:bcc:repositoryId").Should().Be(userRepository.Id); } From a57418b09ca025cd42f70ebf0c1ac545dfefc134 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 2 Nov 2018 16:59:17 -0400 Subject: [PATCH 3/4] Removing the GraphQL Library because it's unused --- src/BCC.Web/BCC.Web.csproj | 1 - .../GitHub/IGitHubAppClientFactory.cs | 15 -------- .../Interfaces/GitHub/IGitHubClientFactory.cs | 7 ---- .../Interfaces/GitHub/IGitHubGraphQLClient.cs | 9 ----- .../GitHub/IGitHubUserClientFactory.cs | 6 ---- .../Services/GitHub/GitHubAppClientFactory.cs | 15 -------- .../Services/GitHub/GitHubClientFactory.cs | 7 ---- .../GitHub/GitHubClientFactoryHelper.cs | 6 ---- .../Services/GitHub/GitHubGraphQLClient.cs | 34 ------------------- .../Services/GitHub/GitHubUserModelService.cs | 3 -- .../Services/GitHubUserClientFactory.cs | 8 ----- 11 files changed, 111 deletions(-) delete mode 100644 src/BCC.Web/Interfaces/GitHub/IGitHubGraphQLClient.cs delete mode 100644 src/BCC.Web/Services/GitHub/GitHubGraphQLClient.cs diff --git a/src/BCC.Web/BCC.Web.csproj b/src/BCC.Web/BCC.Web.csproj index e73fd5f..bfd00ad 100644 --- a/src/BCC.Web/BCC.Web.csproj +++ b/src/BCC.Web/BCC.Web.csproj @@ -26,7 +26,6 @@ - diff --git a/src/BCC.Web/Interfaces/GitHub/IGitHubAppClientFactory.cs b/src/BCC.Web/Interfaces/GitHub/IGitHubAppClientFactory.cs index 1e9ef3c..f5406d2 100644 --- a/src/BCC.Web/Interfaces/GitHub/IGitHubAppClientFactory.cs +++ b/src/BCC.Web/Interfaces/GitHub/IGitHubAppClientFactory.cs @@ -16,26 +16,11 @@ public interface IGitHubAppClientFactory /// A client Task CreateAppClientForLoginAsync(ITokenGenerator tokenGenerator, string login); - /// - /// Create a IGitHubGraphQLClient configured for GitHub App Installation Authentication. - /// - /// A token generator configured for the GitHub App. - /// The login to authenticate. - /// A graphql client - Task CreateAppGraphQLClientForLoginAsync(ITokenGenerator tokenGenerator, string login); - /// /// Create a IGitHubClient configured for GitHub App Authentication. /// /// A token generator configured for the GitHub App. /// A client IGitHubClient CreateAppClient(ITokenGenerator tokenGenerator); - - /// - /// Create a IGitHubGraphQLClient configured for GitHub App Authentication. - /// - /// A token generator configured for the GitHub App. - /// A graphql client - IGitHubGraphQLClient CreateAppGraphQLClient(ITokenGenerator tokenGenerator); } } \ No newline at end of file diff --git a/src/BCC.Web/Interfaces/GitHub/IGitHubClientFactory.cs b/src/BCC.Web/Interfaces/GitHub/IGitHubClientFactory.cs index b777f10..e2c3fa2 100644 --- a/src/BCC.Web/Interfaces/GitHub/IGitHubClientFactory.cs +++ b/src/BCC.Web/Interfaces/GitHub/IGitHubClientFactory.cs @@ -13,12 +13,5 @@ public interface IGitHubClientFactory /// The token. /// A client IGitHubClient CreateClient(string token); - - /// - /// Create a IGitHubGraphQLClient configured with a token for Authentication. - /// - /// The token. - /// A graphql client - IGitHubGraphQLClient CreateGraphQLClient(string token); } } \ No newline at end of file diff --git a/src/BCC.Web/Interfaces/GitHub/IGitHubGraphQLClient.cs b/src/BCC.Web/Interfaces/GitHub/IGitHubGraphQLClient.cs deleted file mode 100644 index 2c85167..0000000 --- a/src/BCC.Web/Interfaces/GitHub/IGitHubGraphQLClient.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BCC.Web.Interfaces.GitHub -{ - /// - /// This service makes calls to the GitHub GraphQL Api. - /// - public interface IGitHubGraphQLClient - { - } -} \ No newline at end of file diff --git a/src/BCC.Web/Interfaces/GitHub/IGitHubUserClientFactory.cs b/src/BCC.Web/Interfaces/GitHub/IGitHubUserClientFactory.cs index 090bd8a..0067d06 100644 --- a/src/BCC.Web/Interfaces/GitHub/IGitHubUserClientFactory.cs +++ b/src/BCC.Web/Interfaces/GitHub/IGitHubUserClientFactory.cs @@ -13,11 +13,5 @@ public interface IGitHubUserClientFactory /// /// A client Task CreateClient(); - - /// - /// Create a IGitHubGraphQLClient configured for GitHub App User-To-Server Authentication. - /// - /// A graphql client - Task CreateGraphQLClient(); } } \ No newline at end of file diff --git a/src/BCC.Web/Services/GitHub/GitHubAppClientFactory.cs b/src/BCC.Web/Services/GitHub/GitHubAppClientFactory.cs index 4b225eb..e1fcf3e 100644 --- a/src/BCC.Web/Services/GitHub/GitHubAppClientFactory.cs +++ b/src/BCC.Web/Services/GitHub/GitHubAppClientFactory.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Octokit; using IGitHubAppClientFactory = BCC.Web.Interfaces.GitHub.IGitHubAppClientFactory; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; using ITokenGenerator = BCC.Web.Interfaces.GitHub.ITokenGenerator; namespace BCC.Web.Services.GitHub @@ -29,20 +28,6 @@ public IGitHubClient CreateAppClient(ITokenGenerator tokenGenerator) }; } - /// - public IGitHubGraphQLClient CreateAppGraphQLClient(ITokenGenerator tokenGenerator) - { - var token = tokenGenerator.GetToken(); - return GitHubClientFactoryHelper.GraphQLClient(token, GitHubClientFactory.UserAgent); - } - - /// - public async Task CreateAppGraphQLClientForLoginAsync(ITokenGenerator tokenGenerator, string login) - { - var (installation, token) = await FindInstallationAndGetToken(tokenGenerator, login); - return GitHubClientFactoryHelper.GraphQLClient(token, GetUserAgent(installation)); - } - private async Task> FindInstallationAndGetToken(ITokenGenerator tokenGenerator, string login) { var appClient = CreateAppClient(tokenGenerator); diff --git a/src/BCC.Web/Services/GitHub/GitHubClientFactory.cs b/src/BCC.Web/Services/GitHub/GitHubClientFactory.cs index a22a053..cd644e6 100644 --- a/src/BCC.Web/Services/GitHub/GitHubClientFactory.cs +++ b/src/BCC.Web/Services/GitHub/GitHubClientFactory.cs @@ -1,6 +1,5 @@ using Octokit; using IGitHubClientFactory = BCC.Web.Interfaces.GitHub.IGitHubClientFactory; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; namespace BCC.Web.Services.GitHub { @@ -14,11 +13,5 @@ public IGitHubClient CreateClient(string token) { return GitHubClientFactoryHelper.GitHubClient(token, UserAgent); } - - /// - public IGitHubGraphQLClient CreateGraphQLClient(string token) - { - return GitHubClientFactoryHelper.GraphQLClient(token, UserAgent); - } } } \ No newline at end of file diff --git a/src/BCC.Web/Services/GitHub/GitHubClientFactoryHelper.cs b/src/BCC.Web/Services/GitHub/GitHubClientFactoryHelper.cs index 8ebf560..0c3268a 100644 --- a/src/BCC.Web/Services/GitHub/GitHubClientFactoryHelper.cs +++ b/src/BCC.Web/Services/GitHub/GitHubClientFactoryHelper.cs @@ -1,6 +1,5 @@ using Octokit; using Octokit.Internal; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; namespace BCC.Web.Services.GitHub { @@ -12,10 +11,5 @@ public static IGitHubClient GitHubClient(string token, string userAgent) var credentialStore = new InMemoryCredentialStore(new Credentials(token)); return new GitHubClient(productHeaderValue, credentialStore); } - - public static IGitHubGraphQLClient GraphQLClient(string token, string userAgent) - { - return new GitHubGraphQLClient(new Octokit.GraphQL.ProductHeaderValue(userAgent), token); - } } } \ No newline at end of file diff --git a/src/BCC.Web/Services/GitHub/GitHubGraphQLClient.cs b/src/BCC.Web/Services/GitHub/GitHubGraphQLClient.cs deleted file mode 100644 index 2df6bc6..0000000 --- a/src/BCC.Web/Services/GitHub/GitHubGraphQLClient.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Octokit.GraphQL; -using Octokit.GraphQL.Core; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; - -namespace BCC.Web.Services.GitHub -{ - /// - public class GitHubGraphQLClient : IGitHubGraphQLClient - { - private readonly Connection _connection; - - public GitHubGraphQLClient(ProductHeaderValue headerValue, string accessToken) - { - _connection = new Connection(headerValue, accessToken); - } - - protected Task Run(IQueryableValue expression) - { - return _connection.Run(expression); - } - - protected Task> Run(IQueryableList expression) - { - return _connection.Run(expression); - } - - protected Task Run(ICompiledQuery query, Dictionary variables = null) - { - return _connection.Run(query, variables); - } - } -} \ No newline at end of file diff --git a/src/BCC.Web/Services/GitHub/GitHubUserModelService.cs b/src/BCC.Web/Services/GitHub/GitHubUserModelService.cs index 259e7a7..6aef2c2 100644 --- a/src/BCC.Web/Services/GitHub/GitHubUserModelService.cs +++ b/src/BCC.Web/Services/GitHub/GitHubUserModelService.cs @@ -5,7 +5,6 @@ using Nito.AsyncEx; using Octokit; using AccountType = BCC.Web.Models.GitHub.AccountType; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; using IGitHubUserClientFactory = BCC.Web.Interfaces.GitHub.IGitHubUserClientFactory; using IGitHubUserModelService = BCC.Web.Interfaces.GitHub.IGitHubUserModelService; using Installation = BCC.Web.Models.GitHub.Installation; @@ -17,12 +16,10 @@ namespace BCC.Web.Services.GitHub public class GitHubUserModelService : IGitHubUserModelService { private readonly AsyncLazy _lazyGitHubUserClient; - private readonly AsyncLazy _lazyGitHubUserGraphQLClient; public GitHubUserModelService(IGitHubUserClientFactory gitHubUserClientFactory) { _lazyGitHubUserClient = new AsyncLazy(() => gitHubUserClientFactory.CreateClient()); - _lazyGitHubUserGraphQLClient = new AsyncLazy(() => gitHubUserClientFactory.CreateGraphQLClient()); } /// diff --git a/src/BCC.Web/Services/GitHubUserClientFactory.cs b/src/BCC.Web/Services/GitHubUserClientFactory.cs index 4a820dc..dea202d 100644 --- a/src/BCC.Web/Services/GitHubUserClientFactory.cs +++ b/src/BCC.Web/Services/GitHubUserClientFactory.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Http; using Octokit; using IGitHubClientFactory = BCC.Web.Interfaces.GitHub.IGitHubClientFactory; -using IGitHubGraphQLClient = BCC.Web.Interfaces.GitHub.IGitHubGraphQLClient; using IGitHubUserClientFactory = BCC.Web.Interfaces.GitHub.IGitHubUserClientFactory; namespace BCC.Web.Services @@ -27,13 +26,6 @@ public async Task CreateClient() return _gitHubClientFactory.CreateClient(token); } - /// - public async Task CreateGraphQLClient() - { - var token = await GetAccessToken(); - return _gitHubClientFactory.CreateGraphQLClient(token); - } - private async Task GetAccessToken() { return await _contextAccessor.HttpContext.GetTokenAsync("access_token"); From efdcc70202c549fbaa0cb4cce47fbd8dd3ce3b01 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 2 Nov 2018 17:29:59 -0400 Subject: [PATCH 4/4] Missing things --- .../IntegrationTestsBase.cs | 21 ------------------- .../GitHubAppModelServiceBaseTests.cs | 6 ++---- .../GitHubGraphQLClientIntegrationTests.cs | 14 ------------- 3 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 src/BCC.Web.IntegrationTests/Services/GitHubGraphQLClientIntegrationTests.cs diff --git a/src/BCC.Web.IntegrationTests/IntegrationTestsBase.cs b/src/BCC.Web.IntegrationTests/IntegrationTestsBase.cs index 7557efb..cbfe511 100644 --- a/src/BCC.Web.IntegrationTests/IntegrationTestsBase.cs +++ b/src/BCC.Web.IntegrationTests/IntegrationTestsBase.cs @@ -38,37 +38,16 @@ protected IGitHubClient CreateGitHubAppClient() return gitHubClientFactory.CreateAppClient(tokenGenerator); } - protected IGitHubGraphQLClient CreateGitHubAppGraphQLClient() - { - var gitHubClientFactory = CreateGitHubAppClientFactory(); - var tokenGenerator = CreateTokenGenerator(); - return gitHubClientFactory.CreateAppGraphQLClient(tokenGenerator); - } - protected async Task CreateGitHubAppClientForLogin(string login) { var gitHubClientFactory = CreateGitHubAppClientFactory(); var tokenGenerator = CreateTokenGenerator(); return await gitHubClientFactory.CreateAppClientForLoginAsync(tokenGenerator, login); } - - protected async Task CreateGitHubAppGraphQLClientForLogin(string login) - { - var gitHubClientFactory = CreateGitHubAppClientFactory(); - var tokenGenerator = CreateTokenGenerator(); - return await gitHubClientFactory.CreateAppGraphQLClientForLoginAsync(tokenGenerator, login); - } - protected IGitHubClient CreateGitHubTokenClient() { var gitHubClientFactory = new GitHubClientFactory(); return gitHubClientFactory.CreateClient(TestToken); } - - protected IGitHubGraphQLClient CreateGitHubGraphQLTokenClient() - { - var gitHubClientFactory = new GitHubClientFactory(); - return gitHubClientFactory.CreateGraphQLClient(TestToken); - } } } \ No newline at end of file diff --git a/src/BCC.Web.IntegrationTests/Services/GitHubAppModelServiceBaseTests.cs b/src/BCC.Web.IntegrationTests/Services/GitHubAppModelServiceBaseTests.cs index 9a9a6af..ff6d098 100644 --- a/src/BCC.Web.IntegrationTests/Services/GitHubAppModelServiceBaseTests.cs +++ b/src/BCC.Web.IntegrationTests/Services/GitHubAppModelServiceBaseTests.cs @@ -27,17 +27,15 @@ public async Task ShouldNotGetFileThatDoesNotExist() private TestAppModelService CreateTarget() { - return new TestAppModelService(CreateGitHubTokenClient(), CreateGitHubGraphQLTokenClient()); + return new TestAppModelService(CreateGitHubTokenClient()); } private class TestAppModelService : GitHubAppModelServiceBase { private readonly IGitHubClient _gitHubClient; - private readonly IGitHubGraphQLClient _graphQLClient; - public TestAppModelService(IGitHubClient gitHubClient, IGitHubGraphQLClient graphQLClient) + public TestAppModelService(IGitHubClient gitHubClient) { - _graphQLClient = graphQLClient; _gitHubClient = gitHubClient; } diff --git a/src/BCC.Web.IntegrationTests/Services/GitHubGraphQLClientIntegrationTests.cs b/src/BCC.Web.IntegrationTests/Services/GitHubGraphQLClientIntegrationTests.cs deleted file mode 100644 index 6796fba..0000000 --- a/src/BCC.Web.IntegrationTests/Services/GitHubGraphQLClientIntegrationTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Threading.Tasks; -using BCC.Web.IntegrationTests.Utilities; - -namespace BCC.Web.IntegrationTests.Services -{ - public class GitHubGraphQLClientIntegrationTests : IntegrationTestsBase - { - [IntegrationTest] - public async Task ShouldConstruct() - { - var gitHubGraphQLClient = CreateGitHubGraphQLTokenClient(); - } - } -} \ No newline at end of file