@@ -628,90 +628,6 @@ func TestNewRegistrationBadKey(t *testing.T) {
628628 test .AssertError (t , err , "Should have rejected authorization with short key" )
629629}
630630
631- func TestNewRegistrationRateLimit (t * testing.T ) {
632- _ , _ , ra , _ , cleanUp := initAuthorities (t )
633- defer cleanUp ()
634-
635- // Specify a dummy rate limit policy that allows 1 registration per exact IP
636- // match, and 2 per range.
637- ra .rlPolicies = & dummyRateLimitConfig {
638- RegistrationsPerIPPolicy : ratelimit.RateLimitPolicy {
639- Threshold : 1 ,
640- Window : config.Duration {Duration : 24 * 90 * time .Hour },
641- },
642- RegistrationsPerIPRangePolicy : ratelimit.RateLimitPolicy {
643- Threshold : 2 ,
644- Window : config.Duration {Duration : 24 * 90 * time .Hour },
645- },
646- }
647-
648- // Create one registration for an IPv4 address
649- mailto := "mailto:[email protected] " 650- reg := & corepb.Registration {
651- Contact : []string {mailto },
652- ContactsPresent : true ,
653- Key : newAcctKey (t ),
654- InitialIP : parseAndMarshalIP (t , "7.6.6.5" ),
655- }
656- // There should be no errors - it is within the RegistrationsPerIP rate limit
657- _ , err := ra .NewRegistration (ctx , reg )
658- test .AssertNotError (t , err , "Unexpected error adding new IPv4 registration" )
659- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIP , "decision" : ratelimits .Allowed }, 1 )
660- // There are no overrides for this IP, so the override usage gauge should
661- // contain 0 entries with labels matching it.
662- test .AssertMetricWithLabelsEquals (t , ra .rlOverrideUsageGauge , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIP , "override_key" : "7.6.6.5" }, 0 )
663-
664- // Create another registration for the same IPv4 address by changing the key
665- reg .Key = newAcctKey (t )
666-
667- // There should be an error since a 2nd registration will exceed the
668- // RegistrationsPerIP rate limit
669- _ , err = ra .NewRegistration (ctx , reg )
670- test .AssertError (t , err , "No error adding duplicate IPv4 registration" )
671- test .AssertEquals (t , err .Error (), "too many registrations for this IP: see https://letsencrypt.org/docs/too-many-registrations-for-this-ip/" )
672- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIP , "decision" : ratelimits .Denied }, 1 )
673-
674- // Create a registration for an IPv6 address
675- reg .Key = newAcctKey (t )
676- reg .InitialIP = parseAndMarshalIP (t , "2001:cdba:1234:5678:9101:1121:3257:9652" )
677-
678- // There should be no errors - it is within the RegistrationsPerIP rate limit
679- _ , err = ra .NewRegistration (ctx , reg )
680- test .AssertNotError (t , err , "Unexpected error adding a new IPv6 registration" )
681- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIP , "decision" : ratelimits .Allowed }, 2 )
682-
683- // Create a 2nd registration for the IPv6 address by changing the key
684- reg .Key = newAcctKey (t )
685-
686- // There should be an error since a 2nd reg for the same IPv6 address will
687- // exceed the RegistrationsPerIP rate limit
688- _ , err = ra .NewRegistration (ctx , reg )
689- test .AssertError (t , err , "No error adding duplicate IPv6 registration" )
690- test .AssertEquals (t , err .Error (), "too many registrations for this IP: see https://letsencrypt.org/docs/too-many-registrations-for-this-ip/" )
691- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIP , "decision" : ratelimits .Denied }, 2 )
692-
693- // Create a registration for an IPv6 address in the same /48
694- reg .Key = newAcctKey (t )
695- reg .InitialIP = parseAndMarshalIP (t , "2001:cdba:1234:5678:9101:1121:3257:9653" )
696-
697- // There should be no errors since two IPv6 addresses in the same /48 is
698- // within the RegistrationsPerIPRange limit
699- _ , err = ra .NewRegistration (ctx , reg )
700- test .AssertNotError (t , err , "Unexpected error adding second IPv6 registration in the same /48" )
701- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIPRange , "decision" : ratelimits .Allowed }, 2 )
702-
703- // Create a registration for yet another IPv6 address in the same /48
704- reg .Key = newAcctKey (t )
705- reg .InitialIP = parseAndMarshalIP (t , "2001:cdba:1234:5678:9101:1121:3257:9654" )
706-
707- // There should be an error since three registrations within the same IPv6
708- // /48 is outside of the RegistrationsPerIPRange limit
709- _ , err = ra .NewRegistration (ctx , reg )
710- test .AssertError (t , err , "No error adding a third IPv6 registration in the same /48" )
711- test .AssertEquals (t , err .Error (), "too many registrations for this IP range: see https://letsencrypt.org/docs/rate-limits/" )
712- test .AssertMetricWithLabelsEquals (t , ra .rlCheckLatency , prometheus.Labels {"limit" : ratelimit .RegistrationsPerIPRange , "decision" : ratelimits .Denied }, 1 )
713- }
714-
715631func TestRegistrationsPerIPOverrideUsage (t * testing.T ) {
716632 _ , _ , ra , _ , cleanUp := initAuthorities (t )
717633 defer cleanUp ()
0 commit comments