2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2022-09-16 05:08:45 +00:00
|
|
|
|
|
|
|
//go:build !ios && !android && !js
|
|
|
|
|
2022-11-08 05:26:26 +00:00
|
|
|
package ipnlocal
|
2022-09-16 05:08:45 +00:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestValidLookingCertDomain(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
in string
|
|
|
|
want bool
|
|
|
|
}{
|
|
|
|
{"foo.com", true},
|
|
|
|
{"foo..com", false},
|
|
|
|
{"foo/com.com", false},
|
|
|
|
{"NUL", false},
|
|
|
|
{"", false},
|
|
|
|
{"foo\\bar.com", false},
|
|
|
|
{"foo\x00bar.com", false},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
if got := validLookingCertDomain(tt.in); got != tt.want {
|
|
|
|
t.Errorf("validLookingCertDomain(%q) = %v, want %v", tt.in, got, tt.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|