github.com/nyan233/littlerpc@v0.4.6-0.20230316182519-0c8d5c48abaf/plugins/auth/auth_test.go (about)

     1  package auth
     2  
     3  import (
     4  	"context"
     5  	"github.com/nyan233/littlerpc/core/common/errorhandler"
     6  	"github.com/nyan233/littlerpc/core/common/logger"
     7  	"github.com/nyan233/littlerpc/core/middle/plugin"
     8  	"github.com/nyan233/littlerpc/core/protocol/message"
     9  	"github.com/stretchr/testify/assert"
    10  	"testing"
    11  )
    12  
    13  func TestAuthorization(t *testing.T) {
    14  	p := NewBasicAuth("xiaomi", "123456")
    15  	ctx := &plugin.Context{
    16  		PluginContext: context.Background(),
    17  		Logger:        logger.DefaultLogger,
    18  		EHandler:      errorhandler.DefaultErrHandler,
    19  	}
    20  	msg := message.New()
    21  	assert.Nil(t, p.Send4C(ctx, msg, nil))
    22  	assert.Nil(t, p.Receive4S(ctx, msg))
    23  	assert.Nil(t, p.AfterReceive4C(ctx, nil, nil))
    24  }