Files
go-otel/internal/investigation/investigation_test.go
T
mats 0ed2935f04
Build and Publish / Metadata (push) Successful in 8s
Build and Publish / BuildAndDeployAmd64 (push) Failing after 36s
alot more changes
2026-09-21 18:59:13 +02:00

38 lines
1.1 KiB
Go

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)
}
}