private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, ApplicationType applicationType) { var architecture = RuntimeArchitecture.x64; var testName = $"OpenIdConnectTestSuite_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}"; using (StartLog(out var loggerFactory, testName)) { var logger = loggerFactory.CreateLogger("OpenIdConnectTestSuite"); var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture) { PublishApplicationBeforeDeployment = true, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, EnvironmentName = "OpenIdConnectTesting", UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, logger); }, AdditionalPublishParameters = " /p:PublishForTesting=true" }; // 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(); 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.VerifyHomePage(response); logger.LogInformation("Verifying login by OpenIdConnect"); await validator.LoginWithOpenIdConnect(); logger.LogInformation("Variation completed successfully."); } } }
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole(LogLevel.Warning) .CreateLogger(string.Format("OpenId:{0}:{1}:{2}", serverType, runtimeFlavor, architecture)); using (logger.BeginScope("OpenIdConnectTestSuite")) { 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 = "OpenIdConnectTesting", 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(); 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.VerifyHomePage(response); // OpenIdConnect login. await validator.LoginWithOpenIdConnect(); logger.LogInformation("Variation completed successfully."); } } }
// TODO: temporarily disabling x86 tests as dotnet xunit test runner currently does not support 32-bit //[ConditionalTheory(Skip = "https://github.com/aspnet/MusicStore/issues/565"), Trait("E2Etests", "E2Etests")] //[OSSkipCondition(OperatingSystems.Windows)] //[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5045/")] //public async Task OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl) //{ // await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); //} private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl) { using (_logger.BeginScope("OpenIdConnectTestSuite")) { 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 = "OpenIdConnectTesting", 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(); 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.VerifyHomePage(response); Console.WriteLine("Verifying login by OpenIdConnect"); await validator.LoginWithOpenIdConnect(); _logger.LogInformation("Variation completed successfully."); } } }
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole() .CreateLogger(string.Format("OpenId:{0}:{1}:{2}", serverType, runtimeFlavor, architecture)); using (logger.BeginScope("OpenIdConnectTestSuite")) { 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 = "OpenIdConnectTesting", 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(); 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); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); await validator.VerifyHomePage(response); // OpenIdConnect login. await validator.LoginWithOpenIdConnect(); logger.LogInformation("Variation completed successfully."); } } }
// TODO: temporarily disabling x86 tests as dotnet xunit test runner currently does not support 32-bit //[ConditionalTheory(Skip = "https://github.com/aspnet/MusicStore/issues/565"), Trait("E2Etests", "E2Etests")] //[OSSkipCondition(OperatingSystems.Windows)] //[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, "http://localhost:5043/")] //public async Task OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) //{ // await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); //} private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { using (_logger.BeginScope("OpenIdConnectTestSuite")) { var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(), serverType, runtimeFlavor, architecture) { PublishApplicationBeforeDeployment = true, PublishTargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netstandardapp1.5", ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "OpenIdConnectTesting", 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(); 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.VerifyHomePage(response); // OpenIdConnect login. await validator.LoginWithOpenIdConnect(); _logger.LogInformation("Variation completed successfully."); } } }