Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions CERTInext.IntegrationTests/V2ApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public async Task GetProductDetails_V2_ReturnsProducts()

/// <summary>
/// Drives <see cref="CERTInextCAPlugin.ValidateProductInfo"/> (not just the client
/// method) end-to-end in V2 mode against the configured product code. Read-only.
/// method) end-to-end in V2 mode with the configured product code. V2 doesn't check a
/// ProductCode against the catalog, so this passes without any CA product lookup. Read-only.
/// </summary>
[SkippableFact]
public async Task ValidateProductInfo_V2_AcceptsConfiguredProductCode()
Expand All @@ -284,16 +285,18 @@ public async Task ValidateProductInfo_V2_AcceptsConfiguredProductCode()
Func<Task> act = () => plugin.ValidateProductInfo(productInfo, connectionInfo);

await act.Should().NotThrowAsync(
$"ProductCode '{_v2ProductCode}' should be present in the live V2 catalog");
$"a V2 template's ProductCode ('{_v2ProductCode}') is sent as given, not checked at save time");
}

/// <summary>
/// Same as <see cref="ValidateProductInfo_V2_AcceptsConfiguredProductCode"/> but with a
/// product code that should never exist, asserting the same "not found" failure mode
/// V1 has always had. Read-only — no order is placed.
/// product code that doesn't exist on the account. V2 template save doesn't check the code
/// against the catalog (CERTInext rejects a code it can't use when an order is placed), so
/// this is accepted too. V1 still rejects an unknown code at save time. Read-only — no order
/// is placed.
/// </summary>
[SkippableFact]
public async Task ValidateProductInfo_V2_RejectsUnknownProductCode()
public async Task ValidateProductInfo_V2_AcceptsUnknownProductCode_WithoutCatalogCheck()
{
Skip.If(!_v2Enabled, "CERTINEXT_USE_V2_API not set or V2 credentials not configured — skipping.");

Expand All @@ -307,8 +310,8 @@ public async Task ValidateProductInfo_V2_RejectsUnknownProductCode()

Func<Task> act = () => plugin.ValidateProductInfo(productInfo, connectionInfo);

await act.Should().ThrowAsync<AnyCAValidationException>()
.WithMessage("*not found*");
await act.Should().NotThrowAsync(
"V2 template save doesn't check ProductCode against the catalog");
}

/// <summary>
Expand Down
37 changes: 12 additions & 25 deletions CERTInext.IntegrationTests/V2FullLifecycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,14 @@ public async Task Enroll_V2_WildcardDv_WildcardOnly_FullLifecycle(V2PinMode mode

/// <summary>
/// Wildcard+apex CSR shape: CN is the wildcard, SAN dictionary carries BOTH the wildcard
/// and its bare apex domain. The non-UCC V2 SAN guard (CERTInextCAPlugin.cs, EnrollV2Async)
/// explicitly exempts exactly this shape for a wildcard product — the guard computes
/// <c>domain</c> as the literal CN ("*.dcv-test.scrup.org" here), and without the
/// exemption the apex ("dcv-test.scrup.org") would match neither that nor its "www."
/// variant and be treated as a disallowed "extra SAN", even though a wildcard+apex
/// pairing is an extremely common, legitimate certificate shape. The order is therefore
/// expected to be accepted and issued. This test records the actual resulting behavior
/// rather than hard-asserting on it everywhere: if the order is rejected anyway,
/// it asserts the rejection is specifically this guard's (by message content) rather than
/// some unrelated failure; if accepted and issued, it parses the issued leaf (BouncyCastle)
/// and logs — as an observation only, not an assertion — whether the apex is covered by
/// the certificate's own SAN list (CERTInext may or may not add the apex to
/// additionalDomains automatically for a non-UCC wildcard product).
/// Expected sandbox order count: 0 or 1 (0 if CERTInext itself rejects a FAILED result
/// before any order is ever placed — see the FAILED branch below).
/// and its bare apex domain. The plugin doesn't count a wildcard's bare apex as an extra
/// name (EnrollV2Async / FindExtraDnsSans), so this goes out as a single-domain wildcard
/// order with no additionalDomains, and CERTInext decides. This test records the actual
/// resulting behavior rather than hard-asserting on it: if the order ends FAILED it logs
/// the reason; if accepted and issued, it parses the issued leaf (BouncyCastle) and logs —
/// as an observation only, not an assertion — whether the apex is covered by the
/// certificate's own SAN list (CERTInext may or may not add the apex automatically for a
/// wildcard product). Expected sandbox order count: 0 or 1.
/// </summary>
[SkippableTheory]
[V2PinModes]
Expand Down Expand Up @@ -713,20 +706,14 @@ public async Task Enroll_V2_WildcardDv_WildcardPlusApexSan_RecordsActualBehavior
if (enrollResult.Status == (int)EndEntityStatus.FAILED)
{
_output.WriteLine(
"RESULT: wildcard+apex was REJECTED before any CA call — the non-UCC SAN guard's " +
$"wildcard-apex exemption did not cover this case: domain==CN=='{wildcard}', and the " +
$"apex '{apex}' matched neither that nor its 'www.' variant.");
enrollResult.StatusMessage.Should().Contain("SAN",
"a FAILED result here must specifically be the non-UCC multi-SAN guard's rejection " +
"(StatusMessage mentions SAN/domain count), not some unrelated failure masquerading as it");
enrollResult.CARequestID.Should().BeNullOrWhiteSpace(
"the guard rejects before PlaceOrderV2Async — no CARequestID should be minted");
$"RESULT: wildcard+apex order ended FAILED: {enrollResult.StatusMessage}");
orderId = string.IsNullOrWhiteSpace(enrollResult.CARequestID) ? null : enrollResult.CARequestID;
}
else
{
_output.WriteLine(
"RESULT: wildcard+apex was ACCEPTED — the non-UCC single-domain SAN guard's " +
"wildcard-apex exemption allows the bare apex alongside the wildcard CN.");
"RESULT: wildcard+apex was ACCEPTED — the bare apex isn't an extra name for a wildcard " +
"domain, so it went out as a single-domain wildcard order.");
enrollResult.CARequestID.Should().NotBeNullOrWhiteSpace();
orderId = enrollResult.CARequestID;

Expand Down
Loading