-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdashboard_test.go
More file actions
36 lines (33 loc) · 1007 Bytes
/
dashboard_test.go
File metadata and controls
36 lines (33 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import "testing"
func TestNormalizeAndValidateCNAMETarget(t *testing.T) {
tests := []struct {
name string
target string
want string
wantErr bool
}{
{name: "adds trailing dot", target: "_abc.sectigo.com", want: "_abc.sectigo.com."},
{name: "keeps trailing dot", target: "_abc.sectigo.com.", want: "_abc.sectigo.com."},
{name: "normalizes case and whitespace", target: " _AbC.AcM-Validations.AWS ", want: "_abc.acm-validations.aws."},
{name: "rejects non-authorized domain", target: "example.com", wantErr: true},
{name: "rejects invalid name", target: "not a domain", wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := normalizeAndValidateCNAMETarget(tt.target)
if tt.wantErr {
if err == nil {
t.Fatalf("expected error, got nil")
}
return
}
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if got != tt.want {
t.Fatalf("got %q, want %q", got, tt.want)
}
})
}
}