Files
archie/internal/infrastructure/alertwebhook/public_test.go
T

34 lines
662 B
Go

package alertwebhook
import (
"net"
"testing"
)
func TestPublicRefusesInstanceNetworks(t *testing.T) {
tests := []struct {
ip string
want bool
}{
{"8.8.8.8", true},
{"2606:4700:4700::1111", true},
{"127.0.0.1", false},
{"::1", false},
{"10.0.0.5", false},
{"192.168.1.10", false},
{"169.254.169.254", false},
{"100.64.0.1", false},
{"0.0.0.0", false},
{"198.19.0.1", false},
{"192.0.0.8", false},
{"64:ff9b::a00:1", false},
}
for _, tt := range tests {
t.Run(tt.ip, func(t *testing.T) {
if got := public(net.ParseIP(tt.ip)); got != tt.want {
t.Fatalf("public(%s) = %v, want %v", tt.ip, got, tt.want)
}
})
}
}