Documentation
¶
Overview ¶
Package testpds provides an in-process fake ATProto PDS for integration tests. It implements the minimal XRPC surface that AppView and Hold call during push/pull (createSession, getServiceAuth, repo.put/get/list/delete Record, identity.resolveHandle), plus an identity.Directory implementation so DID resolution short-circuits the network.
Index ¶
- type Directory
- func (d *Directory) Lookup(ctx context.Context, atid syntax.AtIdentifier) (*identity.Identity, error)
- func (d *Directory) LookupDID(_ context.Context, did syntax.DID) (*identity.Identity, error)
- func (d *Directory) LookupHandle(_ context.Context, handle syntax.Handle) (*identity.Identity, error)
- func (d *Directory) Purge(_ context.Context, _ syntax.AtIdentifier) error
- func (d *Directory) Register(ident *identity.Identity)
- type Identity
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory is an in-memory identity.Directory containing both the user identities served by the fake PDS and any service DIDs the test registers (e.g. the Hold's did:web identity). Install via atproto.SetDirectory().
func (*Directory) Lookup ¶
func (d *Directory) Lookup(ctx context.Context, atid syntax.AtIdentifier) (*identity.Identity, error)
Lookup implements identity.Directory.
func (*Directory) LookupHandle ¶
func (d *Directory) LookupHandle(_ context.Context, handle syntax.Handle) (*identity.Identity, error)
LookupHandle implements identity.Directory.
func (*Directory) Purge ¶
Purge implements identity.Directory. Our directory is authoritative — entries don't expire — so this is a no-op.
type Identity ¶
type Identity struct {
DID syntax.DID
Handle syntax.Handle
SigningKey *atcrypto.PrivateKeyK256
Password string // synthetic app-password; opaque to tests
AccessToken string // synthetic accessJwt returned by createSession
// contains filtered or unexported fields
}
Identity is a single account on the fake PDS. Each identity has its own K-256 signing keypair used to sign service-auth JWTs the Hold service verifies.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the fake PDS. Each test calls New(t) to spin one up, then AddIdentity() to register users. The Directory() must be passed to atproto.SetDirectory() so AppView and Hold resolve DIDs through it.
func New ¶
New starts a fake PDS bound to a random port via httptest.NewServer. The server is torn down automatically via t.Cleanup. Callers should immediately install s.Directory() with atproto.SetDirectory() so DID resolution short- circuits through the in-memory store.
func (*Server) AddIdentity ¶
AddIdentity creates a new account, returns its Identity (DID, handle, signing key, synthetic password / accessJwt), and registers it in the directory so DID/handle lookups return it.
func (*Server) Directory ¶
Directory returns the identity.Directory backing this fake PDS. Install via atproto.SetDirectory() before any DID resolution happens.
func (*Server) GetRecord ¶
func (s *Server) GetRecord(did, collection, rkey string) (json.RawMessage, bool)
GetRecord returns the raw JSON value of a record stored in the fake PDS. Useful for tests that need to assert a downstream component wrote a record without going through the HTTP XRPC surface. Returns (nil, false) on miss.
func (*Server) URL ¶
URL returns the fake PDS's base URL (http://127.0.0.1:NNNN).