mockserver

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package mockserver is a Kapten stand-in for the CLI: a fake auth service (package mockauth) under /auth and the Engine API generated from the CLI's embedded OpenAPI document (package mockengine) under /api, on one listener. Engine requests need an access token the fake auth issued.

The end-to-end tests run the real kapten binary against it, and `kapten-mock` serves it for trying the CLI by hand.

Index

Constants

View Source
const (
	ApplicationID     = "cli_6d6f636b-0000-4000-8000-000000000001"
	ApplicationSecret = "kapten_sk_mock"
)

Application is the OAuth application the mock accepts in server mode (KAPTEN_CLIENT_ID and KAPTEN_CLIENT_SECRET).

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// ManualApproval keeps logins pending until their code is approved on
	// the /auth/device page or through Auth.Approve.
	ManualApproval bool
	// TokenTTL is the lifetime of access tokens (default one hour).
	TokenTTL time.Duration
	// PollInterval is the device poll interval in seconds (default 1).
	PollInterval int
}

Options tune the fake auth service.

type Server

type Server struct {
	Auth   *mockauth.Server
	Engine *mockengine.Server
	// contains filtered or unexported fields
}

Server is the mock. Call Listen with its base URL before serving it.

func New

func New(opts Options) (*Server, error)

New builds the mock from the embedded Engine OpenAPI document.

func (*Server) APIURL

func (s *Server) APIURL() string

APIURL is the mock Engine API, KAPTEN_API_URL.

func (*Server) IssuerURL

func (s *Server) IssuerURL() string

IssuerURL is the fake auth service, KAPTEN_ISSUER_URL.

func (*Server) Listen

func (s *Server) Listen(base string) error

Listen sets the base URL the mock is served at.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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