Codebase list golang-github-go-kit-kit / c4aa78e
auth/jwt: MapClaims: failing test Peter Bourgon 6 years ago
1 changed file(s) with 20 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "context"
4 "sync"
45 "testing"
56 "time"
67
198199 t.Fatalf("JWT customClaims.MyProperty did not match: expecting %s got %s", myProperty, custCl.MyProperty)
199200 }
200201 }
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 }