Skip to content

Commit 9af0123

Browse files
committed
Add integration test for wildcard DNS-Account-01 authorization reuse
Adds TestDNSAccount01WildcardAuthorizationReuse to verify that wildcard authorizations with DNS-Account-01 challenges can be reused correctly. The test: - Creates a wildcard order with DNS-Account-01 - Completes the challenge to get a valid authorization - Creates a second order for the same wildcard domain - Verifies the same authorization is reused (same URL) - Verifies the authorization is already valid (no re-validation) - Verifies the DNS-Account-01 challenge type is preserved This test fills a gap in Boulder's integration test coverage - no existing Go integration tests verify authorization reuse end-to-end.
1 parent cfc2bd4 commit 9af0123

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

test/integration/dns_account_01_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,93 @@ func TestDNSAccount01WildcardDomain(t *testing.T) {
361361
}
362362
}
363363
}
364+
365+
func TestDNSAccount01WildcardAuthorizationReuse(t *testing.T) {
366+
t.Parallel()
367+
368+
if os.Getenv("BOULDER_CONFIG_DIR") == "test/config" {
369+
t.Skip("Test requires dns-account-01 to be enabled")
370+
}
371+
372+
// Use same domain for both orders to trigger authorization reuse
373+
domain := random_domain()
374+
wildcardDomain := fmt.Sprintf("*.%s", domain)
375+
376+
c, err := makeClient()
377+
if err != nil {
378+
t.Fatalf("creating client: %s", err)
379+
}
380+
381+
idents := []acme.Identifier{{Type: "dns", Value: wildcardDomain}}
382+
383+
// First order: Create and complete DNS-Account-01 challenge
384+
order1, err := c.Client.NewOrder(c.Account, idents)
385+
if err != nil {
386+
t.Fatalf("creating first order: %s", err)
387+
}
388+
389+
authzURL := order1.Authorizations[0]
390+
auth1, err := c.Client.FetchAuthorization(c.Account, authzURL)
391+
if err != nil {
392+
t.Fatalf("fetching first authorization: %s", err)
393+
}
394+
395+
chal, ok := auth1.ChallengeMap[acme.ChallengeTypeDNSAccount01]
396+
if !ok {
397+
t.Fatal("dns-account-01 challenge not offered by server")
398+
}
399+
400+
_, err = testSrvClient.AddDNSAccount01Response(c.Account.URL, domain, chal.KeyAuthorization)
401+
if err != nil {
402+
t.Fatalf("adding DNS response: %s", err)
403+
}
404+
t.Cleanup(func() {
405+
_, _ = testSrvClient.RemoveDNSAccount01Response(c.Account.URL, domain)
406+
})
407+
408+
chal, err = c.Client.UpdateChallenge(c.Account, chal)
409+
if err != nil {
410+
t.Fatalf("updating challenge: %s", err)
411+
}
412+
413+
// Wait for authorization to become valid
414+
auth1, err = c.Client.FetchAuthorization(c.Account, authzURL)
415+
if err != nil {
416+
t.Fatalf("fetching first authorization after challenge update: %s", err)
417+
}
418+
419+
if auth1.Status != "valid" {
420+
t.Fatalf("expected first authorization status to be 'valid', got '%s'", auth1.Status)
421+
}
422+
423+
// Second order: Should reuse the existing authorization
424+
order2, err := c.Client.NewOrder(c.Account, idents)
425+
if err != nil {
426+
t.Fatalf("creating second order: %s", err)
427+
}
428+
429+
if len(order2.Authorizations) != 1 {
430+
t.Fatalf("expected 1 authorization in second order, got %d", len(order2.Authorizations))
431+
}
432+
433+
authzURL2 := order2.Authorizations[0]
434+
auth2, err := c.Client.FetchAuthorization(c.Account, authzURL2)
435+
if err != nil {
436+
t.Fatalf("fetching second authorization: %s", err)
437+
}
438+
439+
// Verify reuse occurred: same authorization URL
440+
if authzURL != authzURL2 {
441+
t.Fatalf("expected same authorization URL, got different: %s != %s", authzURL, authzURL2)
442+
}
443+
444+
// Verify authorization is already valid (no re-validation needed)
445+
if auth2.Status != "valid" {
446+
t.Fatalf("expected reused authorization status to be 'valid', got '%s'", auth2.Status)
447+
}
448+
449+
// Verify authorization still has DNS-Account-01 challenge
450+
if _, ok := auth2.ChallengeMap[acme.ChallengeTypeDNSAccount01]; !ok {
451+
t.Fatal("expected reused authorization to have dns-account-01 challenge")
452+
}
453+
}

0 commit comments

Comments
 (0)