Printing the runtime information at the beginning of the test
This commit is contained in:
parent
5df0d884aa
commit
8617bdc223
|
|
@ -3,7 +3,6 @@ using Microsoft.AspNet.Builder;
|
|||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Diagnostics.Entity;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Security;
|
||||
using Microsoft.Framework.Cache.Memory;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using System.Security.Principal;
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Diagnostics.Entity;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Security;
|
||||
using Microsoft.AspNet.Server.WebListener;
|
||||
using Microsoft.Framework.Cache.Memory;
|
||||
|
|
@ -43,6 +42,33 @@ namespace MusicStore
|
|||
|
||||
public IConfiguration Configuration { get; private set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Add EF services to the services container
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
|
||||
//Add all SignalR related services to IoC.
|
||||
services.AddSignalR();
|
||||
|
||||
//Add InMemoryCache
|
||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||
|
||||
// Add session related services.
|
||||
services.AddCachingServices();
|
||||
services.AddSessionServices();
|
||||
|
||||
// Configure Auth
|
||||
services.Configure<AuthorizationOptions>(options =>
|
||||
{
|
||||
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole();
|
||||
|
|
@ -55,6 +81,17 @@ namespace MusicStore
|
|||
serverInformation.Listener.AuthenticationManager.AuthenticationTypes = AuthenticationTypes.NTLM;
|
||||
}
|
||||
|
||||
//Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||
|
||||
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||
|
||||
// Add the runtime information page that can be used by developers
|
||||
// to see what packages are used by the application
|
||||
// default path is: /runtimeinfo
|
||||
app.UseRuntimeInfoPage();
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
//Who will get admin access? For demo sake I'm listing the currently logged on user as the application administrator. But this can be changed to suit the needs.
|
||||
|
|
@ -68,39 +105,6 @@ namespace MusicStore
|
|||
await next.Invoke();
|
||||
});
|
||||
|
||||
//Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||
|
||||
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||
|
||||
app.UseServices(services =>
|
||||
{
|
||||
// Add EF services to the services container
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
|
||||
//Add all SignalR related services to IoC.
|
||||
services.AddSignalR();
|
||||
|
||||
//Add InMemoryCache
|
||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||
|
||||
// Add session related services.
|
||||
services.AddCachingServices();
|
||||
services.AddSessionServices();
|
||||
|
||||
// Configure Auth
|
||||
services.Configure<AuthorizationOptions>(options =>
|
||||
{
|
||||
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
|
||||
});
|
||||
});
|
||||
|
||||
// Configure Session.
|
||||
app.UseSession();
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ namespace E2ETests
|
|||
Assert.Contains("www.github.com/aspnet/MusicStore", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
_logger.WriteInformation("Application initialization successful.");
|
||||
|
||||
_logger.WriteInformation("Application runtime information");
|
||||
var runtimeInfo = _httpClient.GetAsync("runtimeinfo").Result.Content.ReadAsStringAsync().Result;
|
||||
_logger.WriteInformation(runtimeInfo);
|
||||
}
|
||||
|
||||
private string PrefixBaseAddress(string url)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using Microsoft.AspNet.Diagnostics;
|
|||
using Microsoft.AspNet.Diagnostics.Entity;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Security;
|
||||
using Microsoft.AspNet.Security.Facebook;
|
||||
using Microsoft.AspNet.Security.Google;
|
||||
|
|
@ -46,6 +45,72 @@ namespace MusicStore
|
|||
|
||||
public IConfiguration Configuration { get; private set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
//Sql client not available on mono
|
||||
string value;
|
||||
var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ?
|
||||
true :
|
||||
Type.GetType("Mono.Runtime") != null;
|
||||
|
||||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddInMemoryStore()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
}
|
||||
|
||||
// Add Identity services to the services container
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration)
|
||||
.AddEntityFrameworkStores<MusicStoreContext>()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddMessageProvider<EmailMessageProvider>()
|
||||
.AddMessageProvider<SmsMessageProvider>();
|
||||
|
||||
services.ConfigureFacebookAuthentication(options =>
|
||||
{
|
||||
options.AppId = "[AppId]";
|
||||
options.AppSecret = "[AppSecret]";
|
||||
options.Notifications = new FacebookAuthenticationNotifications()
|
||||
{
|
||||
OnAuthenticated = FacebookNotifications.OnAuthenticated,
|
||||
OnReturnEndpoint = FacebookNotifications.OnReturnEndpoint,
|
||||
OnApplyRedirect = FacebookNotifications.OnApplyRedirect
|
||||
};
|
||||
options.BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler();
|
||||
options.StateDataFormat = new CustomStateDataFormat();
|
||||
options.Scope.Add("email");
|
||||
options.Scope.Add("read_friendlists");
|
||||
options.Scope.Add("user_checkins");
|
||||
});
|
||||
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
|
||||
//Add all SignalR related services to IoC.
|
||||
services.AddSignalR();
|
||||
|
||||
//Add InMemoryCache
|
||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||
|
||||
// Add session related services.
|
||||
services.AddCachingServices();
|
||||
services.AddSessionServices();
|
||||
|
||||
// Configure Auth
|
||||
services.Configure<AuthorizationOptions>(options =>
|
||||
{
|
||||
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole();
|
||||
|
|
@ -56,71 +121,10 @@ namespace MusicStore
|
|||
|
||||
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||
|
||||
app.UseServices(services =>
|
||||
{
|
||||
//Sql client not available on mono
|
||||
string value;
|
||||
var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ?
|
||||
true :
|
||||
Type.GetType("Mono.Runtime") != null;
|
||||
|
||||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddInMemoryStore()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework(Configuration)
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>();
|
||||
}
|
||||
|
||||
// Add Identity services to the services container
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration)
|
||||
.AddEntityFrameworkStores<MusicStoreContext>()
|
||||
.AddDefaultTokenProviders()
|
||||
.AddMessageProvider<EmailMessageProvider>()
|
||||
.AddMessageProvider<SmsMessageProvider>();
|
||||
|
||||
services.ConfigureFacebookAuthentication(options =>
|
||||
{
|
||||
options.AppId = "[AppId]";
|
||||
options.AppSecret = "[AppSecret]";
|
||||
options.Notifications = new FacebookAuthenticationNotifications()
|
||||
{
|
||||
OnAuthenticated = FacebookNotifications.OnAuthenticated,
|
||||
OnReturnEndpoint = FacebookNotifications.OnReturnEndpoint,
|
||||
OnApplyRedirect = FacebookNotifications.OnApplyRedirect
|
||||
};
|
||||
options.BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler();
|
||||
options.StateDataFormat = new CustomStateDataFormat();
|
||||
options.Scope.Add("email");
|
||||
options.Scope.Add("read_friendlists");
|
||||
options.Scope.Add("user_checkins");
|
||||
});
|
||||
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
|
||||
//Add all SignalR related services to IoC.
|
||||
services.AddSignalR();
|
||||
|
||||
//Add InMemoryCache
|
||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||
|
||||
// Add session related services.
|
||||
services.AddCachingServices();
|
||||
services.AddSessionServices();
|
||||
|
||||
// Configure Auth
|
||||
services.Configure<AuthorizationOptions>(options =>
|
||||
{
|
||||
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
|
||||
});
|
||||
});
|
||||
// Add the runtime information page that can be used by developers
|
||||
// to see what packages are used by the application
|
||||
// default path is: /runtimeinfo
|
||||
app.UseRuntimeInfoPage();
|
||||
|
||||
// Configure Session.
|
||||
app.UseSession();
|
||||
|
|
|
|||
Loading…
Reference in New Issue