コード例 #1
0
ファイル: middleware_test.go プロジェクト: levcom/csfw
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())
}