public GitHubClientTestServer() { var webhookSecret = Convert.ToBase64String(Encoding.UTF8.GetBytes("github-webhook-secret-value")); TestGitHubAppSettings = new GitHubAppFlavorSettings { GitHubAppsSettings = new Dictionary <string, GitHubAppSettings> { [TestDomain] = new GitHubAppSettings { Id = "23", Name = "fakeName", EnterpriseApiRoot = "https://fakeApiRoot", EnterpriseUrl = $"https://{TestDomain}", PrivateKey = "fakeKey", WebhookSecret = webhookSecret }, ["github.com"] = new GitHubAppSettings { Id = "23", Name = "fakeName", EnterpriseApiRoot = "https://fakeApiRoot", EnterpriseUrl = $"https://{TestDomain}", PrivateKey = "fakeKey", WebhookSecret = webhookSecret } } }; azureServiceBusSettings = new AzureServiceBusSettings { ConnectionString = "fakeString", SubscriptionName = "fakeSub", TopicName = "fakeTopic" }; hostBuilder = new WebHostBuilder() .ConfigureServices( (context, services) => { context.Configuration = new ConfigurationBuilder() .AddInMemoryObject( TestGitHubAppSettings.GitHubAppsSettings[TestDomain], $"{nameof(GitHubAppFlavorSettings)}:GitHubAppsSettings:{TestDomain}") .AddInMemoryObject(azureServiceBusSettings, nameof(AzureServiceBusSettings)) .AddInMemoryCollection( new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("ApplicationInsights:InstrumentationKey", Guid.NewGuid().ToString()) }) .Build(); AddMockTelemetry(services); AddInMemoryEventBus(services); services.RegisterServices(context.Configuration); }) .Configure( (context, app) => { }) .UseStartup <Startup>(); testServer = new TestServer(hostBuilder); }
public GitHubWebhookController( IOptions <GitHubAppFlavorSettings> gitHubAppFlavorSettings, IAppTelemetry appTelemetry, IEventBus eventBus) { ArgumentCheck.ParameterIsNotNull(gitHubAppFlavorSettings, nameof(gitHubAppFlavorSettings)); ArgumentCheck.ParameterIsNotNull(gitHubAppFlavorSettings, nameof(gitHubAppFlavorSettings)); ArgumentCheck.ParameterIsNotNull(appTelemetry, nameof(appTelemetry)); this.appTelemetry = appTelemetry; this.eventBus = eventBus; this.gitHubAppFlavorSettings = gitHubAppFlavorSettings.Value; }