|
|
|
@ -6,16 +6,40 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/http/httptest"
|
|
|
|
|
"os"
|
|
|
|
|
"sync/atomic"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
|
|
|
"github.com/zeromicro/go-zero/core/fs"
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
priKey = `-----BEGIN RSA PRIVATE KEY-----
|
|
|
|
|
MIICXQIBAAKBgQC4TJk3onpqb2RYE3wwt23J9SHLFstHGSkUYFLe+nl1dEKHbD+/
|
|
|
|
|
Zt95L757J3xGTrwoTc7KCTxbrgn+stn0w52BNjj/kIE2ko4lbh/v8Fl14AyVR9ms
|
|
|
|
|
fKtKOnhe5FCT72mdtApr+qvzcC3q9hfXwkyQU32pv7q5UimZ205iKSBmgQIDAQAB
|
|
|
|
|
AoGAM5mWqGIAXj5z3MkP01/4CDxuyrrGDVD5FHBno3CDgyQa4Gmpa4B0/ywj671B
|
|
|
|
|
aTnwKmSmiiCN2qleuQYASixes2zY5fgTzt+7KNkl9JHsy7i606eH2eCKzsUa/s6u
|
|
|
|
|
WD8V3w/hGCQ9zYI18ihwyXlGHIgcRz/eeRh+nWcWVJzGOPUCQQD5nr6It/1yHb1p
|
|
|
|
|
C6l4fC4xXF19l4KxJjGu1xv/sOpSx0pOqBDEX3Mh//FU954392rUWDXV1/I65BPt
|
|
|
|
|
TLphdsu3AkEAvQJ2Qay/lffFj9FaUrvXuftJZ/Ypn0FpaSiUh3Ak3obBT6UvSZS0
|
|
|
|
|
bcYdCJCNHDtBOsWHnIN1x+BcWAPrdU7PhwJBAIQ0dUlH2S3VXnoCOTGc44I1Hzbj
|
|
|
|
|
Rc65IdsuBqA3fQN2lX5vOOIog3vgaFrOArg1jBkG1wx5IMvb/EnUN2pjVqUCQCza
|
|
|
|
|
KLXtCInOAlPemlCHwumfeAvznmzsWNdbieOZ+SXVVIpR6KbNYwOpv7oIk3Pfm9sW
|
|
|
|
|
hNffWlPUKhW42Gc+DIECQQDmk20YgBXwXWRM5DRPbhisIV088N5Z58K9DtFWkZsd
|
|
|
|
|
OBDT3dFcgZONtlmR1MqZO0pTh30lA4qovYj3Bx7A8i36
|
|
|
|
|
-----END RSA PRIVATE KEY-----`
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestNewEngine(t *testing.T) {
|
|
|
|
|
priKeyfile, err := fs.TempFilenameWithText(priKey)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
defer os.Remove(priKeyfile)
|
|
|
|
|
|
|
|
|
|
yamls := []string{
|
|
|
|
|
`Name: foo
|
|
|
|
|
Host: localhost
|
|
|
|
@ -151,6 +175,29 @@ Verbose: true
|
|
|
|
|
Handler: func(w http.ResponseWriter, r *http.Request) {},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
priority: true,
|
|
|
|
|
jwt: jwtSetting{
|
|
|
|
|
enabled: true,
|
|
|
|
|
},
|
|
|
|
|
signature: signatureSetting{
|
|
|
|
|
enabled: true,
|
|
|
|
|
SignatureConf: SignatureConf{
|
|
|
|
|
Strict: true,
|
|
|
|
|
PrivateKeys: []PrivateKeyConf{
|
|
|
|
|
{
|
|
|
|
|
Fingerprint: "a",
|
|
|
|
|
KeyFile: priKeyfile,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
routes: []Route{{
|
|
|
|
|
Method: http.MethodGet,
|
|
|
|
|
Path: "/",
|
|
|
|
|
Handler: func(w http.ResponseWriter, r *http.Request) {},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, yaml := range yamls {
|
|
|
|
|