Printing the runtime information at the beginning of the test

This commit is contained in:
Praburaj 2015-02-04 11:10:53 -08:00
parent 5df0d884aa
commit 8617bdc223
4 changed files with 112 additions and 101 deletions

View File

@ -3,7 +3,6 @@ using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Diagnostics.Entity; using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Security; using Microsoft.AspNet.Security;
using Microsoft.Framework.Cache.Memory; using Microsoft.Framework.Cache.Memory;
using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.ConfigurationModel;

View File

@ -4,7 +4,6 @@ using System.Security.Principal;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Diagnostics.Entity; using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Security; using Microsoft.AspNet.Security;
using Microsoft.AspNet.Server.WebListener; using Microsoft.AspNet.Server.WebListener;
using Microsoft.Framework.Cache.Memory; using Microsoft.Framework.Cache.Memory;
@ -43,38 +42,7 @@ namespace MusicStore
public IConfiguration Configuration { get; private set; } public IConfiguration Configuration { get; private set; }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void ConfigureServices(IServiceCollection services)
{
loggerFactory.AddConsole();
//Set up NTLM authentication for WebListener like below.
//For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or modify the applicationHost.config to enable NTLM.
if ((app.Server as ServerInformation) != null)
{
var serverInformation = (ServerInformation)app.Server;
serverInformation.Listener.AuthenticationManager.AuthenticationTypes = AuthenticationTypes.NTLM;
}
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.
var identity = (ClaimsIdentity)context.User.Identity;
if (identity.GetUserName() == Environment.GetEnvironmentVariable("USERDOMAIN") + "\\" + Environment.GetEnvironmentVariable("USERNAME"))
{
identity.AddClaim(new Claim("ManageStore", "Allowed"));
}
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 // Add EF services to the services container
services.AddEntityFramework(Configuration) services.AddEntityFramework(Configuration)
@ -99,6 +67,42 @@ namespace MusicStore
{ {
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build()); options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
}); });
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
//Set up NTLM authentication for WebListener like below.
//For IIS and IISExpress: Use inetmgr to setup NTLM authentication on the application vDir or modify the applicationHost.config to enable NTLM.
if ((app.Server as ServerInformation) != null)
{
var serverInformation = (ServerInformation)app.Server;
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.
var identity = (ClaimsIdentity)context.User.Identity;
if (identity.GetUserName() == Environment.GetEnvironmentVariable("USERDOMAIN") + "\\" + Environment.GetEnvironmentVariable("USERNAME"))
{
identity.AddClaim(new Claim("ManageStore", "Allowed"));
}
await next.Invoke();
}); });
// Configure Session. // Configure Session.

View File

@ -54,6 +54,10 @@ namespace E2ETests
Assert.Contains("www.github.com/aspnet/MusicStore", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("www.github.com/aspnet/MusicStore", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("/Images/home-showcase.png", responseContent, StringComparison.OrdinalIgnoreCase);
_logger.WriteInformation("Application initialization successful."); _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) private string PrefixBaseAddress(string url)

View File

@ -6,7 +6,6 @@ using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Diagnostics.Entity; using Microsoft.AspNet.Diagnostics.Entity;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Security; using Microsoft.AspNet.Security;
using Microsoft.AspNet.Security.Facebook; using Microsoft.AspNet.Security.Facebook;
using Microsoft.AspNet.Security.Google; using Microsoft.AspNet.Security.Google;
@ -46,17 +45,7 @@ namespace MusicStore
public IConfiguration Configuration { get; private set; } public IConfiguration Configuration { get; private set; }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void ConfigureServices(IServiceCollection services)
{
loggerFactory.AddConsole();
//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 =>
{ {
//Sql client not available on mono //Sql client not available on mono
string value; string value;
@ -120,7 +109,22 @@ namespace MusicStore
{ {
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build()); options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build());
}); });
}); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
//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();
// Configure Session. // Configure Session.
app.UseSession(); app.UseSession();