1 parent
bb2477b8b9
commit
56f4abc632
16 files changed
+171
-26
No files matched your search
@@ -52,17 +52,18 @@ func TestWildcardCertificateDomains(t *testing.T) {
|
||||
|
||||
func TestCertificateDomainsFollowChallengeMode(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Domain: "xuans.com",
|
||||
WebDomain: "web.xuans.com",
|
||||
Domains: []string{"xuans.com"},
|
||||
Domain: "xuans.com",
|
||||
WebDomain: "web.xuans.com",
|
||||
AdminRecoveryDomain: "recovery.xuans.com",
|
||||
Domains: []string{"xuans.com"},
|
||||
}
|
||||
|
||||
cfg.SSLType = config.SSLTypeAutoHTTP
|
||||
httpDomains := certificateDomains(cfg)
|
||||
if len(httpDomains) != 5 {
|
||||
t.Fatalf("got %d HTTP domains, want 5: %v", len(httpDomains), httpDomains)
|
||||
if len(httpDomains) != 6 {
|
||||
t.Fatalf("got %d HTTP domains, want 6: %v", len(httpDomains), httpDomains)
|
||||
}
|
||||
if httpDomains[0] != "web.xuans.com" || httpDomains[1] != "xuans.com" {
|
||||
if httpDomains[0] != "web.xuans.com" || httpDomains[1] != "xuans.com" || httpDomains[2] != "recovery.xuans.com" {
|
||||
t.Fatalf("unexpected HTTP domains: %v", httpDomains)
|
||||
}
|
||||
|
||||
@@ -73,6 +74,26 @@ func TestCertificateDomainsFollowChallengeMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDNSWildcardRejectsUncoveredAdminRecoveryDomain(t *testing.T) {
|
||||
base := &config.Config{
|
||||
Domain: "example.com",
|
||||
WebDomain: "mail.example.com",
|
||||
Domains: []string{"example.com"},
|
||||
SSLType: config.SSLTypeAutoDNS,
|
||||
AdminRecoveryDomain: "recovery.example.com",
|
||||
}
|
||||
if err := validateWildcardConfiguration(base); err != nil {
|
||||
t.Fatalf("covered recovery domain was rejected: %v", err)
|
||||
}
|
||||
for _, value := range []string{"example.com", "a.recovery.example.com", "recovery.other.example"} {
|
||||
candidate := *base
|
||||
candidate.AdminRecoveryDomain = value
|
||||
if err := validateWildcardConfiguration(&candidate); err == nil {
|
||||
t.Fatalf("uncovered recovery domain %q was accepted", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDNSChallengeWildcardProducesSingleRecord(t *testing.T) {
|
||||
challenge := &DNSChallenge{authInfo: map[string]*authInfo{}}
|
||||
if err := challenge.Present("*.xuans.com", "token", "key-auth"); err != nil {
|
||||
|
||||
Reference in new issue
Block a user