Skip to content

Instantly share code, notes, and snippets.

@michaeltnguyen
Created November 6, 2018 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeltnguyen/f4f36e1d92661b60fa1183bc5cb8760b to your computer and use it in GitHub Desktop.
Save michaeltnguyen/f4f36e1d92661b60fa1183bc5cb8760b to your computer and use it in GitHub Desktop.
Overridden startup for integration test
/// <summary>
/// A startup class that bypasses oauth authentication for use in
/// integration tests and turns off application insights.
/// </summary>
public class LocalAuthStartup : Startup
{
public LocalAuthStartup(IConfiguration configuration) : base(configuration)
{
}
protected override void ConfigureAuth(IServiceCollection services)
{
// override the base jwt authentication with our local authorization.
// don't want a dependency on identity server under test
services.AddLocalAuthentication();
}
protected override void ConfigureAppInsights(IServiceCollection services)
{
// override the base implementation with nothing. We don't want
// telemetry under test
}
protected override void ConfigureDependencies(IServiceCollection services)
{
services.AddSingleton(new Mock<IDatabaseManager>(MockBehavior.Strict).Object);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment