private async Task UpgradeFeatureDetectionDeployer(bool disableWebSocket, string sitePath, string expected, HostingModel hostingModel)
        {
            var deploymentParameters = new IISDeploymentParameters(sitePath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
            {
                TargetFramework = Tfm.NetCoreApp22,
                ApplicationType = ApplicationType.Portable,
                AncmVersion     = AncmVersion.AspNetCoreModuleV2,
                HostingModel    = hostingModel,
                PublishApplicationBeforeDeployment = hostingModel == HostingModel.InProcess
            };

            if (disableWebSocket)
            {
                // For IIS, we need to modify the apphost.config file
                deploymentParameters.AddServerConfigAction(
                    element => element.Descendants("webSocket")
                    .Single()
                    .SetAttributeValue("enabled", "false"));
            }

            var deploymentResult = await DeployAsync(deploymentParameters);

            var response = await deploymentResult.RetryingHttpClient.GetAsync("UpgradeFeatureDetection");

            var responseText = await response.Content.ReadAsStringAsync();

            Assert.Equal(expected, responseText);
        }
 public static void SetAnonymousAuth(this IISDeploymentParameters parameters, bool enabled = true)
 {
     parameters.AddServerConfigAction(
         element =>
     {
         element
         .RequiredElement("system.webServer")
         .RequiredElement("security")
         .RequiredElement("authentication")
         .GetOrAdd("anonymousAuthentication")
         .SetAttributeValue("enabled", enabled);
     });
 }
    public static void AddHttpsWithClientCertToServerConfig(this IISDeploymentParameters parameters)
    {
        parameters.AddServerConfigAction(
            element =>
        {
            element.Descendants("binding")
            .Single()
            .SetAttributeValue("protocol", "https");

            element.Descendants("access")
            .Single()
            .SetAttributeValue("sslFlags", "Ssl, SslNegotiateCert");
        });
    }
    public static void SetBasicAuth(this IISDeploymentParameters parameters, bool enabled = true)
    {
        parameters.EnableModule("BasicAuthenticationModule", "%IIS_BIN%\\authbas.dll");

        parameters.AddServerConfigAction(
            element =>
        {
            element
            .RequiredElement("system.webServer")
            .RequiredElement("security")
            .RequiredElement("authentication")
            .GetOrAdd("basicAuthentication")
            .SetAttributeValue("enabled", enabled);
        });
    }
    public static void SetWindowsAuth(this IISDeploymentParameters parameters, bool enabled = true)
    {
        parameters.EnsureSection("windowsAuthentication", "system.webServer", "security", "windowsAuthentication");
        parameters.EnableModule("WindowsAuthenticationModule", "%IIS_BIN%\\authsspi.dll");

        parameters.AddServerConfigAction(
            element =>
        {
            var windowsAuthentication = element
                                        .RequiredElement("system.webServer")
                                        .RequiredElement("security")
                                        .RequiredElement("authentication")
                                        .GetOrAdd("windowsAuthentication");

            windowsAuthentication.SetAttributeValue("enabled", enabled);
            var providers = windowsAuthentication.GetOrAdd("providers");
            providers.GetOrAdd("add", "value", "Negotiate");
            providers.GetOrAdd("add", "value", "NTLM");
        });
    }
Exemplo n.º 6
0
        private static void CopyShimToOutput(IISDeploymentParameters parameters)
        {
            parameters.AddServerConfigAction(
                (config, contentRoot) => {
                var moduleNodes = config.DescendantNodesAndSelf()
                                  .OfType <XElement>()
                                  .Where(element =>
                                         element.Name == "add" &&
                                         element.Attribute("name")?.Value.StartsWith("AspNetCoreModule") == true &&
                                         element.Attribute("image") != null);

                var sourceDirectory      = new DirectoryInfo(Path.GetDirectoryName(moduleNodes.First().Attribute("image").Value));
                var destinationDirectory = new DirectoryInfo(Path.Combine(contentRoot, sourceDirectory.Name));
                destinationDirectory.Create();
                foreach (var element in moduleNodes)
                {
                    var imageAttribute   = element.Attribute("image");
                    imageAttribute.Value = imageAttribute.Value.Replace(sourceDirectory.FullName, destinationDirectory.FullName);
                }
                CopyFiles(sourceDirectory, destinationDirectory);
            });
        }