|
71 | 71 | SupportedChallenges = map[string]bool{ |
72 | 72 | core.ChallengeTypeHTTP01: true, |
73 | 73 | core.ChallengeTypeTLSSNI01: true, |
| 74 | + core.ChallengeTypeDNS01: true, |
74 | 75 | } |
75 | 76 |
|
76 | 77 | // These values we simulate from the client |
@@ -622,6 +623,7 @@ func TestReuseValidAuthorization(t *testing.T) { |
622 | 623 | exp := ra.clk.Now().Add(365 * 24 * time.Hour) |
623 | 624 | finalAuthz.Expires = &exp |
624 | 625 | finalAuthz.Challenges[0].Status = "valid" |
| 626 | + finalAuthz.Challenges[0].Type = core.ChallengeTypeHTTP01 |
625 | 627 | finalAuthz.RegistrationID = Registration.ID |
626 | 628 | finalAuthz, err := sa.NewPendingAuthorization(ctx, finalAuthz) |
627 | 629 | test.AssertNotError(t, err, "Could not store test pending authorization") |
@@ -668,6 +670,21 @@ func TestReuseValidAuthorization(t *testing.T) { |
668 | 670 | test.AssertNotError(t, err, "UpdateAuthorization on secondAuthz sni failed") |
669 | 671 | test.AssertEquals(t, finalAuthz.ID, secondAuthz.ID) |
670 | 672 | test.AssertEquals(t, secondAuthz.Status, core.StatusValid) |
| 673 | + |
| 674 | + // Test that a valid authorization that used a challenge which has been disabled |
| 675 | + // is not reused |
| 676 | + pa, err := policy.New(map[string]bool{ |
| 677 | + core.ChallengeTypeHTTP01: false, |
| 678 | + core.ChallengeTypeTLSSNI01: true, |
| 679 | + core.ChallengeTypeDNS01: true, |
| 680 | + }) |
| 681 | + test.AssertNotError(t, err, "Couldn't create PA") |
| 682 | + err = pa.SetHostnamePolicyFile("../test/hostname-policy.json") |
| 683 | + test.AssertNotError(t, err, "Couldn't set hostname policy") |
| 684 | + ra.PA = pa |
| 685 | + newAuthz, err := ra.NewAuthorization(ctx, AuthzRequest, Registration.ID) |
| 686 | + test.AssertNotError(t, err, "NewAuthorization for secondAuthz failed") |
| 687 | + test.Assert(t, finalAuthz.ID != newAuthz.ID, "NewAuthorization reused a valid authz with a disabled challenge type") |
671 | 688 | } |
672 | 689 |
|
673 | 690 | func TestReusePendingAuthorization(t *testing.T) { |
@@ -902,7 +919,7 @@ func TestUpdateAuthorizationAlreadyValid(t *testing.T) { |
902 | 919 |
|
903 | 920 | response, err := makeResponse(finalAuthz.Challenges[ResponseIndex]) |
904 | 921 | test.AssertNotError(t, err, "Unable to construct response to challenge") |
905 | | - finalAuthz.Challenges[ResponseIndex].Type = core.ChallengeTypeDNS01 |
| 922 | + finalAuthz.Challenges[ResponseIndex].Type = core.ChallengeTypeHTTP01 |
906 | 923 | finalAuthz.Challenges[ResponseIndex].Status = core.StatusPending |
907 | 924 | va.RecordsReturn = []core.ValidationRecord{ |
908 | 925 | {Hostname: "example.com"}} |
@@ -2909,6 +2926,33 @@ func TestDisabledChallengeValidAuthz(t *testing.T) { |
2909 | 2926 | test.AssertNotError(t, err, "RA prevented use of an authorization which used an enabled challenge type") |
2910 | 2927 | } |
2911 | 2928 |
|
| 2929 | +func TestValidChallengeStillGood(t *testing.T) { |
| 2930 | + _, _, ra, _, cleanUp := initAuthorities(t) |
| 2931 | + defer cleanUp() |
| 2932 | + pa, err := policy.New(map[string]bool{ |
| 2933 | + core.ChallengeTypeTLSSNI01: true, |
| 2934 | + }) |
| 2935 | + test.AssertNotError(t, err, "Couldn't create PA") |
| 2936 | + ra.PA = pa |
| 2937 | + |
| 2938 | + test.Assert(t, !ra.validChallengeStillGood(&core.Authorization{}), "ra.validChallengeStillGood didn't fail with empty authorization") |
| 2939 | + test.Assert(t, !ra.validChallengeStillGood(&core.Authorization{Challenges: []core.Challenge{{Status: core.StatusPending}}}), "ra.validChallengeStillGood didn't fail with no valid challenges") |
| 2940 | + test.Assert(t, !ra.validChallengeStillGood(&core.Authorization{Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeHTTP01}}}), "ra.validChallengeStillGood didn't fail with disabled challenge") |
| 2941 | + |
| 2942 | + test.Assert(t, ra.validChallengeStillGood(&core.Authorization{Challenges: []core.Challenge{{Status: core.StatusValid, Type: core.ChallengeTypeTLSSNI01}}}), "ra.validChallengeStillGood failed with enabled challenge") |
| 2943 | +} |
| 2944 | + |
| 2945 | +func TestUpdateAuthorizationBadChallengeType(t *testing.T) { |
| 2946 | + _, _, ra, _, cleanUp := initAuthorities(t) |
| 2947 | + defer cleanUp() |
| 2948 | + pa, err := policy.New(map[string]bool{}) |
| 2949 | + test.AssertNotError(t, err, "Couldn't create PA") |
| 2950 | + ra.PA = pa |
| 2951 | + |
| 2952 | + _, err = ra.UpdateAuthorization(context.Background(), core.Authorization{}, 0, core.Challenge{}) |
| 2953 | + test.AssertError(t, err, "ra.UpdateAuthorization allowed a update to a authorization") |
| 2954 | +} |
| 2955 | + |
2912 | 2956 | var CAkeyPEM = ` |
2913 | 2957 | -----BEGIN RSA PRIVATE KEY----- |
2914 | 2958 | MIIJKQIBAAKCAgEAqmM0dEf/J9MCk2ItzevL0dKJ84lVUtf/vQ7AXFi492vFXc3b |
|
0 commit comments