@@ -19,9 +19,10 @@ import (
19
19
20
20
func paImpl (t * testing.T ) * AuthorityImpl {
21
21
enabledChallenges := map [core.AcmeChallenge ]bool {
22
- core .ChallengeTypeHTTP01 : true ,
23
- core .ChallengeTypeDNS01 : true ,
24
- core .ChallengeTypeTLSALPN01 : true ,
22
+ core .ChallengeTypeHTTP01 : true ,
23
+ core .ChallengeTypeDNS01 : true ,
24
+ core .ChallengeTypeTLSALPN01 : true ,
25
+ core .ChallengeTypeDNSAccount01 : true ,
25
26
}
26
27
27
28
enabledIdentifiers := map [identifier.IdentifierType ]bool {
@@ -457,56 +458,122 @@ func TestChallengeTypesFor(t *testing.T) {
457
458
t .Parallel ()
458
459
pa := paImpl (t )
459
460
460
- testCases := []struct {
461
- name string
462
- ident identifier.ACMEIdentifier
463
- wantChalls []core.AcmeChallenge
464
- wantErr string
465
- }{
466
- {
467
- name : "dns" ,
468
- ident : identifier .NewDNS ("example.com" ),
469
- wantChalls : []core.AcmeChallenge {
470
- core .ChallengeTypeHTTP01 , core .ChallengeTypeDNS01 , core .ChallengeTypeTLSALPN01 ,
461
+ t .Run ("DNSAccount01Enabled=true" , func (t * testing.T ) {
462
+ features .Set (features.Config {DNSAccount01Enabled : true })
463
+ t .Cleanup (features .Reset )
464
+
465
+ testCases := []struct {
466
+ name string
467
+ ident identifier.ACMEIdentifier
468
+ wantChalls []core.AcmeChallenge
469
+ wantErr string
470
+ }{
471
+ {
472
+ name : "dns" ,
473
+ ident : identifier .NewDNS ("example.com" ),
474
+ wantChalls : []core.AcmeChallenge {
475
+ core .ChallengeTypeHTTP01 ,
476
+ core .ChallengeTypeDNS01 ,
477
+ core .ChallengeTypeTLSALPN01 ,
478
+ core .ChallengeTypeDNSAccount01 ,
479
+ },
471
480
},
472
- },
473
- {
474
- name : "dns wildcard" ,
475
- ident : identifier .NewDNS ("*.example.com" ),
476
- wantChalls : []core.AcmeChallenge {
477
- core .ChallengeTypeDNS01 ,
481
+ {
482
+ name : "dns wildcard" ,
483
+ ident : identifier .NewDNS ("*.example.com" ),
484
+ wantChalls : []core.AcmeChallenge {
485
+ core .ChallengeTypeDNS01 ,
486
+ core .ChallengeTypeDNSAccount01 ,
487
+ },
478
488
},
479
- },
480
- {
481
- name : "ip" ,
482
- ident : identifier . NewIP ( netip . MustParseAddr ( "1.2.3.4" )),
483
- wantChalls : [] core.AcmeChallenge {
484
- core . ChallengeTypeHTTP01 , core . ChallengeTypeTLSALPN01 ,
489
+ {
490
+ name : "ip" ,
491
+ ident : identifier . NewIP ( netip . MustParseAddr ( "1.2.3.4" )) ,
492
+ wantChalls : []core. AcmeChallenge {
493
+ core . ChallengeTypeHTTP01 , core .ChallengeTypeTLSALPN01 ,
494
+ } ,
485
495
},
486
- },
487
- {
488
- name : "invalid" ,
489
- ident : identifier.ACMEIdentifier {Type : "fnord" , Value : "uh-oh, Spaghetti-Os[tm]" },
490
- wantErr : "unrecognized identifier type" ,
491
- },
492
- }
496
+ {
497
+ name : "invalid" ,
498
+ ident : identifier.ACMEIdentifier {Type : "fnord" , Value : "uh-oh, Spaghetti-Os[tm]" },
499
+ wantErr : "unrecognized identifier type" ,
500
+ },
501
+ }
493
502
494
- for _ , tc := range testCases {
495
- t .Run (tc .name , func (t * testing.T ) {
496
- t .Parallel ()
497
- challs , err := pa .ChallengeTypesFor (tc .ident )
503
+ for _ , tc := range testCases {
504
+ tc := tc // Capture range variable
505
+ t .Run (tc .name , func (t * testing.T ) {
506
+ t .Parallel ()
507
+ challs , err := pa .ChallengeTypesFor (tc .ident )
498
508
499
- if len (tc .wantChalls ) != 0 {
500
- test .AssertNotError (t , err , "should have succeeded" )
501
- test .AssertDeepEquals (t , challs , tc .wantChalls )
502
- }
509
+ if len (tc .wantChalls ) != 0 {
510
+ test .AssertNotError (t , err , "should have succeeded" )
511
+ test .AssertDeepEquals (t , challs , tc .wantChalls )
512
+ }
503
513
504
- if tc .wantErr != "" {
505
- test .AssertError (t , err , "should have errored" )
506
- test .AssertContains (t , err .Error (), tc .wantErr )
507
- }
508
- })
509
- }
514
+ if tc .wantErr != "" {
515
+ test .AssertError (t , err , "should have errored" )
516
+ test .AssertContains (t , err .Error (), tc .wantErr )
517
+ }
518
+ })
519
+ }
520
+ })
521
+
522
+ t .Run ("DNSAccount01Enabled=false" , func (t * testing.T ) {
523
+ features .Set (features.Config {DNSAccount01Enabled : false })
524
+ t .Cleanup (features .Reset )
525
+
526
+ testCases := []struct {
527
+ name string
528
+ ident identifier.ACMEIdentifier
529
+ wantChalls []core.AcmeChallenge
530
+ wantErr string
531
+ }{
532
+ {
533
+ name : "dns" ,
534
+ ident : identifier .NewDNS ("example.com" ),
535
+ wantChalls : []core.AcmeChallenge {
536
+ core .ChallengeTypeHTTP01 ,
537
+ core .ChallengeTypeDNS01 ,
538
+ core .ChallengeTypeTLSALPN01 ,
539
+ // DNSAccount01 excluded
540
+ },
541
+ },
542
+ {
543
+ name : "wildcard" ,
544
+ ident : identifier .NewDNS ("*.example.com" ),
545
+ wantChalls : []core.AcmeChallenge {
546
+ core .ChallengeTypeDNS01 ,
547
+ // DNSAccount01 excluded
548
+ },
549
+ },
550
+ {
551
+ name : "ip" ,
552
+ ident : identifier .NewIP (netip .MustParseAddr ("1.2.3.4" )),
553
+ wantChalls : []core.AcmeChallenge {
554
+ core .ChallengeTypeHTTP01 , core .ChallengeTypeTLSALPN01 ,
555
+ },
556
+ },
557
+ }
558
+
559
+ for _ , tc := range testCases {
560
+ tc := tc // Capture range variable
561
+ t .Run (tc .name , func (t * testing.T ) {
562
+ t .Parallel ()
563
+ challs , err := pa .ChallengeTypesFor (tc .ident )
564
+
565
+ if len (tc .wantChalls ) != 0 {
566
+ test .AssertNotError (t , err , "should have succeeded" )
567
+ test .AssertDeepEquals (t , challs , tc .wantChalls )
568
+ }
569
+
570
+ if tc .wantErr != "" {
571
+ test .AssertError (t , err , "should have errored" )
572
+ test .AssertContains (t , err .Error (), tc .wantErr )
573
+ }
574
+ })
575
+ }
576
+ })
510
577
}
511
578
512
579
// TestMalformedExactBlocklist tests that loading a YAML policy file with an
0 commit comments