testlive

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package testlive is the opt-in live-local harness: tests that reach the owner's real identity provider, Azure DevOps organisation and AWS account. The live suites build only under `-tags live`, skip unless their own WARDYN_LIVE_* gate is set, and never run in CI. docs/LIVE-TESTS.md is the owner's setup and run guide.

Everything the live suites print goes through Redact first, and they take secrets only as paths to files kept outside the repository.

Index

Constants

View Source
const (
	// MaxTokens is the ceiling on one call's max_tokens.
	MaxTokens = 32
	// DefaultMaxCalls and HardMaxCalls bound WARDYN_LIVE_BEDROCK_MAX_CALLS.
	DefaultMaxCalls = 5
	HardMaxCalls    = 20
	// DefaultModel is Claude Haiku 4.5 through the US cross-region profile.
	DefaultModel = "us.anthropic.claude-haiku-4-5-20251001-v1:0"
)
View Source
const (
	EnvEntra      = "WARDYN_LIVE_ENTRA"
	EnvADO        = "WARDYN_LIVE_ADO"
	EnvBedrock    = "WARDYN_LIVE_BEDROCK"
	EnvAWSSSO     = "WARDYN_LIVE_AWS_SSO"
	EnvBaseURL    = "WARDYN_LIVE_BASE_URL"
	EnvIdentities = "WARDYN_LIVE_IDENTITIES_FILE"

	EnvADOOrg     = "WARDYN_LIVE_ADO_ORG"
	EnvADOProject = "WARDYN_LIVE_ADO_PROJECT"
	EnvADORepo    = "WARDYN_LIVE_ADO_REPO"
	// The LL2 project and repository whose names carry a space (#485);
	// optional, defaulting to the fixture names docs/LIVE-TESTS.md lists.
	EnvADOSpacedProject = "WARDYN_LIVE_ADO_SPACED_PROJECT"
	EnvADOSpacedRepo    = "WARDYN_LIVE_ADO_SPACED_REPO"

	EnvSSORegion    = "WARDYN_LIVE_AWS_SSO_REGION"
	EnvSSOTokenFile = "WARDYN_LIVE_AWS_SSO_TOKEN_FILE"

	EnvBedrockAccount  = "WARDYN_LIVE_BEDROCK_ACCOUNT_ID"
	EnvBedrockRole     = "WARDYN_LIVE_BEDROCK_ROLE_NAME"
	EnvBedrockRegion   = "WARDYN_LIVE_BEDROCK_REGION"
	EnvBedrockModel    = "WARDYN_LIVE_BEDROCK_MODEL"
	EnvBedrockMaxCalls = "WARDYN_LIVE_BEDROCK_MAX_CALLS"
)

The live suites' environment. Values that are secrets are never read from the environment: the *_FILE names hold a path to a file outside the repo.

Variables

View Source
var ErrTokenExpired = errors.New("the Identity Center sign-in has expired")

ErrTokenExpired means the owner has to sign in again; the suite skips on it.

Functions

func Errorf

func Errorf(t testing.TB, format string, args ...any)

func Fatalf

func Fatalf(t testing.TB, format string, args ...any)

func LoadIdentities

func LoadIdentities() (map[string]Identity, error)

LoadIdentities parses WARDYN_LIVE_IDENTITIES_FILE: an object keyed by role ("admin", "member", "norole").

func LoadSSOToken

func LoadSSOToken(now time.Time) (string, error)

LoadSSOToken reads WARDYN_LIVE_AWS_SSO_TOKEN_FILE.

func Logf

func Logf(t testing.TB, format string, args ...any)

Logf, Errorf, Fatalf and Skipf are the only ways a live suite writes output.

func ModelAllowed

func ModelAllowed(id string) bool

ModelAllowed reports whether id is on the allow-list.

func ReadSecretFile

func ReadSecretFile(name string) ([]byte, error)

ReadSecretFile reads the file whose path is in env var name. It refuses a file inside the checkout, where a stray `git add` would publish it, and its errors name the variable, never the path or the contents.

func Redact

func Redact(s string) string

Redact masks every credential- or identity-shaped substring of s.

func Require

func Require(t testing.TB, gate string, names ...string)

Require skips t unless gate is "1" and every name is set. The message names the variables and never prints a value.

func RequireAccount

func RequireAccount(want, got string) error

RequireAccount refuses unless the credential's account is the capped one.

func SignV4

func SignV4(req *http.Request, body []byte, c Creds, region, service string, now time.Time)

SignV4 signs req with AWS Signature Version 4, over host, x-amz-date and, when present, content-type and the session token.

func Skipf

func Skipf(t testing.TB, format string, args ...any)

Types

type Bedrock

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

Bedrock is a client that has already proven it holds member-account credentials. The only way to get one is NewMemberBedrock.

func NewMemberBedrock

func NewMemberBedrock(ctx context.Context, cfg BedrockConfig, ssoToken string, ep Endpoints, hc *http.Client) (*Bedrock, error)

NewMemberBedrock exchanges the Identity Center token for role credentials on cfg.AccountID and then refuses unless STS says those credentials belong to exactly that account.

func (*Bedrock) Converse

func (b *Bedrock) Converse(ctx context.Context, prompt string, maxTokens int) (string, error)

Converse makes one model call. It refuses a max_tokens above MaxTokens and any call past the process's budget, before anything is sent.

type BedrockConfig

type BedrockConfig struct {
	AccountID, RoleName, SSORegion, Region, Model string
	MaxCalls                                      int
}

BedrockConfig is the validated WARDYN_LIVE_BEDROCK_* environment.

func LoadBedrockConfig

func LoadBedrockConfig(getenv func(string) string) (BedrockConfig, error)

LoadBedrockConfig validates the suite's environment. Anything outside the limits is an error, never clamped into range.

type Creds

type Creds struct{ AccessKeyID, SecretAccessKey, SessionToken string }

Creds are temporary role credentials.

type Endpoints

type Endpoints struct{ Portal, STS, Bedrock string }

Endpoints are the three AWS base URLs the suite talks to; tests point them at local fakes.

func DefaultEndpoints

func DefaultEndpoints(c BedrockConfig) Endpoints

DefaultEndpoints returns the real regional endpoints.

type Identity

type Identity struct {
	StorageState string `json:"storage_state"`
	APIToken     string `json:"api_token"`
}

Identity is one test identity's entry in WARDYN_LIVE_IDENTITIES_FILE. The Playwright suites read storage_state; the Go suites read api_token.

type SSOToken

type SSOToken struct {
	AccessToken string    `json:"accessToken"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

SSOToken is the part of an AWS CLI `sso login` cache file the suite uses.

Jump to

Keyboard shortcuts

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