Skip to content

Commit e8ee04a

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 9f37a49 commit e8ee04a

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
@@ -2650,6 +2650,35 @@ func TestGetValidAuthorizations2(t *testing.T) {
26502650
aaa = am.ID
26512651
}
26522652

2653+
var dac int64
2654+
{
2655+
tokenStr := core.NewToken()
2656+
token, err := base64.RawURLEncoding.DecodeString(tokenStr)
2657+
test.AssertNotError(t, err, "computing test authorization challenge token")
2658+
2659+
profile := "test"
2660+
attempted := challTypeToUint[string(core.ChallengeTypeDNSAccount01)]
2661+
attemptedAt := fc.Now()
2662+
vr, _ := json.Marshal([]core.ValidationRecord{})
2663+
2664+
am := authzModel{
2665+
IdentifierType: identifierTypeToUint[string(identifier.TypeDNS)],
2666+
IdentifierValue: "aaa",
2667+
RegistrationID: 3,
2668+
CertificateProfileName: &profile,
2669+
Status: statusToUint[core.StatusValid],
2670+
Expires: fc.Now().Add(24 * time.Hour),
2671+
Challenges: 1 << challTypeToUint[string(core.ChallengeTypeDNSAccount01)],
2672+
Attempted: &attempted,
2673+
AttemptedAt: &attemptedAt,
2674+
Token: token,
2675+
ValidationError: nil,
2676+
ValidationRecord: vr,
2677+
}
2678+
err = sa.dbMap.Insert(context.Background(), &am)
2679+
test.AssertNotError(t, err, "failed to insert valid authz with dns-account-01")
2680+
dac = am.ID
2681+
}
26532682
for _, tc := range []struct {
26542683
name string
26552684
regID int64
@@ -2666,6 +2695,14 @@ func TestGetValidAuthorizations2(t *testing.T) {
26662695
validUntil: fc.Now().Add(time.Hour),
26672696
wantIDs: []int64{aaa},
26682697
},
2698+
{
2699+
name: "happy path, dns-account-01 challenge",
2700+
regID: 3,
2701+
identifiers: []*corepb.Identifier{identifier.NewDNS("aaa").ToProto()},
2702+
profile: "test",
2703+
validUntil: fc.Now().Add(time.Hour),
2704+
wantIDs: []int64{dac},
2705+
},
26692706
{
26702707
name: "different identifier type",
26712708
regID: 1,

0 commit comments

Comments
 (0)