querytest

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package querytest provides adversarial, real-Git fixtures shared by the review application and its transport integration tests.

Index

Constants

View Source
const (
	Repository       = "https://example.test/acme/query-security.git"
	OverviewTarget   = "urn:change-saga:security:fragment:overview"
	LargeTarget      = "urn:change-saga:security:fragment:large"
	ActiveHTMLTarget = "urn:change-saga:security:fragment:active-html"
	ActiveSVGTarget  = "urn:change-saga:security:fragment:active-svg"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorAttack

type CursorAttack struct {
	Name  string
	Token string
}

CursorAttack is a syntactically hostile derivative of a valid opaque cursor.

func TamperedCursors

func TamperedCursors(valid string) []CursorAttack

TamperedCursors returns transport-safe cursor corruptions. The query API must classify all of them as invalid_argument and must not panic or expose cursor internals. Snapshot staleness is tested separately with AdvanceSagaSnapshot.

type FileState

type FileState struct {
	Path   string
	Mode   fs.FileMode
	Digest string
}

type Fixture

type Fixture struct {
	SourceDir string
	SagaRepo  string
	SagaRoot  string
	BaseOID   string
	// contains filtered or unexported fields
}

Fixture keeps the saga and its compared source in different Git worktrees. Query tests should always pass SourceDir explicitly; accidentally loading the source from SagaRepo makes this fixture fail instead of masking the bug.

func New

func New(t testing.TB) *Fixture

New creates two independent, clean Git repositories. The source repository has a base commit and one product commit. The saga repository contains a minimal valid v2 saga which compares those source revisions.

func (*Fixture) AddActiveFragments

func (f *Fixture) AddActiveFragments() (htmlTarget, svgTarget string)

AddActiveFragments creates HTML and SVG whose scripts have obvious sentinel effects if evaluated. Read APIs must return bounded inert bytes; they must never load either document into an executing renderer.

func (*Fixture) AddAmbiguousTargets

func (f *Fixture) AddAmbiguousTargets()

AddAmbiguousTargets creates two structurally distinct fragments with the same public target. A session must reject the saga instead of selecting one according to traversal order.

func (f *Fixture) AddEscapingAssetSymlink() string

AddEscapingAssetSymlink adds a non-entrypoint asset link. This distinction is important: the saga loader can remain valid while an asset enumerator still has to omit or reject the escaping link. This phase has no asset-content read operation, so callers should test metadata enumeration only.

func (f *Fixture) AddEscapingEntrypointSymlink() string

AddEscapingEntrypointSymlink replaces the overview entrypoint with a link to a secret outside the saga. Session opening must reject this as invalid_saga without returning the secret.

func (*Fixture) AddLargeFragment

func (f *Fixture) AddLargeFragment(size int) string

AddLargeFragment creates deterministic content without requiring a large checked-in fixture. Tests should request at least 1 MiB+1 to cross the documented maximum fragment chunk size.

func (*Fixture) AdvanceSagaSnapshot

func (f *Fixture) AdvanceSagaSnapshot()

AdvanceSagaSnapshot changes relevant fragment content without committing it. A cursor obtained before this call must not be accepted against the new snapshot.

func (*Fixture) AssertNoAbsolutePaths

func (f *Fixture) AssertNoAbsolutePaths(output string)

AssertNoAbsolutePaths checks the default diagnostic privacy contract.

func (*Fixture) AssertUnchanged

func (f *Fixture) AssertUnchanged(before TreeState)

AssertUnchanged fails if a read operation changed either worktree, staged content, or created a commit.

func (*Fixture) LeakedAbsolutePath

func (f *Fixture) LeakedAbsolutePath(output string) string

LeakedAbsolutePath returns the fixture root exposed by an application or CLI error, including its slash-normalized and JSON-escaped spelling. Empty means the output contains none of the fixture's absolute paths.

func (*Fixture) MakeInvalidManifest

func (f *Fixture) MakeInvalidManifest()

MakeInvalidManifest adds an unknown field. saga.Load returns a decode error for this case, which the query boundary must normalize to invalid_saga.

func (*Fixture) State

func (f *Fixture) State() TreeState

State returns the current state of both repositories.

func (*Fixture) WriteSaga

func (f *Fixture) WriteSaga(relative, content string)

WriteSaga writes a slash-relative path below the saga root.

func (*Fixture) WriteSource

func (f *Fixture) WriteSource(relative, content string)

WriteSource writes a slash-relative path below the source worktree.

type TreeState

type TreeState struct {
	Files        []FileState
	SourceHEAD   string
	SagaHEAD     string
	SourceStatus string
	SagaStatus   string
}

TreeState captures observable worktree and Git state while ignoring Git's mutable internal bookkeeping. It detects content changes, new files, permission changes, staging, and commits caused by a read request.

Jump to

Keyboard shortcuts

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