File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ package echojwt
6
6
import (
7
7
"errors"
8
8
"fmt"
9
- "github.com/golang-jwt/jwt/v4"
10
9
"net/http"
11
10
"net/http/httptest"
12
11
"net/url"
13
12
"strings"
13
+ "sync"
14
14
"testing"
15
15
16
+ "github.com/golang-jwt/jwt/v4"
16
17
"github.com/labstack/echo/v4"
17
18
"github.com/labstack/echo/v4/middleware"
18
19
"github.com/stretchr/testify/assert"
@@ -751,3 +752,29 @@ func TestWithConfig_panic(t *testing.T) {
751
752
},
752
753
)
753
754
}
755
+
756
+ func TestToMiddlewareRace (t * testing.T ) {
757
+ e := echo .New ()
758
+ mw , err := Config {
759
+ ParseTokenFunc : func (c echo.Context , auth string ) (interface {}, error ) {
760
+ return auth , nil
761
+ },
762
+ SuccessHandler : func (c echo.Context ) {
763
+ c .Set ("success" , "yes" )
764
+ },
765
+ }.ToMiddleware ()
766
+ assert .NoError (t , err )
767
+
768
+ dummyHandler := func (_ echo.Context ) error { return nil }
769
+ var wg sync.WaitGroup
770
+ for i := 0 ; i < 10 ; i ++ {
771
+ wg .Add (1 )
772
+ go func () {
773
+ defer wg .Done ()
774
+ for j := 0 ; j < 10 ; j ++ {
775
+ mw (dummyHandler )(e .NewContext (httptest .NewRequest ("" , "/" , nil ), httptest .NewRecorder ()))
776
+ }
777
+ }()
778
+ }
779
+ wg .Wait ()
780
+ }
You can’t perform that action at this time.
0 commit comments