Example #1
0
        public async Task RunTestsAsync(
            ServerType serverType,
            string applicationBaseUrl,
            ApplicationType applicationType)
        {
            using (_logger.BeginScope(nameof(SmokeTestsOnNanoServerUsingStandaloneRuntime)))
            {
                var deploymentParameters = new RemoteWindowsDeploymentParameters(
                    Helpers.GetApplicationPath(applicationType),
                    _remoteDeploymentConfig.DotnetRuntimePathOnShare,
                    serverType,
                    RuntimeFlavor.CoreClr,
                    RuntimeArchitecture.x64,
                    _remoteDeploymentConfig.FileSharePath,
                    _remoteDeploymentConfig.ServerName,
                    _remoteDeploymentConfig.AccountName,
                    _remoteDeploymentConfig.AccountPassword)
                {
                    TargetFramework        = "netcoreapp1.0",
                    ApplicationBaseUriHint = applicationBaseUrl,
                    ApplicationType        = applicationType
                };
                deploymentParameters.EnvironmentVariables.Add(
                    new KeyValuePair <string, string>("ASPNETCORE_ENVIRONMENT", "SocialTesting"));

                using (var deployer = new RemoteWindowsDeployer(deploymentParameters, _logger))
                {
                    var deploymentResult = deployer.Deploy();

                    await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger);
                }
            }
        }
Example #2
0
        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.");
                }
            }
        }
        // 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,
                    PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
                    TargetFramework        = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0",
                    Configuration          = Helpers.GetCurrentBuildConfiguration(),
                    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>(
                         MusicStoreConfig.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.");
                }
            }
        }
Example #4
0
        public async Task RunTestsAsync(
            ServerType serverType,
            string applicationBaseUrl,
            ApplicationType applicationType)
        {
            using (_logger.BeginScope(nameof(SmokeTestsOnNanoServerUsingStandaloneRuntime)))
            {
                var deploymentParameters = new RemoteWindowsDeploymentParameters(
                    Helpers.GetApplicationPath(applicationType),
                    _remoteDeploymentConfig.DotnetRuntimePathOnShare,
                    serverType,
                    RuntimeFlavor.CoreClr,
                    RuntimeArchitecture.x64,
                    _remoteDeploymentConfig.FileSharePath,
                    _remoteDeploymentConfig.ServerName,
                    _remoteDeploymentConfig.AccountName,
                    _remoteDeploymentConfig.AccountPassword)
                {
                    TargetFramework        = "netcoreapp1.1",
                    ApplicationBaseUriHint = applicationBaseUrl,
                    ApplicationType        = applicationType
                };

                if (applicationType == ApplicationType.Standalone)
                {
                    // Unable to use the RuntimeEnvironment.GetRuntimeIdentifier API here as NanoServer which is
                    // part of Windows Server 2016 has a RID of 'win10-x64' where as the CI servers currently
                    // run on Windows Server 2012 or less, which have different RIDs.
                    deploymentParameters.AdditionalPublishParameters = "-r win10-x64";
                }

                deploymentParameters.EnvironmentVariables.Add(
                    new KeyValuePair <string, string>("ASPNETCORE_ENVIRONMENT", "SocialTesting"));

                using (var deployer = new RemoteWindowsDeployer(deploymentParameters, _logger))
                {
                    var deploymentResult = deployer.Deploy();

                    await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger);
                }
            }
        }