Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/integration/tenant_mission_tag_integration_test.go |
| Original SHA-256 | dbd038f155b8db51609dc63062781c04f4162a2ebe14a2c19081e63e0c54a918 |
| Git blob SHA | 2a4e072ff76bd284e27d40137db9b48599456508 |
| Reading-copy SHA-256 | dbd038f155b8db51609dc63062781c04f4162a2ebe14a2c19081e63e0c54a918 |
Every recorded occurrence
These 15 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/integration/tenant_mission_tag_integration_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓101 lines · 4.4 KB
//go:build integration
// Phase 5a tenant mission tagging, exercised against a REAL Postgres with RLS in force. It seeds an org
// with a candidate whose headline mentions SIGINT, runs the tenant tagging service inside that org's
// context (so every read and write goes through RunInTenantTx as the NOBYPASSRLS application role), and
// asserts a candidate_mission_tags row with code SIGINT exists for that org and that a second org cannot
// see it (RLS isolation). Mission tags are never a scoring input and never reach the eeo schema; this test
// exercises the tagging service end to end and the tenancy guarantee, complementing the static
// mission_tags_integration_test which exercises the raw upsert.
package integration
import (
"context"
"testing"
"github.com/jackc/pgx/v5"
"github.com/missionworkforce/missionmatch/internal/modules/federalsignal"
"github.com/missionworkforce/missionmatch/internal/platform/database/dbgen"
"github.com/missionworkforce/missionmatch/internal/platform/missionclass"
)
func TestTenantTagServiceTagsCandidatesUnderRLS(t *testing.T) {
orgA, orgB := seedOrg(t), seedOrg(t)
// org A candidate whose headline mentions SIGINT, seeded via the migrator so the headline is set.
hn := "SIGINT collection analyst"
candA, err := dbgen.New(migrator).CreateCandidate(context.Background(), dbgen.CreateCandidateParams{
OrganizationID: orgA, FullName: "Alice Analyst", Headline: &hn, ClearanceLevel: "top_secret",
ClearancePoly: "none", ClearanceStatus: "active", Available: true,
})
if err != nil {
t.Fatalf("seed org A candidate: %v", err)
}
// An empty AliasIndex: the SIGINT tag comes from the literal keyword in the headline, so this test does
// not depend on the curated alias rows being present in the database under test.
idx := missionclass.NewAliasIndex(map[string]string{})
svc := federalsignal.NewTenantTagService(federalsignal.NewTenantTagRepo(appDB), idx)
// Tag org A's candidates in org A's context. Every read and write runs as the app role under RLS.
res, err := svc.TagCandidatesForOrg(ctxOrg(orgA))
if err != nil {
t.Fatalf("TagCandidatesForOrg (org A): %v", err)
}
if res.CandidatesScanned < 1 || res.CandidateTags < 1 {
t.Fatalf("org A tagging produced no tags: %+v", res)
}
// Org A MUST see exactly one SIGINT tag for its candidate, with the keyword mechanism.
var code, mechanism string
if err := appDB.RunInTenantTx(ctxOrg(orgA), func(ctx context.Context, tx pgx.Tx) error {
return tx.QueryRow(ctx,
"SELECT mission_code, mechanism FROM candidate_mission_tags WHERE candidate_id = $1 AND mission_code = 'SIGINT'",
candA.ID).Scan(&code, &mechanism)
}); err != nil {
t.Fatalf("org A read SIGINT tag: %v", err)
}
if code != "SIGINT" || mechanism != missionclass.MechKeyword {
t.Fatalf("org A SIGINT tag = code %q mechanism %q, want SIGINT/keyword", code, mechanism)
}
// Org B MUST NOT see org A's tag: a count under org B's session is zero (RLS default deny).
var nB int
if err := appDB.RunInTenantTx(ctxOrg(orgB), func(ctx context.Context, tx pgx.Tx) error {
return tx.QueryRow(ctx,
"SELECT count(*) FROM candidate_mission_tags WHERE candidate_id = $1", candA.ID).Scan(&nB)
}); err != nil {
t.Fatalf("org B count tags: %v", err)
}
if nB != 0 {
t.Fatalf("ISOLATION BREACH: org B saw %d of org A's candidate mission tags (want 0)", nB)
}
// And running the tagging service in org B's context tags nothing of org A's: org B has no candidates,
// so the read returns zero rows and the write set is empty, proving the service is fully RLS scoped.
resB, err := svc.TagCandidatesForOrg(ctxOrg(orgB))
if err != nil {
t.Fatalf("TagCandidatesForOrg (org B): %v", err)
}
if resB.CandidatesScanned != 0 || resB.CandidateTags != 0 {
t.Fatalf("org B tagging should scan and tag nothing (org A's candidate is invisible), got %+v", resB)
}
// Idempotency against the live database: a second run in org A keeps exactly one SIGINT tag.
if _, err := svc.TagCandidatesForOrg(ctxOrg(orgA)); err != nil {
t.Fatalf("second TagCandidatesForOrg (org A): %v", err)
}
var nA int
if err := appDB.RunInTenantTx(ctxOrg(orgA), func(ctx context.Context, tx pgx.Tx) error {
return tx.QueryRow(ctx,
"SELECT count(*) FROM candidate_mission_tags WHERE candidate_id = $1 AND mission_code = 'SIGINT'",
candA.ID).Scan(&nA)
}); err != nil {
t.Fatalf("org A recount SIGINT tag: %v", err)
}
if nA != 1 {
t.Fatalf("idempotency broken: org A has %d SIGINT tags after a second run (want 1)", nA)
}
}