Skip to content

Commit

Permalink
Address next round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pgporada committed Nov 8, 2024
1 parent 2e65dc3 commit 4c7be8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
4 changes: 2 additions & 2 deletions features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type Config struct {
// AutomaticallyPauseZombieClients configures the RA to automatically track
// limiter to be the authoritative source of rate limiting information for
// automatically pausing clients who systemically fail every validation
// attempt. When disabled, only manually paused identifier:accountID:domain
// pairs will be rejected.
// attempt. When disabled, only manually paused accountID:identifier pairs
// will be rejected.
AutomaticallyPauseZombieClients bool

// IncrementRateLimits uses Redis' IncrBy, instead of Set, for rate limit
Expand Down
39 changes: 10 additions & 29 deletions ra/ra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,20 +957,15 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *
})
test.AssertNotError(t, err, "PerformValidation failed")

var vaRequest *vapb.PerformValidationRequest
select {
case r := <-va.performValidationRequest:
vaRequest = r
_ = r
case <-time.After(time.Second):
t.Fatal("Timed out waiting for DummyValidationAuthority.PerformValidation to complete")
}

// Verify that the VA got the request, and it's the same as the others
test.AssertEquals(t, authzPB.Challenges[challIdx].Type, vaRequest.Challenge.Type)
test.AssertEquals(t, authzPB.Challenges[challIdx].Token, vaRequest.Challenge.Token)

// Sleep so the RA has a chance to write to the SA
time.Sleep(200 * time.Millisecond)
time.Sleep(100 * time.Millisecond)

got, err := ra.SA.GetPausedIdentifiers(ctx, &sapb.RegistrationID{Id: authzPB.RegistrationID}, nil)
test.AssertError(t, err, "Should not have any paused identifiers yet, but found some")
Expand All @@ -981,7 +976,7 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *
bucketKey, err := ratelimits.NewRegIdDomainBucketKey(ratelimits.FailedAuthorizationsForPausingPerDomainPerAccount, authzPB.RegistrationID, domain)
test.AssertNotError(t, err, "Should have been able to construct bucket key, but could not")

// Verify that a redis entry exists for this identifier:accountID:domain
// Verify that a redis entry exists for this accountID:identifier.
tat, err := redisSrc.Get(ctx, bucketKey)
test.AssertNotError(t, err, "Should not have errored, but did")

Expand Down Expand Up @@ -1017,17 +1012,13 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *

select {
case r := <-va.performValidationRequest:
vaRequest = r
_ = r
case <-time.After(time.Second):
t.Fatal("Timed out waiting for DummyValidationAuthority.PerformValidation to complete")
}

// Verify that the VA got the request, and it's the same as the others.
test.AssertEquals(t, authzPB.Challenges[challIdx].Type, vaRequest.Challenge.Type)
test.AssertEquals(t, authzPB.Challenges[challIdx].Token, vaRequest.Challenge.Token)

// Sleep so the RA has a chance to write to the SA
time.Sleep(200 * time.Millisecond)
time.Sleep(100 * time.Millisecond)

// Ensure the identifier:account:domain we expect to be paused actually is.
got, err = ra.SA.GetPausedIdentifiers(ctx, &sapb.RegistrationID{Id: authzPB.RegistrationID}, nil)
Expand All @@ -1051,7 +1042,6 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR
features.Set(features.Config{AutomaticallyPauseZombieClients: true})
defer features.Reset()

//originalSA := sa
mockSA := newMockSAPaused(sa)
ra.SA = mockSA

Expand Down Expand Up @@ -1090,18 +1080,13 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR
})
test.AssertNotError(t, err, "PerformValidation failed")

var vaRequest *vapb.PerformValidationRequest
select {
case r := <-va.performValidationRequest:
vaRequest = r
_ = r
case <-time.After(time.Second):
t.Fatal("Timed out waiting for DummyValidationAuthority.PerformValidation to complete")
}

// Verify that the VA got the request, and it's the same as the others
test.AssertEquals(t, authzPB.Challenges[challIdx].Type, vaRequest.Challenge.Type)
test.AssertEquals(t, authzPB.Challenges[challIdx].Token, vaRequest.Challenge.Token)

// Sleep so the RA has a chance to write to the SA
time.Sleep(100 * time.Millisecond)

Expand All @@ -1114,7 +1099,7 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR
bucketKey, err := ratelimits.NewRegIdDomainBucketKey(ratelimits.FailedAuthorizationsForPausingPerDomainPerAccount, authzPB.RegistrationID, domain)
test.AssertNotError(t, err, "Should have been able to construct bucket key, but could not")

// Verify that a redis entry exists for this identifier:accountID:domain
// Verify that a redis entry exists for this accountID:identifier
tat, err := redisSrc.Get(ctx, bucketKey)
test.AssertNotError(t, err, "Should not have errored, but did")

Expand Down Expand Up @@ -1153,22 +1138,18 @@ func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersR

select {
case r := <-va.performValidationRequest:
vaRequest = r
_ = r
case <-time.After(time.Second):
t.Fatal("Timed out waiting for DummyValidationAuthority.PerformValidation to complete")
}

// Verify that the VA got the request, and it's the same as the others
test.AssertEquals(t, authzPB.Challenges[challIdx].Type, vaRequest.Challenge.Type)
test.AssertEquals(t, authzPB.Challenges[challIdx].Token, vaRequest.Challenge.Token)

// We need the bucket key to scan for in Redis
bucketKey, err = ratelimits.NewRegIdDomainBucketKey(ratelimits.FailedAuthorizationsForPausingPerDomainPerAccount, authzPB.RegistrationID, domain)
test.AssertNotError(t, err, "Should have been able to construct bucket key, but could not")

// Verify that the bucket no longer exists (because the limiter reset has
// deleted it). This indicates the identifier:accountID:domain bucket has
// regained capacity avoiding being inadvertently paused.
// deleted it). This indicates the accountID:identifier bucket has regained
// capacity avoiding being inadvertently paused.
_, err = redisSrc.Get(ctx, bucketKey)
test.AssertErrorIs(t, err, ratelimits.ErrBucketNotFound)

Expand Down

0 comments on commit 4c7be8c

Please sign in to comment.