auth/jwt: MapClaims: failing test
Peter Bourgon
6 years ago
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "context" |
4 | "sync" | |
4 | 5 | "testing" |
5 | 6 | "time" |
6 | 7 | |
198 | 199 | t.Fatalf("JWT customClaims.MyProperty did not match: expecting %s got %s", myProperty, custCl.MyProperty) |
199 | 200 | } |
200 | 201 | } |
202 | ||
203 | func TestIssue562(t *testing.T) { | |
204 | var ( | |
205 | kf = func(token *jwt.Token) (interface{}, error) { return []byte("secret"), nil } | |
206 | e = NewParser(kf, jwt.SigningMethodHS256, jwt.MapClaims{})(endpoint.Nop) | |
207 | key = JWTTokenContextKey | |
208 | val = "eyJhbGciOiJIUzI1NiIsImtpZCI6ImtpZCIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZ28ta2l0In0.14M2VmYyApdSlV_LZ88ajjwuaLeIFplB8JpyNy0A19E" | |
209 | ctx = context.WithValue(context.Background(), key, val) | |
210 | ) | |
211 | wg := sync.WaitGroup{} | |
212 | for i := 0; i < 100; i++ { | |
213 | wg.Add(1) | |
214 | go func() { | |
215 | defer wg.Done() | |
216 | e(ctx, struct{}{}) // fatal error: concurrent map read and map write | |
217 | }() | |
218 | } | |
219 | wg.Wait() | |
220 | } |