e2eseed

package
v1.3.16 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package e2eseed creates deterministic OSS fixtures for API and DAC tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountKnownTables

func CountKnownTables(ctx context.Context, configDB, logsDB *gorm.DB) (map[string]int64, error)

CountKnownTables returns row counts for tables touched by the shared seed.

func InitEncryption

func InitEncryption(opts Options)

InitEncryption initializes Bifrost field encryption for DBs containing encrypted rows.

func OpenDB

func OpenDB(dialect, dsn string) (*gorm.DB, error)

OpenDB opens a supported GORM database.

func SeedEnv

func SeedEnv(prefix string) map[string]string

SeedEnv returns deterministic values shared by seeders and tests.

func WriteEnvFile

func WriteEnvFile(path string, env map[string]string) error

WriteEnvFile writes deterministic environment values.

func WriteJSONFile

func WriteJSONFile(path string, value any) error

WriteJSONFile writes a pretty JSON file.

Types

type ExpectedManifest

type ExpectedManifest struct {
	Prefix    string              `json:"prefix"`
	Personas  map[string]string   `json:"personas"`
	Shapes    []Shape             `json:"shapes"`
	LogIDs    map[string][]string `json:"log_ids"`
	MCPLogIDs map[string][]string `json:"mcp_log_ids"`
}

ExpectedManifest records seeded IDs and expected DAC visibility.

func BuildExpectedManifest

func BuildExpectedManifest(prefix string, logRowsPerShape int) ExpectedManifest

BuildExpectedManifest returns the expected DAC visibility document. Each shape gets logRowsPerShape contiguous log IDs and an equal number of MCP log IDs so visibility tests can assert exact set membership for either table.

type Options

type Options struct {
	Prefix          string
	ConfigPath      string
	EncryptionKey   string
	ConfigDialect   string
	ConfigDSN       string
	LogsDialect     string
	LogsDSN         string
	LogRowsPerShape int
	BatchSize       int
	OutputEnvPath   string
	DryRun          bool
}

Options controls the shared seed dataset.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns defaults for local e2e seeding.

func NormalizeOptions

func NormalizeOptions(opts Options) (Options, error)

NormalizeOptions applies default values to unset options.

type Shape

type Shape struct {
	Name           string   `json:"name"`
	UserID         string   `json:"user_id,omitempty"`
	TeamID         string   `json:"team_id,omitempty"`
	CustomerID     string   `json:"customer_id,omitempty"`
	BusinessUnitID string   `json:"business_unit_id,omitempty"`
	VirtualKeyID   string   `json:"virtual_key_id,omitempty"`
	Marker         string   `json:"marker"`
	VisibleTo      []string `json:"visible_to"`
}

Shape describes one DAC ownership combination.

func BuildShapes

func BuildShapes(prefix string) []Shape

BuildShapes returns the DAC ownership matrix.

The set is built by enumerating all 15 non-empty subsets of the four DAC dimensions {VirtualKey, UserID, TeamID, BusinessUnitID}, all flavoured with tiggings-side values so the tiggings-flavoured personas see them, plus three appended shapes for negative coverage:

  • user-not-in-tiggings: outside user + BU (cross-team isolation)
  • outside-team-virtual-key: outside user + team + BU + VK
  • legacy-unowned: no DAC dimensions (fail-closed for non-admin)

CustomerID is set together with BusinessUnitID when the B dimension is present; the two columns are conceptually paired in the seeded dataset.

The VirtualKey value for each tiggings shape is teamVK when the team dimension is present without a user, so the team-only VK ownership path (governance_virtual_keys.team_id) gets exercised. Every other VK-bearing shape uses userVK so the user-attached VK ownership path is exercised too.

type Summary

type Summary struct {
	Prefix          string            `json:"prefix"`
	LogRowsPerShape int               `json:"log_rows_per_shape"`
	SeedEnv         map[string]string `json:"seed_env"`
	Expected        ExpectedManifest  `json:"expected"`
	TableCounts     map[string]int64  `json:"table_counts"`
	DryRun          bool              `json:"dry_run"`
	GeneratedAt     time.Time         `json:"generated_at"`
}

Summary is returned after a seed run.

func SeedBase

func SeedBase(ctx context.Context, configDB, logsDB *gorm.DB, opts Options) (*Summary, error)

SeedBase writes the OSS-owned seed graph.

Jump to

Keyboard shortcuts

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