@@ -865,13 +865,13 @@ func (msa *mockSAPaused) FinalizeAuthorization2(ctx context.Context, req *sapb.F
865865}
866866
867867func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit (t * testing.T ) {
868- if ! strings .Contains (os .Getenv ("BOULDER_CONFIG_DIR" ), "test/config-next" ) {
869- t .Skip ()
870- }
871-
872868 va , sa , ra , redisSrc , fc , cleanUp := initAuthorities (t )
873869 defer cleanUp ()
874870
871+ if ra .limiter == nil {
872+ t .Skip ("no redis limiter configured" )
873+ }
874+
875875 features .Set (features.Config {AutomaticallyPauseZombieClients : true })
876876 defer features .Reset ()
877877
@@ -988,13 +988,13 @@ func TestPerformValidation_FailedValidationsTriggerPauseIdentifiersRatelimit(t *
988988}
989989
990990func TestPerformValidation_FailedThenSuccessfulValidationResetsPauseIdentifiersRatelimit (t * testing.T ) {
991- if ! strings .Contains (os .Getenv ("BOULDER_CONFIG_DIR" ), "test/config-next" ) {
992- t .Skip ()
993- }
994-
995991 va , sa , ra , redisSrc , fc , cleanUp := initAuthorities (t )
996992 defer cleanUp ()
997993
994+ if ra .limiter == nil {
995+ t .Skip ("no redis limiter configured" )
996+ }
997+
998998 features .Set (features.Config {AutomaticallyPauseZombieClients : true })
999999 defer features .Reset ()
10001000
@@ -1778,6 +1778,74 @@ func TestDeactivateAuthorization(t *testing.T) {
17781778 test .AssertEquals (t , deact .Status , string (core .StatusDeactivated ))
17791779}
17801780
1781+ type mockSARecordingPauses struct {
1782+ sapb.StorageAuthorityClient
1783+ recv * sapb.PauseRequest
1784+ }
1785+
1786+ func (sa * mockSARecordingPauses ) PauseIdentifiers (ctx context.Context , req * sapb.PauseRequest , _ ... grpc.CallOption ) (* sapb.PauseIdentifiersResponse , error ) {
1787+ sa .recv = req
1788+ return & sapb.PauseIdentifiersResponse {Paused : int64 (len (req .Identifiers ))}, nil
1789+ }
1790+
1791+ func (sa * mockSARecordingPauses ) DeactivateAuthorization2 (_ context.Context , _ * sapb.AuthorizationID2 , _ ... grpc.CallOption ) (* emptypb.Empty , error ) {
1792+ return nil , nil
1793+ }
1794+
1795+ func TestDeactivateAuthorization_Pausing (t * testing.T ) {
1796+ _ , _ , ra , _ , _ , cleanUp := initAuthorities (t )
1797+ defer cleanUp ()
1798+
1799+ if ra .limiter == nil {
1800+ t .Skip ("no redis limiter configured" )
1801+ }
1802+
1803+ msa := mockSARecordingPauses {}
1804+ ra .SA = & msa
1805+
1806+ features .Set (features.Config {AutomaticallyPauseZombieClients : true })
1807+ defer features .Reset ()
1808+
1809+ // Override the default ratelimits to only allow one failed validation.
1810+ txnBuilder , err := ratelimits .NewTransactionBuilder ("testdata/one-failed-validation-before-pausing.yml" , "" )
1811+ test .AssertNotError (t , err , "making transaction composer" )
1812+ ra .txnBuilder = txnBuilder
1813+
1814+ // The first deactivation of a pending authz should work and nothing should
1815+ // get paused.
1816+ _ , err = ra .DeactivateAuthorization (ctx , & corepb.Authorization {
1817+ Id : "1" ,
1818+ RegistrationID : 1 ,
1819+ DnsName : "example.com" ,
1820+ Status : string (core .StatusPending ),
1821+ })
1822+ test .AssertNotError (t , err , "mock deactivation should work" )
1823+ test .AssertBoxedNil (t , msa .recv , "shouldn't be a pause request yet" )
1824+
1825+ // Deactivating a valid authz shouldn't increment any limits or pause anything.
1826+ _ , err = ra .DeactivateAuthorization (ctx , & corepb.Authorization {
1827+ Id : "2" ,
1828+ RegistrationID : 1 ,
1829+ DnsName : "example.com" ,
1830+ Status : string (core .StatusValid ),
1831+ })
1832+ test .AssertNotError (t , err , "mock deactivation should work" )
1833+ test .AssertBoxedNil (t , msa .recv , "deactivating valid authz should never pause" )
1834+
1835+ // Deactivating a second pending authz should surpass the limit and result
1836+ // in a pause request.
1837+ _ , err = ra .DeactivateAuthorization (ctx , & corepb.Authorization {
1838+ Id : "3" ,
1839+ RegistrationID : 1 ,
1840+ DnsName : "example.com" ,
1841+ Status : string (core .StatusPending ),
1842+ })
1843+ test .AssertNotError (t , err , "mock deactivation should work" )
1844+ test .AssertNotNil (t , msa .recv , "should have recorded a pause request" )
1845+ test .AssertEquals (t , msa .recv .RegistrationID , int64 (1 ))
1846+ test .AssertEquals (t , msa .recv .Identifiers [0 ].Value , "example.com" )
1847+ }
1848+
17811849func TestDeactivateRegistration (t * testing.T ) {
17821850 _ , _ , ra , _ , _ , cleanUp := initAuthorities (t )
17831851 defer cleanUp ()
0 commit comments