apptest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LegacyProtocol    = "2025-11-25"
	StatelessProtocol = "2026-07-28"
)
View Source
const (
	PublicURL     = "https://wpp.example.test"
	OwnerPassword = "owner-password-for-tests"
	DefaultIP     = "203.0.113.7"
)
View Source
const (
	FakeVoiceNotePrefix = "OggS fake voice note of "
	FakeMediaDuration   = 3400 * time.Millisecond
)
View Source
const ClaudeCallback = "https://claude.ai/api/mcp/auth_callback"
View Source
const UploadsPath = "/uploads"

Variables

View Source
var StartTime = time.Date(2026, 10, 13, 12, 0, 0, 0, time.UTC)

Functions

func ReadBody

func ReadBody(t testing.TB, resp *http.Response) string

func ReadJSON

func ReadJSON(t testing.TB, resp *http.Response) map[string]any

func RedirectParams

func RedirectParams(t testing.TB, resp *http.Response, redirectURI string) url.Values

Types

type AuthorizeForm

type AuthorizeForm struct {
	Hidden     url.Values
	Fields     map[string]string
	Accounts   []string
	Checked    []string
	Page       string
	StatusCode int
}

func ParseAuthorizeForm

func ParseAuthorizeForm(status int, page string) AuthorizeForm

func (AuthorizeForm) Submission

func (f AuthorizeForm) Submission(password, accessName string, accounts ...string) url.Values

type CLIResult

type CLIResult struct {
	Stdout string
	Stderr string
	Code   int
}

type CLIRun

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

func (*CLIRun) Wait

func (r *CLIRun) Wait(t testing.TB) CLIResult

func (*CLIRun) WaitWhile

func (r *CLIRun) WaitWhile(t testing.TB, tick func()) CLIResult

type ConnectOption

type ConnectOption func(*connectOptions)

func WithElicitation

func WithElicitation(handler func(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error)) ConnectOption

func WithIP

func WithIP(ip string) ConnectOption

func WithProtocol

func WithProtocol(version string) ConnectOption

func WithReceivingMiddleware

func WithReceivingMiddleware(middleware mcp.Middleware) ConnectOption

func WithToolListChanged

func WithToolListChanged(handler func(context.Context, *mcp.ToolListChangedRequest)) ConnectOption

func WithoutMultiRoundTrip

func WithoutMultiRoundTrip() ConnectOption

type Harness

type Harness struct {
	URL         string
	AdminSocket string
	DataDir     string
	Owner       *admin.Client
	WhatsApp    *fake.World
	Clock       *clock.Manual
	// contains filtered or unexported fields
}

func Start

func Start(t testing.TB, opts ...Option) *Harness

func (*Harness) AddAccount

func (h *Harness) AddAccount(t testing.TB, name, phone, profile string)

func (*Harness) AuditLines

func (h *Harness) AuditLines(t testing.TB) []map[string]any

func (*Harness) AuditRaw

func (h *Harness) AuditRaw() string

func (*Harness) Authorize

func (h *Harness) Authorize(t testing.TB, login *Login, accessName string, accounts ...string) string

func (*Harness) AwaitAccountState

func (h *Harness) AwaitAccountState(t testing.TB, name, state string)

func (*Harness) AwaitPairing

func (h *Harness) AwaitPairing(t testing.TB, phone string) *fake.Pairing

func (*Harness) CLI

func (h *Harness) CLI(t testing.TB, args ...string) CLIResult

func (*Harness) CLIWithInput

func (h *Harness) CLIWithInput(t testing.TB, stdin string, args ...string) CLIResult

func (*Harness) Connect

func (h *Harness) Connect(t testing.TB, token string, opts ...ConnectOption) *mcp.ClientSession

func (*Harness) Do

func (h *Harness) Do(t testing.TB, req *http.Request) *http.Response

func (*Harness) ExchangeCode

func (h *Harness) ExchangeCode(t testing.TB, login *Login, code string) (*http.Response, map[string]any)

func (*Harness) Get

func (h *Harness) Get(t testing.TB, path string, opts ...RequestOption) *http.Response

func (*Harness) LoginFor

func (h *Harness) LoginFor(client OAuthClient) *Login

func (*Harness) MCPURL

func (h *Harness) MCPURL() string

func (*Harness) NewLogin

func (h *Harness) NewLogin(t testing.TB) *Login

func (*Harness) OAuthLogin

func (h *Harness) OAuthLogin(t testing.TB, accessName string, accounts ...string) (*Login, Tokens)

func (*Harness) OpenAuthorizePage

func (h *Harness) OpenAuthorizePage(t testing.TB, query url.Values, opts ...RequestOption) AuthorizeForm

func (*Harness) Options

func (h *Harness) Options(t testing.TB, path string, opts ...RequestOption) *http.Response

func (*Harness) Post

func (h *Harness) Post(t testing.TB, path string, body io.Reader, contentType string, opts ...RequestOption) *http.Response

func (*Harness) PostForm

func (h *Harness) PostForm(t testing.TB, path string, form url.Values, opts ...RequestOption) *http.Response

func (*Harness) PostJSON

func (h *Harness) PostJSON(t testing.TB, path string, body any, opts ...RequestOption) *http.Response

func (*Harness) Refresh

func (h *Harness) Refresh(t testing.TB, client OAuthClient, refreshToken string) (*http.Response, map[string]any)

func (*Harness) RegisterOAuthClient

func (h *Harness) RegisterOAuthClient(t testing.TB, metadata map[string]any) OAuthClient

func (*Harness) Restart

func (h *Harness) Restart(t testing.TB)

func (*Harness) Resume

func (h *Harness) Resume(t testing.TB)

func (*Harness) StartCLI

func (h *Harness) StartCLI(args ...string) *CLIRun

func (*Harness) StartCLIWithInput

func (h *Harness) StartCLIWithInput(stdin string, args ...string) *CLIRun

func (*Harness) StaticToken

func (h *Harness) StaticToken(t testing.TB, name string, accounts []string, readOnly bool) string

func (*Harness) Stop

func (h *Harness) Stop(t testing.TB)

func (*Harness) SubmitAuthorize

func (h *Harness) SubmitAuthorize(t testing.TB, values url.Values, opts ...RequestOption) *http.Response

func (*Harness) TokenRequest

func (h *Harness) TokenRequest(t testing.TB, form url.Values, opts ...RequestOption) (*http.Response, map[string]any)

func (*Harness) TryConnect

func (h *Harness) TryConnect(token string, opts ...ConnectOption) (*mcp.ClientSession, error)

func (*Harness) Upload

func (h *Harness) Upload(t testing.TB, token string, data []byte, contentType string) string

type Login

type Login struct {
	Client  OAuthClient
	PKCE    PKCE
	State   string
	Request url.Values
}

type OAuthClient

type OAuthClient struct {
	ID          string
	Secret      string
	RedirectURI string
}

type Option

type Option func(*options)

func WithConfig

func WithConfig(fn func(*config.Config)) Option

func WithPublicURLOfTheListener

func WithPublicURLOfTheListener() Option

func WithRealFFmpeg

func WithRealFFmpeg() Option

type PKCE

type PKCE struct {
	Verifier  string
	Challenge string
}

func NewPKCE

func NewPKCE() PKCE

type RequestOption

type RequestOption func(*http.Request)

func FromIP

func FromIP(ip string) RequestOption

func WithBasicAuth

func WithBasicAuth(user, password string) RequestOption

func WithBearer

func WithBearer(token string) RequestOption

type Tokens

type Tokens struct {
	Access  string
	Refresh string
	Body    map[string]any
}

func TokensFrom

func TokensFrom(body map[string]any) Tokens

Jump to

Keyboard shortcuts

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