Add support for redirect https to https when from-to-www-redirect is defined

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-01-09 00:33:16 -03:00
parent 35f5a6ce1f
commit a3bcbeb3d2
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
6 changed files with 196 additions and 31 deletions

View file

@ -205,3 +205,39 @@ func newCA(name string) (*keyPair, error) {
Cert: cert,
}, nil
}
func TestIsValidHostname(t *testing.T) {
cases := map[string]struct {
Hostname string
CN []string
Valid bool
}{
"when there is no common names": {
"foo.bar",
[]string{},
false,
},
"when there is a match for foo.bar": {
"foo.bar",
[]string{"foo.bar"},
true,
},
"when there is a wildcard match for foo.bar": {
"foo.bar",
[]string{"*.bar"},
true,
},
"when there is a wrong wildcard for *.bar": {
"invalid.foo.bar",
[]string{"*.bar"},
false,
},
}
for k, tc := range cases {
valid := IsValidHostname(tc.Hostname, tc.CN)
if valid != tc.Valid {
t.Errorf("%s: expected '%v' but returned %v", k, tc.Valid, valid)
}
}
}