only enable http challenges on port 80

This commit is contained in:
Caleb Doxsey 2024-06-26 11:06:32 -06:00
parent 21a4fa6e29
commit 1e155ac3f4
2 changed files with 44 additions and 4 deletions

View file

@ -630,3 +630,23 @@ func Test_configureTrustedRoots(t *testing.T) {
})
}
}
func TestShouldEnableHTTPChallenge(t *testing.T) {
t.Parallel()
assert.False(t, shouldEnableHTTPChallenge(nil))
assert.False(t, shouldEnableHTTPChallenge(&config.Config{}))
assert.False(t, shouldEnableHTTPChallenge(&config.Config{Options: &config.Options{}}))
assert.False(t, shouldEnableHTTPChallenge(&config.Config{Options: &config.Options{
HTTPRedirectAddr: ":8080",
}}))
assert.False(t, shouldEnableHTTPChallenge(&config.Config{Options: &config.Options{
HTTPRedirectAddr: "127.0.0.1:8080",
}}))
assert.True(t, shouldEnableHTTPChallenge(&config.Config{Options: &config.Options{
HTTPRedirectAddr: ":80",
}}))
assert.True(t, shouldEnableHTTPChallenge(&config.Config{Options: &config.Options{
HTTPRedirectAddr: "127.0.0.1:80",
}}))
}