Add an option to request certificate with Must-Staple. (#697)

This commit is contained in:
Yuchen Ying 2020-06-17 08:29:34 -07:00 committed by GitHub
parent 8856577f39
commit 8fc1e9cca8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 23 deletions

View file

@ -314,6 +314,35 @@ func Test_NewOptionsFromConfigEnvVar(t *testing.T) {
}
}
func Test_AutoCertOptionsFromEnvVar(t *testing.T) {
envs := map[string]string{
"AUTOCERT": "true",
"AUTOCERT_DIR": "/test",
"AUTOCERT_MUST_STAPLE": "true",
"INSECURE_SERVER": "true",
}
for k, v := range envs {
os.Setenv(k, v)
defer os.Unsetenv(k)
}
o, err := NewOptionsFromConfig("")
if err != nil {
t.Fatal(err)
}
if !o.AutocertOptions.Enable {
t.Error("o.AutocertOptions.Enable: want true, got false")
}
if !o.AutocertOptions.MustStaple {
t.Error("o.AutocertOptions.MustStaple: want true, got false")
}
if o.AutocertOptions.Folder != "/test" {
t.Errorf("o.AutocertOptions.Folder: want /test, got %s", o.AutocertOptions.Folder)
}
}
type mockService struct {
fail bool
Updated bool