[update] add plugin config (#1180)

Signed-off-by: lihaowei <haoweili35@gmail.com>
This commit is contained in:
Howie
2021-10-31 12:56:25 +08:00
committed by GitHub
parent 8230474667
commit cd1f8da13f
4 changed files with 58 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package rest
import (
"crypto/tls"
"fmt"
"io"
"net/http"
@@ -217,3 +218,39 @@ func TestWithPriority(t *testing.T) {
WithPriority()(&fr)
assert.True(t, fr.priority)
}
func TestWithTLSConfig(t *testing.T) {
const configYaml = `
Name: foo
Port: 54321
`
var cnf RestConf
assert.Nil(t, conf.LoadConfigFromYamlBytes([]byte(configYaml), &cnf))
testConfig := []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
}
testCases := []struct {
c RestConf
opts []RunOption
res *tls.Config
}{
{
c: cnf,
opts: []RunOption{WithTLSConfig(testConfig)},
res: &tls.Config{CipherSuites: testConfig},
},
{
c: cnf,
opts: []RunOption{WithUnsignedCallback(nil)},
res: nil,
},
}
for _, testCase := range testCases {
srv, err := NewServer(testCase.c, testCase.opts...)
assert.Nil(t, err)
assert.Equal(t, srv.ngin.tlsConfig, testCase.res)
}
}