summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-01 16:59:06 +0300
committerValery Piashchynski <[email protected]>2020-12-01 16:59:06 +0300
commit84c8234ec01ad1d5ea5f0a8c7dbca9a3012bcb2b (patch)
treed70f1d5fb0f36821825d0805d71f22940ec6a1af /plugins
parent2ac6d3192fbd43f0911d7c87f394fd0839b0fcfa (diff)
parent70910821a0ffb10316f9970a2fec4c3379d10675 (diff)
Merge branch 'release_2.0' into plugin/headers
# Conflicts: # static_pool_test.go
Diffstat (limited to 'plugins')
-rw-r--r--plugins/http/tests/handler_test.go11
-rw-r--r--plugins/http/tests/http_test.go41
-rw-r--r--plugins/static/tests/static_plugin_test.go16
3 files changed, 50 insertions, 18 deletions
diff --git a/plugins/http/tests/handler_test.go b/plugins/http/tests/handler_test.go
index b898c265..0c6a39ef 100644
--- a/plugins/http/tests/handler_test.go
+++ b/plugins/http/tests/handler_test.go
@@ -614,8 +614,15 @@ func TestHandler_FormData_POST_Overwrite(t *testing.T) {
form := url.Values{}
- form.Add("key", "value1")
+ form.Add("key", "value")
form.Add("key", "value2")
+ form.Add("name[]", "name1")
+ form.Add("name[]", "name2")
+ form.Add("name[]", "name3")
+ form.Add("arr[x][y][z]", "y")
+ form.Add("arr[x][y][e]", "f")
+ form.Add("arr[c]p", "l")
+ form.Add("arr[c]z", "")
req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, strings.NewReader(form.Encode()))
assert.NoError(t, err)
@@ -637,7 +644,7 @@ func TestHandler_FormData_POST_Overwrite(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)
- assert.Equal(t, `{"key":"value2","arr":{"x":{"y":null}}}`, string(b))
+ assert.Equal(t, `{"arr":{"c":{"p":"l","z":""},"x":{"y":{"e":"f","z":"y"}}},"key":"value2","name":["name1","name2","name3"]}`, string(b))
}
func TestHandler_FormData_POST_Form_UrlEncoded_Charset(t *testing.T) {
diff --git a/plugins/http/tests/http_test.go b/plugins/http/tests/http_test.go
index 71859937..73bb53a0 100644
--- a/plugins/http/tests/http_test.go
+++ b/plugins/http/tests/http_test.go
@@ -71,8 +71,9 @@ func TestHTTPInit(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 5)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -164,6 +165,7 @@ func TestHTTPInformerReset(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("HTTPInformerTest", informerTest)
t.Run("HTTPEchoTestBefore", echoHTTP)
t.Run("HTTPResetTest", resetTest)
@@ -253,8 +255,9 @@ func TestSSL(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -281,6 +284,7 @@ func TestSSL(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("SSLEcho", sslEcho)
t.Run("SSLNoRedirect", sslNoRedirect)
t.Run("fCGIecho", fcgiEcho)
@@ -379,8 +383,9 @@ func TestSSLRedirect(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+
+ tt := time.NewTimer(time.Second * 10)
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -407,6 +412,7 @@ func TestSSLRedirect(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("SSLRedirect", sslRedirect)
wg.Wait()
}
@@ -464,8 +470,8 @@ func TestSSLPushPipes(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -492,6 +498,7 @@ func TestSSLPushPipes(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("SSLPush", sslPush)
wg.Wait()
}
@@ -551,10 +558,9 @@ func TestFastCGI_RequestUri(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
- t.Run("FastCGIServiceRequestUri", fcgiReqURI)
+ tt := time.NewTimer(time.Second * 10)
go func() {
- tt := time.NewTimer(time.Second * 10)
defer wg.Done()
for {
select {
@@ -581,6 +587,8 @@ func TestFastCGI_RequestUri(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
+ t.Run("FastCGIServiceRequestUri", fcgiReqURI)
wg.Wait()
}
@@ -635,8 +643,9 @@ func TestH2CUpgrade(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -663,6 +672,7 @@ func TestH2CUpgrade(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("H2cUpgrade", h2cUpgrade)
wg.Wait()
}
@@ -722,8 +732,9 @@ func TestH2C(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -750,6 +761,7 @@ func TestH2C(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("H2c", h2c)
wg.Wait()
}
@@ -810,8 +822,9 @@ func TestHttpMiddleware(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 15)
+
go func() {
- tt := time.NewTimer(time.Second * 15)
defer wg.Done()
for {
select {
@@ -838,6 +851,7 @@ func TestHttpMiddleware(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("MiddlewareTest", middleware)
wg.Wait()
}
@@ -913,8 +927,9 @@ func TestHttpEchoErr(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -941,6 +956,7 @@ func TestHttpEchoErr(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("HttpEchoError", echoError)
wg.Wait()
}
@@ -994,8 +1010,9 @@ func TestHttpEnvVariables(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 5)
defer wg.Done()
for {
select {
@@ -1022,6 +1039,7 @@ func TestHttpEnvVariables(t *testing.T) {
}
}()
+ time.Sleep(time.Second * 1)
t.Run("EnvVariablesTest", envVarsTest)
wg.Wait()
}
@@ -1069,7 +1087,6 @@ func TestHttpBrokenPipes(t *testing.T) {
assert.Error(t, err)
}
-
func get(url string) (string, *http.Response, error) {
r, err := http.Get(url)
if err != nil {
diff --git a/plugins/static/tests/static_plugin_test.go b/plugins/static/tests/static_plugin_test.go
index a9cb1fd1..d0403160 100644
--- a/plugins/static/tests/static_plugin_test.go
+++ b/plugins/static/tests/static_plugin_test.go
@@ -57,8 +57,9 @@ func TestStaticPlugin(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 10)
defer wg.Done()
for {
select {
@@ -85,6 +86,7 @@ func TestStaticPlugin(t *testing.T) {
}
}()
+ time.Sleep(time.Second)
t.Run("ServeSample", serveStaticSample)
t.Run("StaticNotForbid", staticNotForbid)
t.Run("StaticHeaders", staticHeaders)
@@ -163,8 +165,9 @@ func TestStaticDisabled(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 10)
defer wg.Done()
for {
select {
@@ -191,6 +194,7 @@ func TestStaticDisabled(t *testing.T) {
}
}()
+ time.Sleep(time.Second)
t.Run("StaticDisabled", staticDisabled)
wg.Wait()
}
@@ -234,8 +238,9 @@ func TestStaticFilesDisabled(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 10)
defer wg.Done()
for {
select {
@@ -262,6 +267,7 @@ func TestStaticFilesDisabled(t *testing.T) {
}
}()
+ time.Sleep(time.Second)
t.Run("StaticFilesDisabled", staticFilesDisabled)
wg.Wait()
}
@@ -314,8 +320,9 @@ func TestStaticFilesForbid(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
+ tt := time.NewTimer(time.Second * 10)
+
go func() {
- tt := time.NewTimer(time.Second * 10)
defer wg.Done()
for {
select {
@@ -342,6 +349,7 @@ func TestStaticFilesForbid(t *testing.T) {
}
}()
+ time.Sleep(time.Second)
t.Run("StaticTestFilesDir", staticTestFilesDir)
t.Run("StaticNotFound", staticNotFound)
t.Run("StaticFilesForbid", staticFilesForbid)