From 8617bdc223454a70655d90f24ccded587924f5cf Mon Sep 17 00:00:00 2001 From: Praburaj Date: Wed, 4 Feb 2015 11:10:53 -0800 Subject: [PATCH] Printing the runtime information at the beginning of the test --- src/MusicStore/Startup.cs | 1 - src/MusicStore/StartupNtlmAuthentication.cs | 72 +++++----- test/E2ETests/Implementation/Scenarios.cs | 4 + .../shared/Mocks/StartupSocialTesting.cs | 136 +++++++++--------- 4 files changed, 112 insertions(+), 101 deletions(-) diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index ffe81235d1..108d34f429 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -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; diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index 383fdec1c4..d80ed2b670 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -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(); + + // Add MVC services to the services container + services.AddMvc(); + + //Add all SignalR related services to IoC. + services.AddSignalR(); + + //Add InMemoryCache + services.AddSingleton(); + + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + + // Configure Auth + services.Configure(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(); - - // Add MVC services to the services container - services.AddMvc(); - - //Add all SignalR related services to IoC. - services.AddSignalR(); - - //Add InMemoryCache - services.AddSingleton(); - - // Add session related services. - services.AddCachingServices(); - services.AddSessionServices(); - - // Configure Auth - services.Configure(options => - { - options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("ManageStore", "Allowed").Build()); - }); - }); - // Configure Session. app.UseSession(); diff --git a/test/E2ETests/Implementation/Scenarios.cs b/test/E2ETests/Implementation/Scenarios.cs index dba0150697..584f5ce0f3 100644 --- a/test/E2ETests/Implementation/Scenarios.cs +++ b/test/E2ETests/Implementation/Scenarios.cs @@ -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) diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index fa0bb5929f..da32e6f91a 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -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(); + } + else + { + services.AddEntityFramework(Configuration) + .AddSqlServer() + .AddDbContext(); + } + + // Add Identity services to the services container + services.AddIdentity(Configuration) + .AddEntityFrameworkStores() + .AddDefaultTokenProviders() + .AddMessageProvider() + .AddMessageProvider(); + + 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(); + + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + + // Configure Auth + services.Configure(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(); - } - else - { - services.AddEntityFramework(Configuration) - .AddSqlServer() - .AddDbContext(); - } - - // Add Identity services to the services container - services.AddIdentity(Configuration) - .AddEntityFrameworkStores() - .AddDefaultTokenProviders() - .AddMessageProvider() - .AddMessageProvider(); - - 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(); - - // Add session related services. - services.AddCachingServices(); - services.AddSessionServices(); - - // Configure Auth - services.Configure(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();