Skip to content

Commit

Permalink
- Squash previous commits for rebase.
Browse files Browse the repository at this point in the history
- Add validated timestamp test to SA
- Add validated timestamp test to RA
  • Loading branch information
andygabby committed Mar 2, 2021
1 parent 16a30be commit fede924
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 11 additions & 3 deletions ra/ra_test.go
Expand Up @@ -924,7 +924,7 @@ func TestPerformValidationAlreadyValid(t *testing.T) {
}

func TestPerformValidationSuccess(t *testing.T) {
va, sa, ra, _, cleanUp := initAuthorities(t)
va, sa, ra, fc, cleanUp := initAuthorities(t)
defer cleanUp()

// We know this is OK because of TestNewAuthorization
Expand Down Expand Up @@ -982,12 +982,16 @@ func TestPerformValidationSuccess(t *testing.T) {

// The DB authz's expiry should be equal to the current time plus the
// configured authorization lifetime
expectedExpires := ra.clk.Now().Add(ra.authorizationLifetime)
expectedExpires := fc.Now().Add(ra.authorizationLifetime)
test.AssertEquals(t, *dbAuthz.Expires, expectedExpires)

// Check that validated timestamp was recorded, stored, and retrieved
expectedValidated := fc.Now()
test.Assert(t, *dbAuthz.Challenges[challIdx].Validated == expectedValidated, "Validated timestamp incorrect or missing")
}

func TestPerformValidationVAError(t *testing.T) {
va, sa, ra, _, cleanUp := initAuthorities(t)
va, sa, ra, fc, cleanUp := initAuthorities(t)
defer cleanUp()

authz, err := ra.NewAuthorization(ctx, AuthzRequest, Registration.ID)
Expand Down Expand Up @@ -1032,6 +1036,10 @@ func TestPerformValidationVAError(t *testing.T) {
test.Assert(t, dbAuthz.Challenges[challIdx].Status == core.StatusInvalid, "challenge was not marked as invalid")
test.AssertContains(t, dbAuthz.Challenges[challIdx].Error.Error(), "Could not communicate with VA")
test.Assert(t, dbAuthz.Challenges[challIdx].ValidationRecord == nil, "challenge had a ValidationRecord")

// Check that validated timestamp was recorded, stored, and retrieved
expectedValidated := fc.Now()
test.Assert(t, *dbAuthz.Challenges[challIdx].Validated == expectedValidated, "Validated timestamp incorrect or missing")
}

func TestCertificateKeyNotEqualAccountKey(t *testing.T) {
Expand Down
11 changes: 8 additions & 3 deletions sa/sa_test.go
Expand Up @@ -1870,7 +1870,10 @@ func TestFinalizeAuthorization2(t *testing.T) {
ids, err := sa.NewAuthorizations2(context.Background(), &sapb.AddPendingAuthorizationsRequest{Authz: []*corepb.Authorization{apb}})
test.AssertNotError(t, err, "sa.NewAuthorization failed")

fc.Set(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC))
expires = fc.Now().Add(time.Hour * 2).UTC().UnixNano()
attemptedAt := fc.Now().UnixNano()

ip, _ := net.ParseIP("1.1.1.1").MarshalText()
err = sa.FinalizeAuthorization2(context.Background(), &sapb.FinalizeAuthorizationRequest{
Id: ids.Ids[0],
Expand All @@ -1882,9 +1885,10 @@ func TestFinalizeAuthorization2(t *testing.T) {
AddressUsed: ip,
},
},
Status: string(core.StatusValid),
Expires: expires,
Attempted: string(core.ChallengeTypeDNS01),
Status: string(core.StatusValid),
Expires: expires,
Attempted: string(core.ChallengeTypeDNS01),
AttemptedAt: attemptedAt,
})
test.AssertNotError(t, err, "sa.FinalizeAuthorization2 failed")

Expand All @@ -1894,6 +1898,7 @@ func TestFinalizeAuthorization2(t *testing.T) {
test.AssertEquals(t, time.Unix(0, dbVer.Expires).UTC(), fc.Now().Add(time.Hour*2).UTC())
test.AssertEquals(t, dbVer.Challenges[0].Status, string(core.StatusValid))
test.AssertEquals(t, len(dbVer.Challenges[0].Validationrecords), 1)
test.AssertEquals(t, time.Unix(0, dbVer.Challenges[0].Validated).UTC(), fc.Now().UTC())

apb2 := &corepb.Authorization{
Identifier: "aaa",
Expand Down

0 comments on commit fede924

Please sign in to comment.