forked from letsencrypt/boulder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities_test.go
27 lines (19 loc) · 1.02 KB
/
utilities_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package ratelimits
import (
"testing"
"github.com/letsencrypt/boulder/test"
)
func TestFQDNsToETLDsPlusOne(t *testing.T) {
domains := FQDNsToETLDsPlusOne([]string{})
test.AssertEquals(t, len(domains), 0)
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com"})
test.AssertDeepEquals(t, domains, []string{"example.com"})
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com", "www.example.co.uk"})
test.AssertDeepEquals(t, domains, []string{"example.co.uk", "example.com"})
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com", "www.example.co.uk", "co.uk"})
test.AssertDeepEquals(t, domains, []string{"co.uk", "example.co.uk", "example.com"})
domains = FQDNsToETLDsPlusOne([]string{"foo.bar.baz.www.example.com", "baz.example.com"})
test.AssertDeepEquals(t, domains, []string{"example.com"})
domains = FQDNsToETLDsPlusOne([]string{"github.io", "foo.github.io", "bar.github.io"})
test.AssertDeepEquals(t, domains, []string{"bar.github.io", "foo.github.io", "github.io"})
}