diff --git a/middleware/auth_access_token_test.go b/middleware/auth_access_token_test.go index b26a7f0..fe1ba8d 100644 --- a/middleware/auth_access_token_test.go +++ b/middleware/auth_access_token_test.go @@ -15,23 +15,17 @@ import ( ) func TestAuthFuncGRPC_AccessToken(t *testing.T) { - ss := &TestAuthAccessTokenSuite{ + var ss TestAuthAccessTokenSuite + ss = TestAuthAccessTokenSuite{ InterceptorTestSuite: &grpc_test.InterceptorTestSuite{ TestService: newTestAuthenticationAccessToken(), ServerOpts: []grpc.ServerOption{ - grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), - grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), + grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAccessTokenAuthFuncGRPC(ss.validateAccessToken))), + grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAccessTokenAuthFuncGRPC(ss.validateAccessToken))), }, }, } - suite.Run(t, ss) -} - -func validateAccessToken(ctx context.Context, token string) error { - if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { - return status.Error(codes.Unauthenticated, "Invalid access token") - } - return nil + suite.Run(t, &ss) } type TestAuthAccessTokenSuite struct { @@ -91,6 +85,13 @@ func (suite *TestAuthAccessTokenSuite) TestValidToken() { suite.Assert().NotNil(res) } +func (suite *TestAuthAccessTokenSuite) validateAccessToken(ctx context.Context, token string) error { + if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { + return status.Error(codes.Unauthenticated, "Invalid access token") + } + return nil +} + type testAuthAccessToken struct { grpc_test.UnimplementedTestServiceServer }