testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package testutil provides shared test fixtures for cells/accesscore tests.

IMPORTANT: This package MUST NOT be imported by production code. It is scoped under internal/ so only cells/accesscore/** can reach it; archtest rule LAYER-TESTUTIL further enforces the rule.

Why a non-_test.go file: the helpers are needed across multiple sibling packages (cells/accesscore/slices/{identitymanage,sessionlogout,rbaccheck}/...); _test.go visibility cannot cross package boundaries.

Verified: no production (non-_test.go) file imports this package (confirmed by `git grep -l "cells/accesscore/internal/testutil" -- '*.go' ':!*_test.go'` returning empty output).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RealRefreshStore

func RealRefreshStore(t testing.TB) refresh.Store

RealRefreshStore returns a ready-to-use in-memory refresh.Store for unit tests. It uses a permissive policy suitable for test scenarios.

func RealSessionRepo

func RealSessionRepo(t testing.TB) *session.MemStore

RealSessionRepo returns a ready-to-use in-memory session.Store for unit tests. It wires the canonical test Protocol (sessiontest.Protocol — JTI-ref fingerprint, AuthzEpoch ordering, all CredentialEvents enabled) and a real clock. The returned store is safe for concurrent use (MemStore has an internal RWMutex).

sessiontest.Protocol lives in runtime/auth/session/sessiontest/ so that SESSION-PROTOCOL-COMPOSITION-ROOT-01 archtest covers Protocol construction inside the allowlisted path; this helper itself does not call session.NewProtocol directly (session.MustNewProtocol was deleted in B2-K-02).

func TestID

func TestID(label string) string

TestID returns a deterministic canonical lowercase UUID for the given label. Used so handler-level tests pass the UUID-validator added in PR-A45 while keeping the source readable (label = test fixture identity).

Types

type RecordingWriter

type RecordingWriter struct {
	Entries []outbox.Entry
	Err     error
}

RecordingWriter is test-only and does NOT satisfy L2 durability semantics (no retry, no idempotency, no transactional row visibility). Production code must use adapters/postgres OutboxWriter.

It records every Entry written to it. Tests assert against Entries to verify L2 OutboxFact semantics (transactional outbox row presence, EventType, payload shape, eventId).

Set Err to simulate failure for negative-path tests; when Err is non-nil, Write returns Err immediately and Entries is not appended (rolling-back callers must observe the error propagating from RunInTx).

func (*RecordingWriter) Write

func (w *RecordingWriter) Write(_ context.Context, entry outbox.Entry) error

Write implements outbox.Writer.

Jump to

Keyboard shortcuts

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