@@ -5,24 +5,24 @@ metadata:
55spec :
66 description : |
77 Validates that resources injected via NATS AUDIT_EVENTS with tenant metadata carried
8- in user.extra fields are correctly indexed with _tenant/_tenant_type fields and that
9- search results expose tenant.name and tenant.type. Since project control planes are
10- not available in the test environment, this test directly publishes crafted audit
11- events to NATS to simulate the multi-tenant audit event indexing path.
8+ in top-level audit event annotations are correctly indexed with _tenant/_tenant_type
9+ fields and that search results expose tenant.name and tenant.type. Since project
10+ control planes are not available in the test environment, this test directly publishes
11+ crafted audit events to NATS to simulate the multi-tenant audit event indexing path.
1212
1313 This exercises the Indexer.Start() path (not ReindexConsumer), which:
1414 1. Consumes from the AUDIT_EVENTS stream on subject audit.k8s.activity.
1515 2. Iterates all active ResourceIndexPolicies and evaluates responseObject against
1616 each policy's CEL conditions.
17- 3. Calls extractTenantFromAuditEvent() to read tenant identity from
18- user.extra["iam .miloapis.com/parent- type"] and
19- user.extra["iam .miloapis.com/parent- name"].
20- 4. Falls back to "platform"/"platform" when user.extra is absent.
17+ 3. Calls extractTenantFromAuditEvent() to read tenant identity from the top-level
18+ annotations["platform .miloapis.com/scope. type"] and
19+ annotations["platform .miloapis.com/scope. name"] fields of the audit event .
20+ 4. Falls back to "platform"/"platform" when top-level annotations are absent.
2121
2222 Covers:
2323 - A1: Project-tenant resource is searchable with tenant.name and tenant.type set.
24- - A2: Platform-tenant resource (no user.extra ) is searchable with fallback
25- tenant.name="platform" and tenant.type="platform".
24+ - A2: Platform-tenant resource (no top-level annotations ) is searchable with
25+ fallback tenant.name="platform" and tenant.type="platform".
2626 - A3: Mixed search returns both results with correct per-result tenant metadata.
2727 - _tenant/_tenant_type internal fields are not exposed on the resource object.
2828
@@ -97,16 +97,16 @@ spec:
9797 timeout : 120s
9898 content : |
9999 # Event A: project-tenant resource.
100- # user.extra carries iam .miloapis.com/parent- type and parent-name so the
101- # indexer's extractTenantFromAuditEvent() will resolve the tenant as
102- # type="Project", name="e2e-audit-test-project".
103- EVENT_A='{"auditID":"e2e-audit-project-event-001","verb":"create","objectRef":{"apiGroup":"rbac.authorization.k8s.io","apiVersion":"v1","resource":"rolebindings","name":"e2e-audit-project-role","namespace":"default","uid":"e2e-audit-project-uid-00000001"},"responseObject":{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"RoleBinding","metadata":{"name":"e2e-audit-project-role","namespace":"default","uid":"e2e-audit-project-uid-00000001","labels":{"e2e-multi-tenant-audit":"true"},"annotations":{"e2e.search.test/service":"audit-project-service-mt-rn2","platform.miloapis.com/scope.type":"Project","platform.miloapis.com/scope.name":"e2e-audit-test-project "}},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role","name":"view"},"subjects":[]},"user":{"extra":{"iam.miloapis.com/parent-type":["project"],"iam.miloapis.com/parent-name":["e2e-audit-test-project"]}}}'
100+ # Top-level annotations field carries platform .miloapis.com/scope. type and
101+ # scope.name so the indexer's extractTenantFromAuditEvent() will resolve
102+ # the tenant as type="Project", name="e2e-audit-test-project".
103+ EVENT_A='{"auditID":"e2e-audit-project-event-001","verb":"create","annotations":{"platform.miloapis.com/scope.type":"Project","platform.miloapis.com/scope.name":"e2e-audit-test-project"}," objectRef":{"apiGroup":"rbac.authorization.k8s.io","apiVersion":"v1","resource":"rolebindings","name":"e2e-audit-project-role","namespace":"default","uid":"e2e-audit-project-uid-00000001"},"responseObject":{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"RoleBinding","metadata":{"name":"e2e-audit-project-role","namespace":"default","uid":"e2e-audit-project-uid-00000001","labels":{"e2e-multi-tenant-audit":"true"},"annotations":{"e2e.search.test/service":"audit-project-service-mt-rn2"}},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role","name":"view"},"subjects":[]},"user":{"extra":{"iam.miloapis.com/parent-type":["project"],"iam.miloapis.com/parent-name":["e2e-audit-test-project"]}}}'
104104
105105 # Event B: platform-tenant resource.
106- # No "user" field at all — exercises the fallback path in
106+ # No top-level annotations field — exercises the fallback path in
107107 # extractTenantFromAuditEvent() that returns "platform"/"platform"
108- # when user.extra is nil .
109- EVENT_B='{"auditID":"e2e-audit-platform-event-001","verb":"create","objectRef":{"apiGroup":"rbac.authorization.k8s.io","apiVersion":"v1","resource":"rolebindings","name":"e2e-audit-platform-role","namespace":"default","uid":"e2e-audit-platform-uid-00000001"},"responseObject":{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"RoleBinding","metadata":{"name":"e2e-audit-platform-role","namespace":"default","uid":"e2e-audit-platform-uid-00000001","labels":{"e2e-multi-tenant-audit":"true"},"annotations":{"e2e.search.test/service":"audit-platform-service-mt-rn2","platform.miloapis.com/scope.type":"platform","platform.miloapis.com/scope.name":"platform" }},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role","name":"view"},"subjects":[]}}'
108+ # when top-level annotations are absent .
109+ EVENT_B='{"auditID":"e2e-audit-platform-event-001","verb":"create","objectRef":{"apiGroup":"rbac.authorization.k8s.io","apiVersion":"v1","resource":"rolebindings","name":"e2e-audit-platform-role","namespace":"default","uid":"e2e-audit-platform-uid-00000001"},"responseObject":{"apiVersion":"rbac.authorization.k8s.io/v1","kind":"RoleBinding","metadata":{"name":"e2e-audit-platform-role","namespace":"default","uid":"e2e-audit-platform-uid-00000001","labels":{"e2e-multi-tenant-audit":"true"},"annotations":{"e2e.search.test/service":"audit-platform-service-mt-rn2"}},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role","name":"view"},"subjects":[]}}'
110110
111111 # Store event payloads in a ConfigMap so they can be mounted into the
112112 # Job container without shell escaping issues.
0 commit comments