(t *testing.T)
| 1538 | router.ServeHTTP(rec, req) |
| 1539 | |
| 1540 | if rec.Code != http.StatusBadRequest { |
| 1541 | t.Fatalf("status = %d, want %d: %s", rec.Code, http.StatusBadRequest, rec.Body.String()) |
| 1542 | } |
| 1543 | if !strings.Contains(rec.Body.String(), "SecretRef.Namespace") { |
| 1544 | t.Fatalf("expected explicit namespace validation error, got %s", rec.Body.String()) |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | func TestPutWarehouseRejectsCrossTenantSecretReference(t *testing.T) { |
| 1549 | store := newFakeAPIStore() |
| 1550 | store.orgs["analytics"] = &configstore.Org{Name: "analytics"} |
| 1551 | router := newTestAPIRouter(store) |
| 1552 | |
| 1553 | body := []byte(`{ |
| 1554 | "worker_identity": { |
| 1555 | "namespace": "tenant-a" |
| 1556 | }, |
| 1557 | "metadata_store_credentials": { |
| 1558 | "namespace": "tenant-b", |
| 1559 | "name": "analytics-metadata", |
| 1560 | "key": "dsn" |
| 1561 | } |
| 1562 | }`) |
| 1563 | |
| 1564 | req := httptest.NewRequest(http.MethodPut, "/api/v1/orgs/analytics/warehouse", bytes.NewReader(body)) |
| 1565 | req.Header.Set("Content-Type", "application/json") |
| 1566 | rec := httptest.NewRecorder() |
| 1567 | router.ServeHTTP(rec, req) |
nothing calls this directly
no test coverage detected