public async Task SmokeTestSuite( ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl, bool noSource = false) { using (_logger.BeginScope("SmokeTestSuite")) { var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters( Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture) { ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "SocialTesting", ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, SiteName = "MusicStoreTestSite", PublishApplicationBeforeDeployment = true, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, UserAdditionalCleanup = parameters => { DbUtils.DropDatabase(musicStoreDbName, _logger); } }; if (applicationType == ApplicationType.Standalone) { deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier(); } // 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, _logger)) { var deploymentResult = deployer.Deploy(); Helpers.SetInMemoryStoreForIIS(deploymentParameters, _logger); await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger); } } }
public async Task SmokeTestSuite( ServerType serverType, RuntimeArchitecture architecture, ApplicationType applicationType, bool noSource = false) { var testName = $"SmokeTestSuite_{serverType}_{architecture}_{applicationType}"; using (StartLog(out var loggerFactory, testName)) { var logger = loggerFactory.CreateLogger("SmokeTestSuite"); var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters( Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture) { EnvironmentName = "SocialTesting", ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, SiteName = "MusicStoreTestSite", PublishApplicationBeforeDeployment = true, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, TargetFramework = "netcoreapp2.0", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, 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(); Helpers.SetInMemoryStoreForIIS(deploymentParameters, logger); await SmokeTestHelper.RunTestsAsync(deploymentResult, logger); } } }
public async Task SmokeTestSuite( ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl, bool noSource = false) { using (_logger.BeginScope("SmokeTestSuite")) { var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters( Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture) { ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "SocialTesting", ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null, SiteName = "MusicStoreTestSite", PublishApplicationBeforeDeployment = true, TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0", ApplicationType = applicationType, 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(); Helpers.SetInMemoryStoreForIIS(deploymentParameters, _logger); var httpClientHandler = new HttpClientHandler(); var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri), Timeout = TimeSpan.FromSeconds(5), }; // 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); // Verify the static file middleware can serve static content. await validator.VerifyStaticContentServed(); // Making a request to a protected resource should automatically redirect to login page. await validator.AccessStoreWithoutPermissions(); // Register a user - Negative scenario where the Password & ConfirmPassword do not match. await validator.RegisterUserWithNonMatchingPasswords(); // Register a valid user. var generatedEmail = await validator.RegisterValidUser(); await validator.SignInWithUser(generatedEmail, "Password~1"); // Register a user - Negative scenario : Trying to register a user name that's already registered. await validator.RegisterExistingUser(generatedEmail); // Logout from this user session - This should take back to the home page await validator.SignOutUser(generatedEmail); // Sign in scenarios: Invalid password - Expected an invalid user name password error. await validator.SignInWithInvalidPassword(generatedEmail, "InvalidPassword~1"); // Sign in scenarios: Valid user name & password. await validator.SignInWithUser(generatedEmail, "Password~1"); // Change password scenario await validator.ChangePassword(generatedEmail); // SignIn with old password and verify old password is not allowed and new password is allowed await validator.SignOutUser(generatedEmail); await validator.SignInWithInvalidPassword(generatedEmail, "Password~1"); await validator.SignInWithUser(generatedEmail, "Password~2"); // Making a request to a protected resource that this user does not have access to - should // automatically redirect to the configured access denied page await validator.AccessStoreWithoutPermissions(generatedEmail); // Logout from this user session - This should take back to the home page await validator.SignOutUser(generatedEmail); // Login as an admin user await validator.SignInWithUser("*****@*****.**", "YouShouldChangeThisPassword1!"); // Now navigating to the store manager should work fine as this user has // the necessary permission to administer the store. await validator.AccessStoreWithPermissions(); // Create an album var albumName = await validator.CreateAlbum(); var albumId = await validator.FetchAlbumIdFromName(albumName); // Get details of the album await validator.VerifyAlbumDetails(albumId, albumName); // Verify status code pages acts on non-existing items. await validator.VerifyStatusCodePages(); // Get the non-admin view of the album. await validator.GetAlbumDetailsFromStore(albumId, albumName); // Add an album to cart and checkout the same await validator.AddAlbumToCart(albumId, albumName); await validator.CheckOutCartItems(); // Delete the album from store await validator.DeleteAlbum(albumId, albumName); // Logout from this user session - This should take back to the home page await validator.SignOutUser("Administrator"); // Google login await validator.LoginWithGoogle(); // Facebook login await validator.LoginWithFacebook(); // Twitter login await validator.LoginWithTwitter(); // MicrosoftAccountLogin await validator.LoginWithMicrosoftAccount(); _logger.LogInformation("Variation completed successfully."); } } }
public async Task SmokeTestSuite( ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource = false) { var logger = new LoggerFactory() .AddConsole(LogLevel.Information) .CreateLogger($"Smoke:{serverType}:{donetFlavor}:{architecture}"); using (logger.BeginScope("SmokeTestSuite")) { var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty); var deploymentParameters = new DeploymentParameters( Helpers.GetApplicationPath(), serverType, donetFlavor, architecture) { ApplicationBaseUriHint = applicationBaseUrl, EnvironmentName = "SocialTesting", PublishWithNoSource = noSource, UserAdditionalCleanup = parameters => { if (!Helpers.RunningOnMono && TestPlatformHelper.IsWindows && parameters.ServerType != ServerType.IIS) { // 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(); Helpers.SetInMemoryStoreForIIS(deploymentParameters, logger); var httpClientHandler = new HttpClientHandler() { // Temporary workaround for issue https://github.com/dotnet/corefx/issues/4960 AllowAutoRedirect = false }; var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri), Timeout = TimeSpan.FromSeconds(5) }; // 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); // Verify the static file middleware can serve static content. await validator.VerifyStaticContentServed(); // Making a request to a protected resource should automatically redirect to login page. await validator.AccessStoreWithoutPermissions(); // Register a user - Negative scenario where the Password & ConfirmPassword do not match. await validator.RegisterUserWithNonMatchingPasswords(); // Register a valid user. var generatedEmail = await validator.RegisterValidUser(); await validator.SignInWithUser(generatedEmail, "Password~1"); // Register a user - Negative scenario : Trying to register a user name that's already registered. await validator.RegisterExistingUser(generatedEmail); // Logout from this user session - This should take back to the home page await validator.SignOutUser(generatedEmail); // Sign in scenarios: Invalid password - Expected an invalid user name password error. await validator.SignInWithInvalidPassword(generatedEmail, "InvalidPassword~1"); // Sign in scenarios: Valid user name & password. await validator.SignInWithUser(generatedEmail, "Password~1"); // Change password scenario await validator.ChangePassword(generatedEmail); // SignIn with old password and verify old password is not allowed and new password is allowed await validator.SignOutUser(generatedEmail); await validator.SignInWithInvalidPassword(generatedEmail, "Password~1"); await validator.SignInWithUser(generatedEmail, "Password~2"); // Making a request to a protected resource that this user does not have access to - should // automatically redirect to the configured access denied page await validator.AccessStoreWithoutPermissions(generatedEmail); // Logout from this user session - This should take back to the home page await validator.SignOutUser(generatedEmail); // Login as an admin user await validator.SignInWithUser("*****@*****.**", "YouShouldChangeThisPassword1!"); // Now navigating to the store manager should work fine as this user has // the necessary permission to administer the store. await validator.AccessStoreWithPermissions(); // Create an album var albumName = await validator.CreateAlbum(); var albumId = await validator.FetchAlbumIdFromName(albumName); // Get details of the album await validator.VerifyAlbumDetails(albumId, albumName); // Verify status code pages acts on non-existing items. await validator.VerifyStatusCodePages(); // Get the non-admin view of the album. await validator.GetAlbumDetailsFromStore(albumId, albumName); // Add an album to cart and checkout the same await validator.AddAlbumToCart(albumId, albumName); await validator.CheckOutCartItems(); // Delete the album from store await validator.DeleteAlbum(albumId, albumName); // Logout from this user session - This should take back to the home page await validator.SignOutUser("Administrator"); // Google login await validator.LoginWithGoogle(); // Facebook login await validator.LoginWithFacebook(); // Twitter login await validator.LoginWithTwitter(); // MicrosoftAccountLogin await validator.LoginWithMicrosoftAccount(); logger.LogInformation("Variation completed successfully."); } } }