1 parent
d8867dfc4a
commit
657f4922b4
2 files changed
+100
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"io"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/netip"
|
||||
"net/textproto"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -42,6 +43,27 @@ func TestDialRejectsNonPublicRemoteAddress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainsOnlyBenchmarkAddresses(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
addresses []netip.Addr
|
||||
want bool
|
||||
}{
|
||||
{name: "empty", want: false},
|
||||
{name: "fake IP", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77")}, want: true},
|
||||
{name: "multiple fake IPs", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77"), netip.MustParseAddr("198.19.1.82")}, want: true},
|
||||
{name: "public IP", addresses: []netip.Addr{netip.MustParseAddr("47.251.242.178")}, want: false},
|
||||
{name: "mixed", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77"), netip.MustParseAddr("127.0.0.1")}, want: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := containsOnlyBenchmarkAddresses(tt.addresses); got != tt.want {
|
||||
t.Fatalf("containsOnlyBenchmarkAddresses() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendMailUnsafeRejectsNonLoopbackTargets(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user