Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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())
}