Skip to content

Commit

Permalink
Tests: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Oct 17, 2024
1 parent 4cc5ca0 commit 81d8342
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CertRequestTests()
PrimaryTestDomain = ConfigSettings["Cloudflare_TestDomain"];

testSiteDomain = "integration1." + PrimaryTestDomain;
testSitePath = _primaryWebRoot;
testSitePath = PrimaryWebRootPath;

_testCredStorageKey = ConfigSettings["TestCredentialsKey_Cloudflare"];

Expand All @@ -69,7 +69,7 @@ public async Task SetupIIS()
await iisManager.DeleteSite(testSiteName);
}

var site = await iisManager.CreateSite(testSiteName, testSiteDomain, _primaryWebRoot, "DefaultAppPool", port: testSiteHttpPort);
var site = await iisManager.CreateSite(testSiteName, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool", port: testSiteHttpPort);
Assert.IsTrue(await iisManager.SiteExists(testSiteName));
_siteId = site.Id.ToString();
}
Expand Down Expand Up @@ -527,7 +527,7 @@ public async Task TestChallengeRequestDNSWildcard()
await iisManager.DeleteSite(testWildcardSiteName);
}

var site = await iisManager.CreateSite(testWildcardSiteName, "test" + testStr + "." + PrimaryTestDomain, _primaryWebRoot, "DefaultAppPool", port: testSiteHttpPort);
var site = await iisManager.CreateSite(testWildcardSiteName, "test" + testStr + "." + PrimaryTestDomain, PrimaryWebRootPath, "DefaultAppPool", port: testSiteHttpPort);

ManagedCertificate managedCertificate = null;
X509Certificate2 certInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task TestCertCleanupAtExpiry()
await iisManager.DeleteSite(testSiteDomain);
}

var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, _primaryWebRoot, "DefaultAppPool");
var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool");

await iisManager.AddOrUpdateSiteBinding(
new Models.BindingInfo
Expand Down Expand Up @@ -92,7 +92,7 @@ public async Task TestCertCleanupByThumbprint()
await iisManager.DeleteSite(testSiteDomain);
}

var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, _primaryWebRoot, "DefaultAppPool");
var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool");

await iisManager.AddOrUpdateSiteBinding(
new Models.BindingInfo
Expand Down Expand Up @@ -156,7 +156,7 @@ public async Task TestCertCleanupFull()
await iisManager.DeleteSite(testSiteDomain);
}

var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, _primaryWebRoot, "DefaultAppPool");
var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool");

await iisManager.AddOrUpdateSiteBinding(
new Models.BindingInfo
Expand Down Expand Up @@ -223,7 +223,7 @@ public async Task TestCertCleanupAfterRenewal()
await iisManager.DeleteSite(testSiteDomain);
}

var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, _primaryWebRoot, "DefaultAppPool");
var site = await iisManager.CreateSite(testSiteDomain, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool");

await iisManager.AddOrUpdateSiteBinding(
new Models.BindingInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task SetupIIS()
await _iisManager.DeleteSite(_testSiteName);
}

var site = await _iisManager.CreateSite(_testSiteName, _testSiteDomain, _primaryWebRoot, "DefaultAppPool", ipAddress: _testSiteIp, port: _testSiteHttpPort);
var site = await _iisManager.CreateSite(_testSiteName, _testSiteDomain, PrimaryWebRootPath, "DefaultAppPool", ipAddress: _testSiteIp, port: _testSiteHttpPort);
Assert.IsTrue(await _iisManager.SiteExists(_testSiteName));
_testSiteId = site.Id.ToString();
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public async Task TestCertifyManagerGetDomainOptionsFromSiteNoDomain()
}

// Add no domain site
var noDomainSite = await _iisManager.CreateSite(noDomainSiteName, "", _primaryWebRoot, "DefaultAppPool", port: 81);
var noDomainSite = await _iisManager.CreateSite(noDomainSiteName, "", PrimaryWebRootPath, "DefaultAppPool", port: 81);
Assert.IsTrue(await _iisManager.SiteExists(_testSiteName), "Expected no domain site to be created");
var noDomainSiteId = noDomainSite.Id.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public DeploymentPreviewTests()
PrimaryTestDomain = ConfigSettings["AWS_TestDomain"];

testSiteDomain = "integration1." + PrimaryTestDomain;
testSitePath = _primaryWebRoot;
testSitePath = PrimaryWebRootPath;

_awsCredStorageKey = ConfigSettings["TestCredentialsKey_Route53"];

Expand All @@ -60,7 +60,7 @@ public async Task SetupIIS()
await iisManager.DeleteSite(testSiteName);
}

var site = await iisManager.CreateSite(testSiteName, testSiteDomain, _primaryWebRoot, "DefaultAppPool", port: testSiteHttpPort);
var site = await iisManager.CreateSite(testSiteName, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool", port: testSiteHttpPort);
Assert.IsTrue(await iisManager.SiteExists(testSiteName));
_siteId = site.Id.ToString();
}
Expand All @@ -85,7 +85,7 @@ public async Task TestPreviewWildcard()
await iisManager.DeleteSite(testPreviewSiteName);
}

var site = await iisManager.CreateSite(testPreviewSiteName, hostname, _primaryWebRoot, "DefaultAppPool", port: testSiteHttpPort);
var site = await iisManager.CreateSite(testPreviewSiteName, hostname, PrimaryWebRootPath, "DefaultAppPool", port: testSiteHttpPort);

ManagedCertificate managedCertificate = null;
X509Certificate2 certInfo = null;
Expand Down Expand Up @@ -166,7 +166,7 @@ public async Task TestPreviewStaticIPBindings()

var ipAddress = GetTestStaticIP();

var site = await iisManager.CreateSite(testPreviewSiteName, hostname, _primaryWebRoot, "DefaultAppPool", "http", ipAddress, testSiteHttpPort);
var site = await iisManager.CreateSite(testPreviewSiteName, hostname, PrimaryWebRootPath, "DefaultAppPool", "http", ipAddress, testSiteHttpPort);

ManagedCertificate managedCertificate = null;
X509Certificate2 certInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ namespace Certify.Core.Tests
{
public class IntegrationTestBase
{
public string PrimaryTestDomain = "test.certifytheweb.com"; // TODO: get this from debug config as it changes per dev machine
public string _primaryWebRoot = @"c:\inetpub\wwwroot\";
public Dictionary<string, string> ConfigSettings = new Dictionary<string, string>();

public string PrimaryTestDomain = "test.certifytheweb.com"; // TODO: get this from debug config as it changes per dev machine
public string PrimaryWebRootPath = @"c:\inetpub\wwwroot\";

private string _testConfigPath = @"c:\temp\Certify\TestConfigSettings.json";

internal ILog _log;

public IntegrationTestBase()
Expand All @@ -23,13 +27,14 @@ public IntegrationTestBase()
PrimaryTestDomain = Environment.GetEnvironmentVariable("CERTIFY_TESTDOMAIN");
}

/* ConfigSettings.Add("AWS_ZoneId", "example");
ConfigSettings.Add("Azure_ZoneId", "example");
ConfigSettings.Add("Cloudflare_ZoneId", "example");
System.IO.File.WriteAllText("C:\\temp\\TestConfigSettings.json", JsonConvert.SerializeObject(ConfigSettings));
*/

ConfigSettings = JsonConvert.DeserializeObject<Dictionary<string, string>>(System.IO.File.ReadAllText("C:\\temp\\Certify\\TestConfigSettings.json"));
if (File.Exists("C:\\temp\\Certify\\TestConfigSettings.json"))
{
ConfigSettings = JsonConvert.DeserializeObject<Dictionary<string, string>>(System.IO.File.ReadAllText(_testConfigPath));
}
else
{
System.Diagnostics.Debug.WriteLine("Test config file not found: " + _testConfigPath);
}

_log = new Loggy(LoggerFactory.Create(builder => builder.AddDebug()).CreateLogger<IntegrationTestBase>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task SetupIIS()
await iisManager.DeleteSite(testSiteName);
}

var site = await iisManager.CreateSite(testSiteName, testSiteDomain, _primaryWebRoot, "DefaultAppPool");
var site = await iisManager.CreateSite(testSiteName, testSiteDomain, PrimaryWebRootPath, "DefaultAppPool");
_siteId = site.Id.ToString();
Assert.IsTrue(await iisManager.SiteExists(testSiteName));
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public async Task TestCreateUnusualBindings()
try
{
// create net.msmq://localhost binding, no port or ip
await iisManager.CreateSite(siteName, "localhost", _primaryWebRoot, null, protocol: "net.msmq", ipAddress: null, port: null);
await iisManager.CreateSite(siteName, "localhost", PrimaryWebRootPath, null, protocol: "net.msmq", ipAddress: null, port: null);

var sites = iisManager.GetSiteBindingList(false);
}
Expand All @@ -134,7 +134,7 @@ public async Task TestCreateFixedIPBindings()
try
{
var ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
var site = await iisManager.CreateSite(testName, testDomainName, _primaryWebRoot, "DefaultAppPool", "http", ipAddress);
var site = await iisManager.CreateSite(testName, testDomainName, PrimaryWebRootPath, "DefaultAppPool", "http", ipAddress);

Assert.IsTrue(await iisManager.SiteExists(testSiteName));

Expand Down Expand Up @@ -165,7 +165,7 @@ public async Task TestManySiteBindingUpdates()
await iisManager.DeleteSite(testSiteName);
}

await iisManager.CreateSite(testSiteName, "site_" + i + "_toomany.com", _primaryWebRoot, null, protocol: "http");
await iisManager.CreateSite(testSiteName, "site_" + i + "_toomany.com", PrimaryWebRootPath, null, protocol: "http");
var site = await iisManager.GetSiteBindingByDomain(domain);
for (var d = 0; d < 2; d++)
{
Expand All @@ -175,7 +175,7 @@ public async Task TestManySiteBindingUpdates()
{
SiteId = site.SiteId,
Host = testDomain,
PhysicalPath = _primaryWebRoot
PhysicalPath = PrimaryWebRootPath
}, addNew: true));
}
}
Expand All @@ -200,7 +200,7 @@ public async Task TestManySiteBindingUpdates()
{
SiteId = site.SiteId,
Host = testDomain,
PhysicalPath = _primaryWebRoot
PhysicalPath = PrimaryWebRootPath
}, addNew: true));
}
else
Expand All @@ -209,7 +209,7 @@ public async Task TestManySiteBindingUpdates()
{
SiteId = site.SiteId,
Host = testDomain,
PhysicalPath = _primaryWebRoot
PhysicalPath = PrimaryWebRootPath
}, addNew: true));
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public async Task TestTooManyBindings()
try
{
// create net.msmq://localhost binding, no port or ip
await iisManager.CreateSite("ManyBindings", "toomany.com", _primaryWebRoot, null, protocol: "http");
await iisManager.CreateSite("ManyBindings", "toomany.com", PrimaryWebRootPath, null, protocol: "http");
var site = await iisManager.GetSiteBindingByDomain("toomany.com");
var domains = new List<string>();
for (var i = 0; i < 101; i++)
Expand All @@ -287,7 +287,7 @@ public async Task TestLongBinding()
await iisManager.DeleteSite(testName);
}

var site = await iisManager.CreateSite(testName, testDomainName, _primaryWebRoot, null);
var site = await iisManager.CreateSite(testName, testDomainName, PrimaryWebRootPath, null);

try
{
Expand Down Expand Up @@ -344,7 +344,7 @@ public async Task TestBindingMatch()
}

// create site with IP all unassigned, no hostname
var site = await iisManager.CreateSite(testBindingSiteName, "", _primaryWebRoot, "DefaultAppPool", port: testSiteHttpPort);
var site = await iisManager.CreateSite(testBindingSiteName, "", PrimaryWebRootPath, "DefaultAppPool", port: testSiteHttpPort);

// add another hostname binding (matching cert and not matching cert)
var testDomains = new List<string> { testSiteDomain, "label1." + testSiteDomain, "nested.label." + testSiteDomain };
Expand Down

0 comments on commit 81d8342

Please sign in to comment.