apptest

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 11 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

Overview

Package apptest is an in-memory NeuralTrust console for tests. It implements the contract ntctl relies on: OAuth discovery, authorization code + PKCE with a loopback redirect, rotating refresh tokens and revocation, and the CLI API under /api/cli/v1. Every secret it issues (codes, access, refresh, config-sync and enrolment tokens) contains "CANARY", so tests can check none leaks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Issued

type Issued struct {
	Product, Org, ID string
	Rotate           bool
	Config           api.InstallConfig
}

Issued is one install config the console handed out.

type Server

type Server struct {
	*httptest.Server

	// Email is the signed-in user; Orgs are the organizations they belong to;
	// Chosen is the one picked on the consent page.
	Email  string
	Orgs   []api.Org
	Chosen string
	// Deny makes the user refuse consent.
	Deny bool
	// AccessTTL is how long access tokens live.
	AccessTTL time.Duration
	// ReadOnly makes every write answer 403, as for a member without ADMIN.
	ReadOnly bool
	// ControlPlane is the DNS suffix of the control plane the issued tokens
	// are valid at; New sets the EU region's.
	ControlPlane string
	// contains filtered or unexported fields
}

Server is the fake console.

func New

func New() *Server

New starts a fake console with one user in two organizations.

func (*Server) AddInstance

func (s *Server) AddInstance(product api.Product, org string, in api.Instance)

AddInstance adds an existing private instance.

func (*Server) Browser

func (s *Server) Browser(authURL string) error

Browser stands in for the user's browser: it opens the authorization URL and follows the console's redirect back to ntctl.

func (*Server) ExpireAccessTokens

func (s *Server) ExpireAccessTokens()

ExpireAccessTokens makes every access token issued so far stale, as if an hour had passed.

func (*Server) Finalized

func (s *Server) Finalized(id string) string

Finalized returns the endpoint recorded for an instance.

func (*Server) Instances

func (s *Server) Instances(product api.Product, org string) []api.Instance

Instances returns an organization's instances of a product.

func (*Server) Issued

func (s *Server) Issued() []Issued

Issued returns every install config handed out so far.

func (*Server) Sessions

func (s *Server) Sessions() int

Sessions returns how many sign-in sessions are still live.

func (*Server) Update

func (s *Server) Update(f func(*Server))

Update changes the console's settings (Deny, ReadOnly, Chosen…) safely while it is serving.

Jump to

Keyboard shortcuts

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