Documentation
¶
Overview ¶
Package e2eseed creates deterministic OSS fixtures for API and DAC tests.
Index ¶
- func CountKnownTables(ctx context.Context, configDB, logsDB *gorm.DB) (map[string]int64, error)
- func InitEncryption(opts Options)
- func OpenDB(dialect, dsn string) (*gorm.DB, error)
- func SeedEnv(prefix string) map[string]string
- func WriteEnvFile(path string, env map[string]string) error
- func WriteJSONFile(path string, value any) error
- type ExpectedManifest
- type Options
- type Shape
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountKnownTables ¶
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 WriteEnvFile ¶
WriteEnvFile writes deterministic environment values.
func WriteJSONFile ¶
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 ¶
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 ¶
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.