2024-01-02 17:23:46 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
const (
|
|
|
|
pagesDomain = "pages.local"
|
|
|
|
pagesDomainWildcard = "*.pages.local"
|
|
|
|
)
|
|
|
|
|
|
|
|
func equals(a, b []string) bool {
|
|
|
|
if len(a) != len(b) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, _ := range a {
|
|
|
|
if a[i] != b[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-06 14:09:36 +00:00
|
|
|
// TODO: We can only do this once we can do DNS01 for wildcard certificates.
|
|
|
|
/*func TestDomainListBare(t *testing.T) {
|
2024-01-02 17:23:46 +00:00
|
|
|
expect := []string{pagesDomain, pagesDomainWildcard}
|
|
|
|
res := buildDomainList(pagesDomain, pagesDomain)
|
|
|
|
if !equals(res, expect) {
|
|
|
|
t.Fatalf("%v != %v", res, expect)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDomainListSubdomain(t *testing.T) {
|
|
|
|
expect := []string{pagesDomain, pagesDomainWildcard}
|
|
|
|
res := buildDomainList("user."+pagesDomain, pagesDomain)
|
|
|
|
if !equals(res, expect) {
|
|
|
|
t.Fatalf("%v != %v", res, expect)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDomainListCNAME(t *testing.T) {
|
|
|
|
expect := []string{"testdomain.example"}
|
|
|
|
res := buildDomainList("testdomain.example", pagesDomain)
|
|
|
|
if !equals(res, expect) {
|
|
|
|
t.Fatalf("%v != %v", res, expect)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDomainKeyBare(t *testing.T) {
|
|
|
|
res := getDomainKey(pagesDomain, pagesDomain)
|
|
|
|
if res != pagesDomainWildcard {
|
|
|
|
t.Fatalf("%s != %s", res, pagesDomainWildcard)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDomainKeySubdomain(t *testing.T) {
|
|
|
|
res := getDomainKey("user."+pagesDomain, pagesDomain)
|
|
|
|
if res != pagesDomainWildcard {
|
|
|
|
t.Fatalf("%s != %s", res, pagesDomainWildcard)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDomainKeyCNAME(t *testing.T) {
|
|
|
|
res := getDomainKey("testdomain.example", pagesDomain)
|
|
|
|
if res != "testdomain.example" {
|
|
|
|
t.Fatalf("%s != %s", res, "testdomain.example")
|
|
|
|
}
|
2024-01-06 14:09:36 +00:00
|
|
|
}*/
|