Skip to content

Commit 4fc2078

Browse files
ACME Account test cleanup
1 parent 18294cd commit 4fc2078

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/Certify.Tests/Certify.Core.Tests.Unit/Tests/CertifyManagerAccountTests.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task TestInit()
5757

5858
await AddCustomCa();
5959
await AddNewCustomCaAccount();
60-
await CheckForExistingLeAccount();
60+
await CheckForExistingAcmeAccount();
6161
}
6262

6363
[TestCleanup]
@@ -146,7 +146,7 @@ private static async Task BootstrapStepCa()
146146
}
147147
}
148148

149-
// Run bootstrap command
149+
// Run bootstrap command: requires step-cli to be installed on the host machine and in the system path
150150
var args = $"ca bootstrap -f --ca-url https://{_caDomain}:{_caPort} --fingerprint {stepCaFingerprint}";
151151
RunCommand("step", args, "Bootstrap Step CA Script", 1000 * 30);
152152
}
@@ -377,17 +377,15 @@ private async Task AddNewCustomCaAccount()
377377
}
378378
}
379379

380-
private async Task CheckForExistingLeAccount()
380+
private async Task CheckForExistingAcmeAccount()
381381
{
382-
if ((await _certifyManager.GetAccountRegistrations()).Find(a => a.CertificateAuthorityId == "letsencrypt.org") == null)
382+
if ((await _certifyManager.GetAccountRegistrations()).Find(a => a.CertificateAuthorityId == _customCa.Id) == null)
383383
{
384384
var contactRegistration = new ContactRegistration
385385
{
386386
AgreedToTermsAndConditions = true,
387-
CertificateAuthorityId = "letsencrypt.org",
387+
CertificateAuthorityId = _customCa.Id,
388388
EmailAddress = "admin." + Guid.NewGuid().ToString().Substring(0, 6) + "@test.com",
389-
ImportedAccountKey = "",
390-
ImportedAccountURI = "",
391389
IsStaging = true
392390
};
393391

@@ -464,7 +462,7 @@ public async Task TestCertifyManagerGetAccountDetailsNoMatches()
464462
[TestMethod, Description("Test for using CertifyManager.GetAccountDetails() when it is a resume order")]
465463
public async Task TestCertifyManagerGetAccountDetailsIsResumeOrder()
466464
{
467-
var dummyManagedCert = (new ManagedCertificate { UseStagingMode = true, CertificateAuthorityId = "letsencrypt.org", LastAttemptedCA = "zerossl.com" });
465+
var dummyManagedCert = (new ManagedCertificate { UseStagingMode = true, CertificateAuthorityId = _customCa.Id, LastAttemptedCA = "zerossl.com" });
468466
var caAccount = await _certifyManager.GetAccountDetails(dummyManagedCert, true, false, true);
469467
Assert.IsNotNull(caAccount, "Expected result of CertifyManager.GetAccountDetails() to not be null");
470468
}
@@ -879,10 +877,8 @@ public async Task TestCertifyManagerChangeAccountKey()
879877
var contactRegistration = new ContactRegistration
880878
{
881879
AgreedToTermsAndConditions = true,
882-
CertificateAuthorityId = "letsencrypt.org",
880+
CertificateAuthorityId = StandardCertAuthorities.LETS_ENCRYPT,
883881
EmailAddress = contactRegEmail,
884-
ImportedAccountKey = "",
885-
ImportedAccountURI = "",
886882
IsStaging = true
887883
};
888884

@@ -914,10 +910,8 @@ public async Task TestCertifyManagerChangeAccountKeyNull()
914910
var contactRegistration = new ContactRegistration
915911
{
916912
AgreedToTermsAndConditions = true,
917-
CertificateAuthorityId = "letsencrypt.org",
913+
CertificateAuthorityId = StandardCertAuthorities.LETS_ENCRYPT,
918914
EmailAddress = contactRegEmail,
919-
ImportedAccountKey = "",
920-
ImportedAccountURI = "",
921915
IsStaging = true
922916
};
923917

@@ -1107,11 +1101,13 @@ public async Task TestCertifyManagerUpdateCertificateAuthorityUpdate()
11071101
public async Task TestCertifyManagerUpdateCertificateAuthorityDefaultCa()
11081102
{
11091103
var certificateAuthorities = await _certifyManager.GetCertificateAuthorities();
1110-
var defaultCa = certificateAuthorities.First();
1104+
1105+
// find a built in CA we will try to update
1106+
var defaultCa = certificateAuthorities.First(ca => ca.IsCustom == false);
11111107
var newCustomCa = new CertificateAuthority
11121108
{
11131109
Id = defaultCa.Id,
1114-
Title = "Test Custom CA",
1110+
Title = "Test CA Update",
11151111
IsCustom = true,
11161112
IsEnabled = true,
11171113
AllowInternalHostnames = false,

0 commit comments

Comments
 (0)