예제 #1
0
func newStoreServiceWithTokenCtx(initO scope.Option, tokenStoreCode string) context.Context {
	ctx := store.NewContextReader(context.Background(), getInitializedStoreService(initO))
	tok := jwt.New(jwt.SigningMethodHS256)
	tok.Claims[store.ParamName] = tokenStoreCode
	ctx = ctxjwt.NewContext(ctx, tok)
	return ctx
}
예제 #2
0
파일: context_test.go 프로젝트: levcom/csfw
func TestFromContext(t *testing.T) {

	ctx := ctxjwt.NewContext(context.Background(), nil)
	assert.NotNil(t, ctx)

	haveToken, haveErr := ctxjwt.FromContext(ctx)
	assert.Nil(t, haveToken)
	assert.EqualError(t, haveErr, ctxjwt.ErrContextJWTNotFound.Error())
}