func newStoreServiceWithTokenCtx(initO scope.Option, tokenStoreCode string) context.Context { ctx := store.WithContextReader(context.Background(), getInitializedStoreService(initO)) tok := jwt.New(jwt.SigningMethodHS256) tok.Claims[store.ParamName] = tokenStoreCode ctx = ctxjwt.WithContext(ctx, tok) return ctx }
func TestFromContext(t *testing.T) { ctx := ctxjwt.WithContext(context.Background(), nil) assert.NotNil(t, ctx) haveToken, haveErr := ctxjwt.FromContext(ctx) assert.Nil(t, haveToken) assert.EqualError(t, haveErr, ctxjwt.ErrContextJWTNotFound.Error()) }