Skip to content

Commit 1c345a9

Browse files
committed
test: Add dns-account-01 challenge test case to TestGetValidAuthorizations2
Extends the existing TestGetValidAuthorizations2 function to verify that authorizations with dns-account-01 challenges can be properly stored in and retrieved from the database.
1 parent 3f21384 commit 1c345a9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

sa/sa_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,35 @@ func TestGetValidAuthorizations2(t *testing.T) {
26392639
aaa = am.ID
26402640
}
26412641

2642+
var dac int64
2643+
{
2644+
tokenStr := core.NewToken()
2645+
token, err := base64.RawURLEncoding.DecodeString(tokenStr)
2646+
test.AssertNotError(t, err, "computing test authorization challenge token")
2647+
2648+
profile := "test"
2649+
attempted := challTypeToUint[string(core.ChallengeTypeDNSAccount01)]
2650+
attemptedAt := fc.Now()
2651+
vr, _ := json.Marshal([]core.ValidationRecord{})
2652+
2653+
am := authzModel{
2654+
IdentifierType: identifierTypeToUint[string(identifier.TypeDNS)],
2655+
IdentifierValue: "aaa",
2656+
RegistrationID: 3,
2657+
CertificateProfileName: &profile,
2658+
Status: statusToUint[core.StatusValid],
2659+
Expires: fc.Now().Add(24 * time.Hour),
2660+
Challenges: 1 << challTypeToUint[string(core.ChallengeTypeDNSAccount01)],
2661+
Attempted: &attempted,
2662+
AttemptedAt: &attemptedAt,
2663+
Token: token,
2664+
ValidationError: nil,
2665+
ValidationRecord: vr,
2666+
}
2667+
err = sa.dbMap.Insert(context.Background(), &am)
2668+
test.AssertNotError(t, err, "failed to insert valid authz with dns-account-01")
2669+
dac = am.ID
2670+
}
26422671
for _, tc := range []struct {
26432672
name string
26442673
regID int64
@@ -2655,6 +2684,14 @@ func TestGetValidAuthorizations2(t *testing.T) {
26552684
validUntil: fc.Now().Add(time.Hour),
26562685
wantIDs: []int64{aaa},
26572686
},
2687+
{
2688+
name: "happy path, dns-account-01 challenge",
2689+
regID: 3,
2690+
identifiers: []*corepb.Identifier{identifier.NewDNS("aaa").ToProto()},
2691+
profile: "test",
2692+
validUntil: fc.Now().Add(time.Hour),
2693+
wantIDs: []int64{dac},
2694+
},
26582695
{
26592696
name: "different identifier type",
26602697
regID: 1,

0 commit comments

Comments
 (0)