testsupport

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testsupport holds fixtures shared by the protocol proxies' test suites (PostgreSQL, MySQL, MongoDB, Oracle, SQL Server).

Nothing here carries the `integration` build tag. The SQL Server suite mints its grants from the same fixture but runs against an in-process fake, so it is untagged and would not otherwise be able to import a tagged helper. That costs nothing in the shipped binary: this package is only ever imported by _test.go files, so it is absent from `go list -deps .` and never links into dbbat itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateGrantWithControls

func CreateGrantWithControls(
	ctx context.Context,
	t *testing.T,
	dataStore *store.Store,
	userUID, databaseUID uuid.UUID,
	controls []string,
	opts ...GrantOption,
) (*store.Grant, error)

CreateGrantWithControls issues a grant carrying the given controls. Every grant is an *instance of a definition* and carries no shape of its own, so the definition has to exist first and be named by uid — an inline GrantDefinition on the grant is not enough (CreateGrant answers ErrGrantDefinitionRequired), which is what used to fail these suites at setup.

The definition's name/slug is randomized per call: a suite that seeds twice against one store would otherwise trip "grant definition with this slug already exists". Callers never have to think about it.

Types

type GrantOption

type GrantOption func(*store.GrantDefinition)

GrantOption tunes the definition a grant is minted from, for the suites that care about a field the common case never sets. It is an option rather than another parameter so the four suites that only ever pass controls keep reading as one line.

func WithApprovalPatterns

func WithApprovalPatterns(patterns ...string) GrantOption

WithApprovalPatterns puts approval-hold patterns on the definition — the RE2 patterns that suspend a matching statement until a second human releases it. The SQL Server suites are the ones that exercise holds.

func WithMaxBytesTransferred

func WithMaxBytesTransferred(maxBytes int64) GrantOption

WithMaxBytesTransferred puts a transfer quota on the definition — the cumulative wire-byte budget the limit guard enforces mid-stream. The Oracle suite uses it to trip a quota in the middle of a reply, which is the only way to observe the refusal that cuts into a call rather than answering one.

Jump to

Keyboard shortcuts

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