testkit

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertChecklistCoverage

func AssertChecklistCoverage(t testing.TB, registered []string, checklist []string)

AssertChecklistCoverage fails if any checklist item is not registered.

func ListTools

func ListTools(t testing.TB, server *Server, token string, sessionID string) []string

ListTools calls tools/list over Streamable HTTP and returns tool names.

func ListToolsURL

func ListToolsURL(t testing.TB, mcpURL string, token string, sessionID string) []string

ListToolsURL calls tools/list at mcpURL and returns tool names.

func MintToken

func MintToken(t testing.TB, scopes ...string) string

MintToken issues a signed test bearer token accepted by TokenValidator.

func RunHandshake

func RunHandshake(t testing.TB, server *Server, token string) string

RunHandshake initializes a Streamable HTTP MCP session and returns Mcp-Session-Id.

func RunHandshakeURL

func RunHandshakeURL(t testing.TB, mcpURL string, token string) string

RunHandshakeURL initializes a Streamable HTTP MCP session at mcpURL.

func TokenValidator

func TokenValidator(t testing.TB) oauth.TokenValidator

TokenValidator returns a test-only validator for tokens produced by MintToken.

Types

type Server

type Server struct {
	URL             string
	MCPURL          string
	HTTPServer      *httptest.Server
	UserStore       *UserStore
	RegisteredTools []string
}

Server is an in-memory mcp-kit server for tests.

func NewServer

func NewServer(t testing.TB) *Server

NewServer starts an in-memory mcp-kit server with test-token auth.

type User

type User struct {
	IDValue           uuid.UUID
	EmailValue        string
	PasswordHashValue []byte
	Active            bool
	Scopes            []string
}

User is an in-memory test user with configurable scopes.

func (User) Email

func (u User) Email() string

func (User) ID

func (u User) ID() uuid.UUID

func (User) IsActive

func (u User) IsActive() bool

func (User) PasswordHash

func (u User) PasswordHash() []byte

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

UserStore is an in-memory userstore.Store implementation.

func NewUserStore

func NewUserStore(t testing.TB, scopes ...string) *UserStore

NewUserStore creates a single-user in-memory user store.

func (*UserStore) Add

func (s *UserStore) Add(user User)

Add inserts or replaces user.

func (*UserStore) FindByEmail

func (s *UserStore) FindByEmail(_ context.Context, email string) (userstore.User, error)

func (*UserStore) FindByID

func (s *UserStore) FindByID(_ context.Context, id uuid.UUID) (userstore.User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL