public async Task MixedIPBindingChecks() { var bindings = new List <BindingInfo> { new BindingInfo { Host = "test.com", IP = "127.0.0.1", Port = 80, Protocol = "http" }, new BindingInfo { Host = "test.com", IP = "[fe80::3c4e:11b7:fe4f:c601%31]", Port = 80, Protocol = "http" }, new BindingInfo { Host = "www.test.com", IP = "127.0.0.1", Port = 80, Protocol = "http" }, new BindingInfo { Host = "www.test.com", IP = "[fe80::3c4e:11b7:fe4f:c601%31]", Port = 80, Protocol = "http" } }; var deployment = new BindingDeploymentManager(); var testManagedCert = new ManagedCertificate { Id = Guid.NewGuid().ToString(), Name = "MixedIPBindings", UseStagingMode = true, RequestConfig = new CertRequestConfig { PrimaryDomain = "test.com", PerformAutomatedCertBinding = true, DeploymentSiteOption = DeploymentOption.Auto, Challenges = new ObservableCollection <CertRequestChallengeConfig> { new CertRequestChallengeConfig { ChallengeType = SupportedChallengeTypes.CHALLENGE_TYPE_DNS, ChallengeProvider = "DNS01.API.Route53", ChallengeCredentialKey = "ABC123" } } }, ItemType = ManagedCertificateType.SSL_LetsEncrypt_LocalIIS }; var mockTarget = new MockBindingDeploymentTarget(); mockTarget.AllBindings = bindings; var results = await deployment.StoreAndDeployManagedCertificate(mockTarget, testManagedCert, "test.pfx", true); Assert.IsTrue(results.Any()); }
public async Task BindingMatchTestsVarious() { /* * Single Site - Default Match * www.test.com * test.com*/ /* * * All Sites(*.test.com) * All Sites(*.test.co.uk) */ var managedCertificate = new ManagedCertificate { Id = Guid.NewGuid().ToString(), Name = "TestSite..", GroupId = "test", UseStagingMode = true, RequestConfig = new CertRequestConfig { PrimaryDomain = "test.com", Challenges = new ObservableCollection <CertRequestChallengeConfig>( new List <CertRequestChallengeConfig> { new CertRequestChallengeConfig { ChallengeType = "dns-01" } }), PerformAutomatedCertBinding = true, WebsiteRootPath = "c:\\inetpub\\wwwroot", DeploymentSiteOption = DeploymentOption.SingleSite }, ItemType = ManagedCertificateType.SSL_LetsEncrypt_LocalIIS }; var bindingManager = new BindingDeploymentManager(); var deploymentTarget = new MockBindingDeploymentTarget(); deploymentTarget.AllBindings = _allSites; managedCertificate.ServerSiteId = "ShouldNotMatch"; var preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsFalse(preview.Any(), " Should not match any bindings"); managedCertificate.ServerSiteId = "1.1"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsFalse(preview.Any(), "Should not match any bindings (same domain, different sudomains no wildcard)"); managedCertificate.ServerSiteId = "1"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsTrue(preview.Count == 1, "Should match one binding"); managedCertificate.ServerSiteId = "1"; managedCertificate.RequestConfig.PrimaryDomain = "*.test.com"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsTrue(preview.Count == 1, "Should match 1 binding (root level domain should be ignored using wildcard)"); managedCertificate.ServerSiteId = "1"; managedCertificate.RequestConfig.DeploymentSiteOption = DeploymentOption.AllSites; managedCertificate.RequestConfig.PrimaryDomain = "test.com"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsTrue(preview.Count == 1, "Should match 1 binding"); managedCertificate.ServerSiteId = "1"; managedCertificate.RequestConfig.DeploymentSiteOption = DeploymentOption.AllSites; managedCertificate.RequestConfig.PrimaryDomain = "*.test.com"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsTrue(preview.Count == 3, "Should match 3 bindings across all sites"); managedCertificate.ServerSiteId = "5"; managedCertificate.RequestConfig.DeploymentSiteOption = DeploymentOption.AllSites; managedCertificate.RequestConfig.PrimaryDomain = "altport.com"; preview = await bindingManager.StoreAndDeployManagedCertificate(deploymentTarget, managedCertificate, null, isPreviewOnly : true); Assert.IsTrue(preview.Count == 2, "Should match 2 bindings across all sites"); Assert.IsTrue(preview.Count(b => b.Category == "Deployment.UpdateBinding" && b.Description.Contains(":9000")) == 1, "Should have 1 port 9000 binding"); Assert.IsTrue(preview.Count(b => b.Category == "Deployment.UpdateBinding" && b.Description.Contains(":9001")) == 1, "Should have 1 port 9001 binding"); foreach (var a in preview) { System.Diagnostics.Debug.WriteLine(a.Description); } }