ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/integration/directory_integration_test.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/integration/directory_integration_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision9bde0f9a74b89d01980fa658e5253acda7528d0c
Branchper-tenant-routing
Path or archive memberinternal/integration/directory_integration_test.go
Original SHA-25666234730d1ad7b41dbcdfb3380921847ddb08817c8c868dafa1ed6cb36f6ad06
Git blob SHA46e16c6a60bad69933188518f5191d199512e733
Reading-copy SHA-25666234730d1ad7b41dbcdfb3380921847ddb08817c8c868dafa1ed6cb36f6ad06

Original source ↗

Every recorded occurrence

These 3 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/integration/directory_integration_test.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/integration/directory_integration_test.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/integration/directory_integration_test.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original

Recovered source transcript

//go:build integration package integration import ( "context" "errors" "testing" "github.com/google/uuid" "github.com/missionworkforce/missionmatch/internal/platform/directory" ) // TestTenantDirectoryRoundTrip proves the control plane tenant directory: the MIGRATOR registers a // tenant's database mapping, the APP role (the routing path) reads it, status and migration bookkeeping // update, and an unknown organization is a typed ErrUnknownTenant, never a fallback. This exercises the // 0020 catalog and the directory accessor against the staging database standing in as the control plane. func TestTenantDirectoryRoundTrip(t *testing.T) { ctx := context.Background() org := seedOrg(t) dbName := "tenant_" + org.String()[:8] // unique per org, satisfies the db_name UNIQUE and the name regex // Clean up the directory row so an active entry pointing at a database that this test never created // does not linger and fail a later migrate-all-tenants run. t.Cleanup(func() { _, _ = migrator.Exec(context.Background(), "DELETE FROM tenant_directory WHERE organization_id=$1", org) }) mig := directory.New(migrator) // provisioning writes (migrator role) app := directory.New(appDB.Pool) // routing reads (NOBYPASSRLS app role) if err := mig.Register(ctx, directory.TenantConn{ OrganizationID: org, DBName: dbName, Host: "100.94.8.94", Port: 5432, SecretRef: "tenant-" + org.String()[:8], Status: directory.StatusProvisioning, Cloud: "local", }); err != nil { t.Fatalf("register: %v", err) } // The app role (routing) can read the directory even though it never wrote it. got, err := app.Lookup(ctx, org) if err != nil { t.Fatalf("app lookup: %v", err) } if got.DBName != dbName || got.Host != "100.94.8.94" || got.SecretRef != "tenant-"+org.String()[:8] { t.Fatalf("lookup returned wrong row: %+v", got) } if got.Status != directory.StatusProvisioning { t.Fatalf("status = %q, want provisioning", got.Status) } // Lifecycle: provisioning to active, and migration bookkeeping. if err := mig.SetStatus(ctx, org, directory.StatusActive); err != nil { t.Fatalf("set status: %v", err) } if err := mig.SetMigrated(ctx, org, 20); err != nil { t.Fatalf("set migrated: %v", err) } got, _ = app.Lookup(ctx, org) if got.Status != directory.StatusActive { t.Fatalf("status after activate = %q", got.Status) } if got.LastMigratedVersion == nil || *got.LastMigratedVersion != 20 { t.Fatalf("last_migrated_version = %v, want 20", got.LastMigratedVersion) } // List(active) includes our tenant (the cross tenant migrator iterates this). list, err := app.List(ctx, directory.StatusActive) if err != nil { t.Fatalf("list: %v", err) } found := false for _, tc := range list { if tc.OrganizationID == org { found = true } } if !found { t.Fatal("active list must include the registered tenant") } // An unknown organization is a typed ErrUnknownTenant, never a fallback to another tenant. if _, err := app.Lookup(ctx, uuid.New()); !errors.Is(err, directory.ErrUnknownTenant) { t.Fatalf("unknown org must be ErrUnknownTenant, got %v", err) } }

Search equations, builds, manuscript text, and recovered sources.