private async Task NtlmAuthenticationTest(TestVariant variant) { var testName = $"NtlmAuthentication_{variant}"; using (StartLog(out var loggerFactory, testName)) { var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest"); var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(variant) { ApplicationPath = Helpers.GetApplicationPath(), PublishApplicationBeforeDeployment = true, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' ServerConfigTemplateContent = (variant.Server == ServerType.IISExpress) ? File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "NtlmAuthentation.config")) : null, SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, logger); } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair <string, string>( MusicStoreConfig.ConnectionStringKey, DbUtils.CreateConnectionString(musicStoreDbName))); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { var deploymentResult = await deployer.DeployAsync(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = deploymentResult.CreateHttpClient(httpClientHandler); // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async() => { return(await httpClient.GetAsync(string.Empty)); }, logger : logger, cancellationToken : deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); logger.LogInformation("Verifying home page"); await validator.VerifyNtlmHomePage(response); logger.LogInformation("Verifying access to store with permissions"); await validator.AccessStoreWithPermissions(); logger.LogInformation("Variation completed successfully."); } } }
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl) { using (_logger.BeginScope("NtlmAuthenticationTest")) { var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture) { PublishApplicationBeforeDeployment = true, PublishTargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0", ApplicationType = applicationType, ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null, SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, _logger); } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair <string, string>( MusicStore.StoreConfig.ConnectionStringKey, DbUtils.CreateConnectionString(musicStoreDbName))); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger)) { var deploymentResult = deployer.Deploy(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async() => { return(await httpClient.GetAsync(string.Empty)); }, logger : _logger, cancellationToken : deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult); Console.WriteLine("Verifying home page"); await validator.VerifyNtlmHomePage(response); Console.WriteLine("Verifying access to store with permissions"); await validator.AccessStoreWithPermissions(); _logger.LogInformation("Variation completed successfully."); } } }
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole(LogLevel.Warning) .CreateLogger(string.Format("Ntlm:{0}:{1}:{2}", serverType, runtimeFlavor, architecture)); using (logger.BeginScope("NtlmAuthenticationTest")) { var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var connectionString = string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(), serverType, runtimeFlavor, architecture) { ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' ApplicationHostConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null, SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config UserAdditionalCleanup = parameters => { if (!Helpers.RunningOnMono) { // Mono uses InMemoryStore DbUtils.DropDatabase(musicStoreDbName, logger); } } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair<string, string>( "SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName))); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger)) { var deploymentResult = deployer.Deploy(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async () => { return await httpClient.GetAsync(string.Empty); }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); await validator.VerifyNtlmHomePage(response); //Should be able to access the store as the Startup adds necessary permissions for the current user await validator.AccessStoreWithPermissions(); logger.LogInformation("Variation completed successfully."); } } }
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl) { using (_logger.BeginScope("NtlmAuthenticationTest")) { var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture) { PublishApplicationBeforeDeployment = true, TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0", ApplicationType = applicationType, ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null, SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, _logger); } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair<string, string>( MusicStore.StoreConfig.ConnectionStringKey, DbUtils.CreateConnectionString(musicStoreDbName))); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger)) { var deploymentResult = deployer.Deploy(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async () => { return await httpClient.GetAsync(string.Empty); }, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult); Console.WriteLine("Verifying home page"); await validator.VerifyNtlmHomePage(response); Console.WriteLine("Verifying access to store with permissions"); await validator.AccessStoreWithPermissions(); _logger.LogInformation("Variation completed successfully."); } } }
private async Task NtlmAuthenticationTest(TestVariant variant) { var testName = $"NtlmAuthentication_{variant}"; using (StartLog(out var loggerFactory, testName)) { var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest"); var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(variant) { ApplicationPath = Helpers.GetApplicationPath(), PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, logger); } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair <string, string>( MusicStoreConfig.ConnectionStringKey, DbUtils.CreateConnectionString(musicStoreDbName))); if (variant.Server == ServerType.IISExpress) { var iisDeploymentParameters = new IISDeploymentParameters(deploymentParameters); iisDeploymentParameters.ServerConfigActionList.Add( (element, _) => { var authentication = element .RequiredElement("system.webServer") .GetOrAdd("security") .GetOrAdd("authentication"); authentication.GetOrAdd("anonymousAuthentication") .SetAttributeValue("enabled", "false"); authentication.GetOrAdd("windowsAuthentication") .SetAttributeValue("enabled", "true"); }); deploymentParameters = iisDeploymentParameters; } using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { var deploymentResult = await deployer.DeployAsync(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = deploymentResult.CreateHttpClient(httpClientHandler); // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async() => { return(await httpClient.GetAsync(string.Empty)); }, logger : logger, cancellationToken : deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); logger.LogInformation("Verifying home page"); await validator.VerifyNtlmHomePage(response); logger.LogInformation("Verifying architecture"); validator.VerifyArchitecture(response, deploymentResult.DeploymentParameters.RuntimeArchitecture); logger.LogInformation("Verifying access to store with permissions"); await validator.AccessStoreWithPermissions(); logger.LogInformation("Variation completed successfully."); } } }
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole(LogLevel.Warning) .CreateLogger(string.Format("Ntlm:{0}:{1}:{2}", serverType, runtimeFlavor, architecture)); using (logger.BeginScope("NtlmAuthenticationTest")) { var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var connectionString = string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(), serverType, runtimeFlavor, architecture) { ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' ApplicationHostConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null, SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config UserAdditionalCleanup = parameters => { if (!Helpers.RunningOnMono) { // Mono uses InMemoryStore DbUtils.DropDatabase(musicStoreDbName, logger); } } }; // Override the connection strings using environment based configuration deploymentParameters.EnvironmentVariables .Add(new KeyValuePair <string, string>( "SQLAZURECONNSTR_DefaultConnection", string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName))); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger)) { var deploymentResult = deployer.Deploy(); var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await RetryHelper.RetryRequest(async() => { return(await httpClient.GetAsync(string.Empty)); }, logger : logger, cancellationToken : deploymentResult.HostShutdownToken); Assert.False(response == null, "Response object is null because the client could not " + "connect to the server after multiple retries"); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); await validator.VerifyNtlmHomePage(response); //Should be able to access the store as the Startup adds necessary permissions for the current user await validator.AccessStoreWithPermissions(); logger.LogInformation("Variation completed successfully."); } } }