caddytest: normalize the JSON config (#6316)

* caddytest: normalize the JSON config
This commit is contained in:
Mohammed Al Sahaf
2024-05-14 10:50:14 +03:00
committed by GitHub
parent fb63e2e40c
commit 4c90f1427f
2 changed files with 110 additions and 0 deletions

View File

@ -136,6 +136,20 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
})
rawConfig = prependCaddyFilePath(rawConfig)
// normalize JSON config
if configType == "json" {
tc.t.Logf("Before: %s", rawConfig)
var conf any
if err := json.Unmarshal([]byte(rawConfig), &conf); err != nil {
return err
}
c, err := json.Marshal(conf)
if err != nil {
return err
}
rawConfig = string(c)
tc.t.Logf("After: %s", rawConfig)
}
client := &http.Client{
Timeout: Default.LoadRequestTimeout,
}