Skip to content

Commit

Permalink
plugin tests changed to accept new types
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley committed Nov 2, 2018
1 parent 29a3e4f commit 264eaac
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions mw_js_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestJSVMLogs(t *testing.T) {
log.Out = &buf
log.Formatter = new(prefixed.TextFormatter)

jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))

jsvm.RawLog = logrus.New()
Expand Down Expand Up @@ -81,7 +81,8 @@ func TestJSVMBody(t *testing.T) {
}
body := "foô \uffff \u0000 \xff bàr"
req := httptest.NewRequest("GET", "/foo", strings.NewReader(body))
jsvm := JSVM{}
jsvm := &OttoJSVM{}

jsvm.Init(nil, logrus.NewEntry(log))

const js = `
Expand Down Expand Up @@ -117,7 +118,7 @@ func TestJSVMProcessTimeout(t *testing.T) {
Pre: true,
}
req := httptest.NewRequest("GET", "/foo", strings.NewReader("body"))
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))
jsvm.Timeout = time.Millisecond

Expand Down Expand Up @@ -165,7 +166,7 @@ testJSVMData.NewProcessRequest(function(request, session, spec) {
MiddlewareClassName: "testJSVMData",
Pre: true,
}
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))
if _, err := jsvm.VM.Run(js); err != nil {
t.Fatalf("failed to set up js plugin: %v", err)
Expand Down Expand Up @@ -201,7 +202,7 @@ testJSVMData.NewProcessRequest(function(request, session, config) {
MiddlewareClassName: "testJSVMData",
Pre: true,
}
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))
if _, err := jsvm.VM.Run(js); err != nil {
t.Fatalf("failed to set up js plugin: %v", err)
Expand Down Expand Up @@ -247,7 +248,7 @@ testJSVMData.NewProcessRequest(function(request, session, config) {
MiddlewareClassName: "testJSVMData",
Pre: true,
}
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))
if _, err := jsvm.VM.Run(js); err != nil {
t.Fatalf("failed to set up js plugin: %v", err)
Expand Down Expand Up @@ -296,7 +297,7 @@ testJSVMCore.NewProcessRequest(function(request, session, config) {
globalConf.TykJSPath = old
config.SetGlobal(globalConf)
}()
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))
if _, err := jsvm.VM.Run(js); err != nil {
t.Fatalf("failed to set up js plugin: %v", err)
Expand All @@ -321,7 +322,7 @@ func TestJSVMRequestScheme(t *testing.T) {
}
req := httptest.NewRequest("GET", "/foo", nil)
req.URL.Scheme = "http"
jsvm := JSVM{}
jsvm := &OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))

const js = `
Expand Down Expand Up @@ -419,7 +420,7 @@ func TestTykMakeHTTPRequest(t *testing.T) {
}

func TestJSVMBase64(t *testing.T) {
jsvm := JSVM{}
jsvm := OttoJSVM{}
jsvm.Init(nil, logrus.NewEntry(log))

inputString := "teststring"
Expand Down

0 comments on commit 264eaac

Please sign in to comment.