subscription

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package subscription contains provider-neutral, fixture-only contracts for credential-backed subscription transports. It deliberately knows no real provider origin, OAuth registration, account identity, or model catalogue.

Package subscription provides provider-neutral, fixture-only certification contracts for credential-backed subscription transports.

An enabled OpenAI or Anthropic subscription package must add a package test that constructs a Witness with its explicit Constructor and Contract, then calls Witness.Run against NewServer(t). The witness is deliberately fail-closed: no constructor, provider endpoint, client ID, account selector, or model-discovery behavior can be inferred by this package. Registration gates that are unavailable must not fabricate a witness or provider client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(contract Contract, server *Server) error

Execute validates a contract and runs its complete fixture-only matrix.

func Run

func Run(t *testing.T, contract Contract, server *Server)

Run executes the complete contract matrix against server.

func RunContract

func RunContract(t *testing.T, contract Contract, server *Server)

RunContract is a descriptive alias for Run.

func ValidateContract

func ValidateContract(contract Contract) error

ValidateContract checks the bounded, explicit inputs needed by Run. It does not perform network I/O or infer an endpoint, credential, or model.

Types

type Constructor

type Constructor func(model.Model, credentials.Source, *Server) (inference.Client, error)

Constructor builds one provider-bound client for a model and fixture source. The fixture server is passed explicitly so a provider test can provide its TLS roots and any transport-only test options without the contract runner knowing provider constructor details.

type Contract

type Contract struct {
	Provider    string
	Transport   string
	Issuer      string
	Scheme      credentials.Scheme
	Usage       credentials.UsageClass
	Formats     []model.APIFormat
	ModelName   string
	NewSource   SourceFactory
	Constructor Constructor
}

Contract describes one provider-neutral subscription transport matrix. The values are caller-supplied identity metadata; no provider defaults are embedded here.

type Server

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

Server is a loopback-only TLS provider fixture. The handler and request capture are owned by the contract runner; callers only use URL and RootCAs when adapting a provider constructor.

func NewServer

func NewServer(t testing.TB) *Server

NewServer starts a loopback TLS fixture. httptest's generated certificate is the only root exposed by RootCAs; callers must opt into it explicitly.

func (*Server) Close

func (s *Server) Close() error

Close stops the fixture server. It is safe to call more than once.

func (*Server) RootCAs

func (s *Server) RootCAs() *x509.CertPool

RootCAs returns a fresh pool containing only the fixture's certificate.

func (*Server) URL

func (s *Server) URL() string

URL returns the exact loopback TLS origin of the fixture.

type SourceFactory

type SourceFactory func(credentials.Descriptor) (credentials.Source, error)

SourceFactory creates the explicit credential source used for one contract case. Tests normally return a deterministic fixture source; production credential stores and provider account selection are intentionally outside this package.

type Witness

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

Witness is the fail-closed certification handle for an enabled subscription constructor. Provider package tests should construct one with their explicit contract and call Run; a provider is not contract-certified merely because its constructor compiles.

func NewWitness

func NewWitness(contract Contract) (Witness, error)

NewWitness validates the explicit contract that a provider package test intends to certify. It never supplies provider identity, endpoints, or model defaults.

func (Witness) Run

func (w Witness) Run(t *testing.T, server *Server)

Run executes the certified provider contract against the supplied fixture.

func (Witness) Validate

func (w Witness) Validate() error

Validate rechecks the witness contract before a provider test runs it.

Jump to

Keyboard shortcuts

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