-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added grace period for acme domain renewal. has to be between 1 and 3…
…0 days. should panic server if not set correctly. needs revisit for providers other than letsencrypt. defaults to 30
- Loading branch information
1 parent
3ae5db0
commit 5b4b15c
Showing
7 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,112 @@ func TestValidateAcmeEmail(t *testing.T) { | |
config = config.validateAcmeConfig() | ||
} | ||
|
||
//TestValidateAcmeEmail | ||
func TestValidateAcmeGracePeriod30(t *testing.T) { | ||
config := &Config{ | ||
Connection: Connection{ | ||
Downstream: Downstream{ | ||
Http: Http{Port: 80}, | ||
Tls: Tls{ | ||
Acme: Acme{ | ||
Domains: []string{"adyntest.com"}, | ||
Provider: "letsencrypt", | ||
Email: "[email protected]", | ||
GracePeriodDays: 30, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
config = config.validateAcmeConfig() | ||
|
||
want := 30 | ||
got := config.Connection.Downstream.Tls.Acme.GracePeriodDays | ||
if want != got { | ||
t.Errorf("want grace period days %v, got %v", want, got) | ||
} | ||
} | ||
|
||
func TestValidateAcmeGracePeriod15(t *testing.T) { | ||
config := &Config{ | ||
Connection: Connection{ | ||
Downstream: Downstream{ | ||
Http: Http{Port: 80}, | ||
Tls: Tls{ | ||
Acme: Acme{ | ||
Domains: []string{"adyntest.com"}, | ||
Provider: "letsencrypt", | ||
Email: "[email protected]", | ||
GracePeriodDays: 15, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
config = config.validateAcmeConfig() | ||
|
||
want := 15 | ||
got := config.Connection.Downstream.Tls.Acme.GracePeriodDays | ||
if want != got { | ||
t.Errorf("want grace period days %v, got %v", want, got) | ||
} | ||
} | ||
|
||
func TestValidateDefaultAcmeGracePeriod(t *testing.T) { | ||
config := &Config{ | ||
Connection: Connection{ | ||
Downstream: Downstream{ | ||
Http: Http{Port: 80}, | ||
Tls: Tls{ | ||
Acme: Acme{ | ||
Domains: []string{"adyntest.com"}, | ||
Provider: "letsencrypt", | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
config = config.validateAcmeConfig() | ||
|
||
want := 30 | ||
got := config.Connection.Downstream.Tls.Acme.GracePeriodDays | ||
if want != got { | ||
t.Errorf("want grace period days %v, got %v", want, got) | ||
} | ||
} | ||
|
||
func TestValidateAcmeGracePeriodFailsGreater30(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r == nil { | ||
t.Errorf("config should have panicked with 31 days acme grace period") | ||
} else { | ||
t.Logf("normal config panic for 31 days acme grace period") | ||
} | ||
}() | ||
|
||
config := &Config{ | ||
Connection: Connection{ | ||
Downstream: Downstream{ | ||
Http: Http{Port: 80}, | ||
Tls: Tls{ | ||
Acme: Acme{ | ||
Domains: []string{"adyntest.com"}, | ||
Provider: "letsencrypt", | ||
Email: "[email protected]", | ||
GracePeriodDays: 31, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
config = config.validateAcmeConfig() | ||
} | ||
|
||
//TestValidateAcmeDomainInvalidLeadingDotFails | ||
func TestValidateValidateAcmeDomainInvalidLeadingDotFails(t *testing.T) { | ||
defer func() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters