alot more changes
This commit is contained in:
1 parent
23243ddbdc
commit
0ed2935f04
40 files changed
+2889
-115
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package investigation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/netip"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBootstrapServiceFor(t *testing.T) {
|
||||
var b bootstrap
|
||||
err := json.Unmarshal([]byte(`{
|
||||
"services": [
|
||||
[["8.0.0.0/8"], ["https://rdap.example.test/"]],
|
||||
[["2001:db8::/32"], ["https://rdap6.example.test/"]]
|
||||
]
|
||||
}`), &b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, ok := b.serviceFor(netip.MustParseAddr("8.8.8.8")); !ok || got != "https://rdap.example.test/" {
|
||||
t.Fatalf("IPv4 service = %q, %v", got, ok)
|
||||
}
|
||||
if got, ok := b.serviceFor(netip.MustParseAddr("2001:db8::1")); !ok || got != "https://rdap6.example.test/" {
|
||||
t.Fatalf("IPv6 service = %q, %v", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRdapContacts(t *testing.T) {
|
||||
entities := []rdapEntity{
|
||||
{Roles: []string{"registrant"}, VCard: []any{"vcard", []any{[]any{"fn", map[string]any{}, "text", "Example Org"}}}},
|
||||
{Roles: []string{"abuse"}, VCard: []any{"vcard", []any{[]any{"email", map[string]any{}, "text", "abuse@example.test"}}}},
|
||||
}
|
||||
org, email := rdapContacts(entities)
|
||||
if org != "Example Org" || email != "abuse@example.test" {
|
||||
t.Fatalf("contacts = %q, %q", org, email)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user