Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test: drop the CLI-driven gateway tests and the additional privilege tests
Claude732b3a390698
diff --git a/backend/e2e-test/routes/v1/additional-privilege-legacy.spec.ts b/backend/e2e-test/routes/v1/additional-privilege-legacy.spec.tsdeleted file mode 100644index 00d700564b..0000000000--- a/backend/e2e-test/routes/v1/additional-privilege-legacy.spec.ts+++ /dev/null@@ -1,219 +0,0 @@-import { OrgMembershipRole, ProjectMembershipRole, TableName } from "@app/db/schemas";--// Additional privileges are refused on every project created today: only projects that existed before-// the legacy-privileges migration carry isLegacyAdditionalPrivilegesEnabled, and no route sets it. The-// flag is written straight to the table so the behaviour those projects still rely on stays covered.-import { createIsolatedOrgAndProject } from "e2e-test/testUtils/fixtures";-import { addIdentityToProject, createIdentityActor } from "e2e-test/testUtils/identities";-import { overrideLicenseFeatures } from "e2e-test/testUtils/license";-import { pollUntil } from "e2e-test/testUtils/poll";-import { addUserMembership, createUser, createUserAccessToken, deleteUsers } from "e2e-test/testUtils/users";--const READ_SECRETS = [{ subject: "secrets", action: ["describeSecret", "readValue"] }];--describe("Additional privileges on a legacy project", () => {- let orgId: string;- let projectId: string;- let authToken: string;- let cleanup: () => Promise<void>;- const users: string[] = [];-- beforeAll(async () => {- ({ orgId, projectId, authToken, cleanup } = await createIsolatedOrgAndProject("legacy-privileges"));- await testDb(TableName.Project).where({ id: projectId }).update({ isLegacyAdditionalPrivilegesEnabled: true });- });-- afterAll(async () => {- await cleanup();- await deleteUsers(users);- });-- const listSecrets = (token: string) =>- testServer.inject({- method: "GET",- url: "/api/v3/secrets/raw",- headers: { authorization: `Bearer ${token}` },- query: { workspaceId: projectId, environment: "dev", secretPath: "/" }- });-- const noAccessIdentity = async () => {- const identity = await createIdentityActor({ orgId, authToken, role: OrgMembershipRole.Member });- await addIdentityToProject({- projectId,- identityId: identity.identityId,- role: ProjectMembershipRole.NoAccess,- authToken- });- return identity;- };-- const waitForStatus = (token: string, status: number) =>- pollUntil({- describe: `secret listing to answer ${status}`,- read: async () => (await listSecrets(token)).statusCode,- done: (code) => code === status,- timeoutMs: 20_000- });-- test("an identity privilege grants access, and deleting it takes the access away", async () => {- const identity = await noAccessIdentity();- expect((await listSecrets(identity.authToken)).statusCode).toBe(403);-- const created = await testServer.inject({- method: "POST",- url: "/api/v2/identity-project-additional-privilege",- headers: { authorization: `Bearer ${authToken}` },- body: {- identityId: identity.identityId,- projectId,- slug: "read-dev",- permissions: READ_SECRETS,- type: { isTemporary: false }- }- });- expect(created.statusCode, created.payload).toBe(200);- await waitForStatus(identity.authToken, 200);-- const deleted = await testServer.inject({- method: "DELETE",- url: `/api/v2/identity-project-additional-privilege/${created.json().privilege.id as string}`,- headers: { authorization: `Bearer ${authToken}` }- });- expect(deleted.statusCode, deleted.payload).toBe(200);- await waitForStatus(identity.authToken, 403);- }, 60_000);-- test("a user privilege grants access, and deleting it takes the access away", async () => {- const user = await createUser("legacy-privilege-user");- users.push(user.userId);- await addUserMembership({ userId: user.userId, orgId, role: OrgMembershipRole.Member });- const projectMembershipId = await addUserMembership({- userId: user.userId,- orgId,- projectId,- role: ProjectMembershipRole.NoAccess- });- const userToken = await createUserAccessToken({ userId: user.userId, orgId });- expect((await listSecrets(userToken)).statusCode).toBe(403);-- const created = await testServer.inject({- method: "POST",- url: "/api/v1/user-project-additional-privilege",- headers: { authorization: `Bearer ${authToken}` },- body: { projectMembershipId, slug: "read-dev", permissions: READ_SECRETS, type: { isTemporary: false } }- });- expect(created.statusCode, created.payload).toBe(200);- await waitForStatus(userToken, 200);-- const deleted = await testServer.inject({- method: "DELETE",- url: `/api/v1/user-project-additional-privilege/${created.json().privilege.id as string}`,- headers: { authorization: `Bearer ${authToken}` }- });- expect(deleted.statusCode, deleted.payload).toBe(200);- await waitForStatus(userToken, 403);- }, 60_000);-- test("a temporary privilege whose window has ended grants nothing", async () => {- const identity = await noAccessIdentity();-- const created = await testServer.inject({- method: "POST",- url: "/api/v2/identity-project-additional-privilege",- headers: { authorization: `Bearer ${authToken}` },- body: {- identityId: identity.identityId,- projectId,- slug: "expired-read",- permissions: READ_SECRETS,- type: {- isTemporary: true,- temporaryMode: "relative",- temporaryRange: "1h",- temporaryAccessStartTime: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString()- }- }- });- expect(created.statusCode, created.payload).toBe(200);-- expect((await listSecrets(identity.authToken)).statusCode).toBe(403);- });-});--// Only the legacy privilege system compares a grant with the actor's own permissions; the new one-// checks assign-additional-privileges alone. New orgs use the new system and no route turns it off,-// so the flag is written, as group-legacy-privilege.spec.ts does.-describe("Additional privileges on the legacy privilege system", () => {- let orgId: string;- let projectId: string;- let authToken: string;- let cleanup: () => Promise<void>;- let restoreLicense: () => void;-- beforeAll(async () => {- restoreLicense = overrideLicenseFeatures({ rbac: true });- ({ orgId, projectId, authToken, cleanup } = await createIsolatedOrgAndProject("legacy-privilege-boundary"));- await testDb(TableName.Project).where({ id: projectId }).update({ isLegacyAdditionalPrivilegesEnabled: true });- await testDb(TableName.Organization).where({ id: orgId }).update({ shouldUseNewPrivilegeSystem: false });- });-- afterAll(async () => {- await cleanup();- restoreLicense();- });-- test("an actor can grant a privilege within its own permissions but not one broader than them", async () => {- const slug = `granter-${orgId.slice(0, 8)}`;- const role = await testServer.inject({- method: "POST",- url: `/api/v1/projects/${projectId}/roles`,- headers: { authorization: `Bearer ${authToken}` },- body: {- slug,- name: slug,- permissions: [- { subject: "secrets", action: ["describeSecret", "readValue"] },- { subject: "identity", action: ["read", "edit", "grant-privileges"] }- ]- }- });- expect(role.statusCode, role.payload).toBe(200);- const actor = await createIdentityActor({ orgId, authToken, role: OrgMembershipRole.Member });- const added = await testServer.inject({- method: "POST",- url: `/api/v1/projects/${projectId}/memberships/identities/${actor.identityId}`,- headers: { authorization: `Bearer ${authToken}` },- body: { roles: [{ role: slug }] }- });- expect(added.statusCode, added.payload).toBe(200);- const target = await createIdentityActor({ orgId, authToken, role: OrgMembershipRole.Member });- await addIdentityToProject({- projectId,- identityId: target.identityId,- role: ProjectMembershipRole.NoAccess,- authToken- });- const grant = (privilegeSlug: string, permissions: unknown) =>- testServer.inject({- method: "POST",- url: "/api/v2/identity-project-additional-privilege",- headers: { authorization: `Bearer ${actor.authToken}` },- body: {- identityId: target.identityId,- projectId,- slug: privilegeSlug,- permissions,- type: { isTemporary: false }- }- });-- const within = await grant("within", READ_SECRETS);- expect(within.statusCode, within.payload).toBe(200);-- const broader = await grant("too-broad", [{ subject: "role", action: ["create", "edit", "delete"] }]);- expect(broader.statusCode, broader.payload).toBe(403);- expect(broader.json().error).toBe("PermissionBoundaryError");- const privileges = await testDb(TableName.AdditionalPrivilege).where({ actorIdentityId: target.identityId });- expect(privileges.map((p) => p.name)).toEqual(["within"]);- });-});diff --git a/tests/cmd/fakenet/main.go b/tests/cmd/fakenet/main.goindex 0666ebb478..e2dda23291 100644--- a/tests/cmd/fakenet/main.go+++ b/tests/cmd/fakenet/main.go@@ -70,20 +70,6 @@ func main() {log.Fatalf("fakenet: admin listener: %v", http.ListenAndServe(":8080", srv.Admin(ca)))}()- // A Kubernetes API server reached through a gateway arrives as a raw TCP tunnel with- // Host: localhost, so it is told apart by port, as API servers conventionally listen- // on 6443, rather than by name.- k8s, err := tls.Listen("tcp", fmt.Sprintf(":%d", kubernetes.Port), ca.TLSConfig())- if err != nil {- log.Fatalf("fakenet: %v", err)- }- go func() {- log.Fatalf("fakenet: kubernetes listener: %v", http.Serve(k8s, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- r.Host = kubernetes.Service.Host()- srv.ServeHTTP(w, r)- })))- }()-ln, err := tls.Listen("tcp", ":443", ca.TLSConfig())if err != nil {log.Fatalf("fakenet: %v", err)diff --git a/tests/docs/writing-tests.md b/tests/docs/writing-tests.mdindex 8e034c67b6..8dc42df92a 100644--- a/tests/docs/writing-tests.md+++ b/tests/docs/writing-tests.md@@ -51,9 +51,6 @@ such as a rotation target database, are added with `harness.WithInfra(...)`. Insenvironment, such as `RELAY_AUTH_SECRET`, is set with `harness.WithInfisicalEnv(k, v)`,which only an `Isolated` package may use.-A container one test owns, such as a relay or gateway agent, is started with-`h.RunContainer(...)` and stopped when the test ends (`suites/gateway/forwarding_test.go`).-## Structure- Setup in about eight lines, the action as one call, one to three assertions. A longerdiff --git a/tests/fakes/kubernetes/kubernetes.go b/tests/fakes/kubernetes/kubernetes.goindex ac5561a21c..37ff1ad02f 100644--- a/tests/fakes/kubernetes/kubernetes.go+++ b/tests/fakes/kubernetes/kubernetes.go@@ -26,14 +26,6 @@ func (s service) Host() string { return s.host }// URL is what an identity's kubernetesHost is set to.func (s service) URL() string { return "https://" + s.host }-// Port is where fakenet also serves the API server, routed by port rather than by-// name, for requests that arrive through a gateway's TCP tunnel with Host: localhost.-const Port = 6443--// TunnelURL is the kubernetesHost to use when Infisical reaches the cluster through a-// gateway.-func (s service) TunnelURL() string { return "https://" + s.host + ":6443" }-// Scope is the reviewer JWT. Attaching Kubernetes auth probes /version with no// credential first, which a real API server answers anonymously; it holds no state, so// those probes share one scope.diff --git a/tests/harness/container.go b/tests/harness/container.godeleted file mode 100644index dc48223194..0000000000--- a/tests/harness/container.go+++ /dev/null@@ -1,80 +0,0 @@-package harness--import (- "context"- "testing"-- "github.com/Infisical/infisical/tests/infra"- "github.com/Infisical/infisical/tests/infra/fakenet"- "github.com/Infisical/infisical/tests/internal/id"-)--// TestContainer is a container one test started, such as a relay or gateway agent.-// It is stopped when the test ends.-type TestContainer struct {- // Name is its address on the shared network, for Infisical and sibling- // containers to dial: the spec's Alias when one was given.- Name string-- c infra.Container-}--// Stop stops the container before the test ends, for a test whose claim is what-// happens when it goes away.-func (c *TestContainer) Stop(t *testing.T) {- t.Helper()- if err := c.c.Stop(context.WithoutCancel(t.Context())); err != nil {- t.Fatalf("harness: stopping %s: %v", c.Name, err)- }-}--// Logs is the container's output so far.-func (c *TestContainer) Logs(t *testing.T) string {- t.Helper()- out, err := c.c.Logs(context.WithoutCancel(t.Context()))- if err != nil {- return "harness: reading logs of " + c.Name + ": " + err.Error()- }- return out-}--// RunContainer starts a container for one test, on the network Infisical is on and-// resolving through fakenet as Infisical does, and stops it at cleanup. module names-// it; the spec's Name, Network and Labels are filled in here.-//-// Set Alias when the address has to be known before the container starts, such as a-// relay whose host Infisical records before the agent can enroll. It must be unique.-//-// Its output is logged when the test fails, since an agent that never connected is-// usually explained only there.-func (s *Stack) RunContainer(t *testing.T, module string, spec infra.ContainerSpec) *TestContainer {- t.Helper()-- parts := infra.NameParts{Scope: infra.Test, ScopeID: id.Short() + id.Short(), Module: module}- spec.Name = infra.ContainerName(parts)- if spec.Alias == "" {- spec.Alias = spec.Name- }- spec.Network = infra.NetworkName- spec.Labels = infra.Labels(parts, infra.Workspace())- if len(spec.DNS) == 0 {- spec.DNS = []string{fakenet.IP}- }-- runner := infra.NewRunner(infra.Workspace(), s.log)- c, err := runner.Run(t.Context(), spec)- if err != nil {- t.Fatalf("harness: starting %s: %v", spec.Name, err)- }- tc := &TestContainer{Name: spec.Alias, c: c}-- t.Cleanup(func() {- if t.Failed() {- t.Logf("harness: output of %s:\n%s", tc.Name, tc.Logs(t))- }- // A container the test already stopped answers with an error here, which is- // the outcome wanted anyway.- _ = c.Stop(context.WithoutCancel(context.Background()))- })- return tc-}diff --git a/tests/suites/gateway/forwarding_test.go b/tests/suites/gateway/forwarding_test.godeleted file mode 100644index 29ec6a6a52..0000000000--- a/tests/suites/gateway/forwarding_test.go+++ /dev/null@@ -1,300 +0,0 @@-package gateway_test--import (- "net/http"- "testing"- "time"-- "github.com/Infisical/infisical/tests/clients/api"- "github.com/Infisical/infisical/tests/fixture"- "github.com/Infisical/infisical/tests/harness"- "github.com/Infisical/infisical/tests/infra"- "github.com/Infisical/infisical/tests/internal/apierr"- "github.com/Infisical/infisical/tests/internal/id"- "github.com/Infisical/infisical/tests/internal/spec"- "github.com/Infisical/infisical/tests/internal/wait"- "github.com/google/uuid"- "github.com/stretchr/testify/require"-)--// The image under test ships the Infisical CLI, so the agents run the build a customer-// would pair with this server.-const agentImage = "infisical-test:local"--// agentDomain is where the agents reach Infisical: its container on the shared network,-// over plain http, which is what the server listens on.-func agentDomain(h *harness.Stack) string { return h.App().BaseURL(infra.Internal) }--// startRelay runs a relay agent whose recorded host is its own container's address.-func startRelay(t *testing.T, h *harness.Stack, tn *harness.Tenant) relayView {- t.Helper()- name := relayName()- res := createRelay(t, tn.Admin.API, name, name)- requireStatus(t, http.StatusOK, res.StatusCode(), res.Body)- relay := relayView{ID: res.JSON200.Id, Name: name, Host: name}- h.RunContainer(t, "relay", infra.ContainerSpec{- Image: agentImage,- Alias: name,- Command: []string{"infisical", "relay", "start", "--telemetry=false",- "--name=" + name, "--enroll-method=token", "--token=" + relayToken(t, tn, relay.ID),- "--domain=" + agentDomain(h)},- })- return relay-}--// startGateway runs a gateway agent for an existing token-auth gateway, through relay.-func startGateway(t *testing.T, h *harness.Stack, tn *harness.Tenant, gw gatewayView, relay relayView) *harness.TestContainer {- t.Helper()- return h.RunContainer(t, "gateway", infra.ContainerSpec{- Image: agentImage,- Command: []string{"infisical", "gateway", "start", gw.Name, "--telemetry=false",- "--enroll-method=token", "--token=" + enrollmentToken(t, tn, gw.ID),- "--domain=" + agentDomain(h), "--target-relay-name=" + relay.Name},- })-}--func waitHealthy(t *testing.T, tn *harness.Tenant, gatewayID uuid.UUID) gatewayView {- t.Helper()- var gw gatewayView- wait.Until(t, "the gateway to record a heartbeat", func() bool {- gw = getGateway(t, tn, gatewayID)- return gw.Heartbeat != nil- })- return gw-}--// healthyGateway is a token-auth gateway whose agent is connected through relay.-func healthyGateway(t *testing.T, h *harness.Stack, tn *harness.Tenant, relay relayView) (gatewayView, *harness.TestContainer) {- t.Helper()- gw := newGateway(t, tn)- c := startGateway(t, h, tn, gw, relay)- waitHealthy(t, tn, gw.ID)- return gw, c-}--// dynamicSecret is a Postgres dynamic secret on the target that Infisical reaches-// through route, a {"gatewayId": ...} or {"gatewayPoolId": ...} pair.-type dynamicSecret struct {- name string- proj *fixture.Project-}--func createDynamicSecret(t *testing.T, tn *harness.Tenant, target *fixture.PostgresTarget, route map[string]any) (*api.CreateDynamicSecretResponse, dynamicSecret) {- t.Helper()- proj := fixture.NewProject(t, tn, fixture.WithProjectType("secret-manager"))- inputs := map[string]any{- "client": "postgres",- "host": target.Host,- "port": target.Port,- "database": target.Database,- "username": target.User,- "password": target.Password,- "creationStatement": `CREATE ROLE "{{username}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';`,- "revocationStatement": `DROP ROLE "{{username}}";`,- }- for k, v := range route {- inputs[k] = v- }- ds := dynamicSecret{name: "ds-" + id.Short(), proj: proj}- res, err := tn.Admin.API.CreateDynamicSecretWithBodyWithResponse(t.Context(), "application/json", jsonBody(t, map[string]any{- "projectSlug": proj.Slug,- "environmentSlug": "dev",- "path": "/",- "name": ds.name,- "provider": map[string]any{"type": "sql-database", "inputs": inputs},- "defaultTTL": "1h",- }))- require.NoError(t, err)- return res, ds-}--func (d dynamicSecret) lease(t *testing.T) *api.CreateDynamicSecretLeaseResponse {- t.Helper()- path := "/"- res, err := d.proj.Tenant().Admin.API.CreateDynamicSecretLeaseWithResponse(t.Context(), api.CreateDynamicSecretLeaseJSONRequestBody{- DynamicSecretName: d.name, ProjectSlug: d.proj.Slug, EnvironmentSlug: "dev", Path: &path,- })- require.NoError(t, err)- return res-}--func leasedUsername(t *testing.T, res *api.CreateDynamicSecretLeaseResponse) (string, string) {- t.Helper()- data, _ := res.JSON200.Data.(map[string]any)- username, _ := data["DB_USERNAME"].(string)- password, _ := data["DB_PASSWORD"].(string)- require.NotEmpty(t, username, "the lease carries no DB_USERNAME: %v", data)- return username, password-}--func TestGatewayForwarding_Health(t *testing.T) {- t.Parallel()- h := harness.From(t)-- t.Run("should show the gateway healthy with a fresh heartbeat once its agent connects through the relay", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- relay := startRelay(t, h, tn)- gw := newGateway(t, tn)-- // Action- startGateway(t, h, tn, gw, relay)-- // Assert- healthy := waitHealthy(t, tn, gw.ID)- require.WithinDuration(t, time.Now(), *healthy.Heartbeat, time.Minute)- require.NotNil(t, healthy.HeartbeatTTL)- require.Positive(t, *healthy.HeartbeatTTL)- require.Equal(t, relay.ID, *healthy.RelayID)- })-}--func TestGatewayForwarding_DynamicSecret(t *testing.T) {- t.Parallel()- h := harness.From(t)-- t.Run("should lease a postgres dynamic secret through the gateway and create the role on the target", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- target := fixture.OpenPostgresTarget(t, tn)- gw, _ := healthyGateway(t, h, tn, startRelay(t, h, tn))- created, ds := createDynamicSecret(t, tn, target, map[string]any{"gatewayId": gw.ID})- requireStatus(t, http.StatusOK, created.StatusCode(), created.Body)-- // Action- res := ds.lease(t)-- // Assert- requireStatus(t, http.StatusOK, res.StatusCode(), res.Body)- username, password := leasedUsername(t, res)- target.DropRoleAtCleanup(t, username)- require.True(t, target.RoleExists(t, username))- require.NoError(t, target.Login(t, username, password))- })-- t.Run("should fail the lease once the gateway's agent stops", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- target := fixture.OpenPostgresTarget(t, tn)- gw, agentContainer := healthyGateway(t, h, tn, startRelay(t, h, tn))- created, ds := createDynamicSecret(t, tn, target, map[string]any{"gatewayId": gw.ID})- requireStatus(t, http.StatusOK, created.StatusCode(), created.Body)- agentContainer.Stop(t)-- // Action- res := ds.lease(t)-- // Assert- requireStatus(t, http.StatusBadRequest, res.StatusCode(), res.Body)- require.Contains(t, apierr.Message(res.Body), "Failed to establish gateway mTLS")- })-}--func TestGatewayForwarding_Pool(t *testing.T) {- t.Parallel()- h := harness.From(t)-- // pooled is a pool of two healthy gateways sharing one relay.- pooled := func(t *testing.T, tn *harness.Tenant) (uuid.UUID, []*harness.TestContainer, []uuid.UUID) {- t.Helper()- relay := startRelay(t, h, tn)- poolID := newPool(t, tn)- var agents []*harness.TestContainer- var ids []uuid.UUID- for range 2 {- gw, c := healthyGateway(t, h, tn, relay)- added := addToPool(t, tn.Admin.API, poolID, gw.ID)- requireStatus(t, http.StatusOK, added.StatusCode(), added.Body)- agents = append(agents, c)- ids = append(ids, gw.ID)- }- return poolID, agents, ids- }-- t.Run("should keep serving through the pool while a stopped member still looks healthy", func(t *testing.T) {- t.Parallel()- spec.Why(t, `Infisical has not noticed the stopped member, so it can still select it: every- call succeeding means a call that lands on it is retried on the live member. Which- member served a call is not observable over HTTP; the retry itself is unit tested in- gateway-pool-failover.test.ts.`)-- // Setup- tn := h.NewTenant(t)- target := fixture.OpenPostgresTarget(t, tn)- poolID, agents, ids := pooled(t, tn)- agents[0].Stop(t)-- // Action- var statuses []int- for range 4 {- res := createPostgresConnection(t, tn.Admin.API, target, map[string]any{"gatewayPoolId": poolID})- statuses = append(statuses, res.StatusCode())- }-- // Assert- require.Equal(t, []int{http.StatusOK, http.StatusOK, http.StatusOK, http.StatusOK}, statuses)- stopped := getGateway(t, tn, ids[0])- require.NotNil(t, stopped.HeartbeatTTL)- require.Positive(t, *stopped.HeartbeatTTL, "the stopped member was already marked down, so it was never selectable")- })-- t.Run("should answer that the pool has no healthy gateways when every member is down", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- target := fixture.OpenPostgresTarget(t, tn)- poolID, agents, ids := pooled(t, tn)- for i, c := range agents {- c.Stop(t)- probed, err := tn.Admin.API.TriggerGatewayHeartbeatWithResponse(t.Context(), ids[i].String())- require.NoError(t, err)- requireStatus(t, http.StatusBadRequest, probed.StatusCode(), probed.Body)- }-- // Action- res := createPostgresConnection(t, tn.Admin.API, target, map[string]any{"gatewayPoolId": poolID})-- // Assert- requireStatus(t, http.StatusBadRequest, res.StatusCode(), res.Body)- require.Equal(t, "Gateway pool has no healthy gateways.", apierr.Message(res.Body))- })-}--// Revoking clears the gateway's transports, so routing refuses it at once rather than-// handing out connection details while the agent's open tunnel lives on.-func TestGatewayForwarding_Revoke(t *testing.T) {- t.Parallel()- h := harness.From(t)-- t.Run("should refuse a lease through a gateway as soon as it is revoked", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- target := fixture.OpenPostgresTarget(t, tn)- gw, _ := healthyGateway(t, h, tn, startRelay(t, h, tn))- created, ds := createDynamicSecret(t, tn, target, map[string]any{"gatewayId": gw.ID})- requireStatus(t, http.StatusOK, created.StatusCode(), created.Body)- revoked, err := tn.Admin.API.RevokeGatewayAccessWithResponse(t.Context(), gw.ID)- require.NoError(t, err)- requireStatus(t, http.StatusOK, revoked.StatusCode(), revoked.Body)-- // Action- res := ds.lease(t)-- // Assert- if res.StatusCode() == http.StatusOK {- username, _ := leasedUsername(t, res)- target.DropRoleAtCleanup(t, username)- }- requireStatus(t, http.StatusBadRequest, res.StatusCode(), res.Body)- require.Equal(t, "Gateway does not have a reachable transport configured", apierr.Message(res.Body))- })-}diff --git a/tests/suites/gateway/kubernetes_test.go b/tests/suites/gateway/kubernetes_test.godeleted file mode 100644index 4024cd2d9c..0000000000--- a/tests/suites/gateway/kubernetes_test.go+++ /dev/null@@ -1,78 +0,0 @@-package gateway_test--import (- "net/http"- "testing"-- "github.com/Infisical/infisical/tests/clients/api"- "github.com/Infisical/infisical/tests/fakes/kubernetes"- "github.com/Infisical/infisical/tests/fixture"- "github.com/Infisical/infisical/tests/harness"- "github.com/Infisical/infisical/tests/internal/apierr"- "github.com/stretchr/testify/require"-)--func TestGatewayForwarding_Kubernetes(t *testing.T) {- t.Parallel()- h := harness.From(t)-- t.Run("should review a machine identity's Kubernetes token through a gateway", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- gw, _ := healthyGateway(t, h, tn, startRelay(t, h, tn))- cluster := kubernetes.Open(t, fixture.FakenetAdmin(t, tn))- identity := tn.NewMachineIdentity(t)- attached, err := tn.Admin.API.AttachKubernetesAuthWithResponse(t.Context(), identity.ID.String(), api.AttachKubernetesAuthJSONRequestBody{- KubernetesHost: new(kubernetes.Service.TunnelURL()),- TokenReviewerJwt: new(cluster.ReviewerJWT),- GatewayId: new(gw.ID),- VerifyTlsCertificate: new(false),- AllowedNamespaces: "payments",- AllowedNames: "api",- })- require.NoError(t, err)- require.NotNilf(t, attached.JSON200, "attaching Kubernetes auth through the gateway returned %d: %s", attached.StatusCode(), apierr.Body(attached.Body))- saToken := cluster.ServiceAccountToken(t, "payments", "api")-- // Action- res, err := tn.Anonymous(t).LoginWithKubernetesAuthWithResponse(t.Context(), api.LoginWithKubernetesAuthJSONRequestBody{- IdentityId: identity.ID.String(), Jwt: saToken,- })-- // Assert- require.NoError(t, err)- require.NotNilf(t, res.JSON200, "login returned %d: %s", res.StatusCode(), apierr.Body(res.Body))- cluster.ExpectEvent(t, func(e kubernetes.TokenReviewed) bool { return e.Token == saToken })- })-- t.Run("should refuse deleting a gateway another gateway reviews Kubernetes tokens through, naming it", func(t *testing.T) {- t.Parallel()-- // Setup- tn := h.NewTenant(t)- reviewer, _ := healthyGateway(t, h, tn, startRelay(t, h, tn))- cluster := kubernetes.Open(t, fixture.FakenetAdmin(t, tn))- dependentName := gatewayName()- dependent := createGateway(t, tn.Admin.API, dependentName, map[string]any{- "method": "kubernetes",- "kubernetesHost": kubernetes.Service.TunnelURL(),- "tokenReviewerJwt": cluster.ReviewerJWT,- "gatewayId": reviewer.ID,- "verifyTlsCertificate": false,- "allowedNamespaces": "infisical",- "allowedNames": "gateway",- })- requireStatus(t, http.StatusOK, dependent.StatusCode(), dependent.Body)-- // Action- res, err := tn.Admin.API.DeleteGatewayWithResponse(t.Context(), reviewer.ID.String())-- // Assert- require.NoError(t, err)- requireStatus(t, http.StatusBadRequest, res.StatusCode(), res.Body)- require.Contains(t, apierr.Message(res.Body), "reviews Kubernetes tokens for '"+dependentName+"'")- require.Contains(t, gatewayIDs(t, tn.Admin.API), reviewer.ID)- })-}diff --git a/tests/suites/secretmanager/access/additional_privilege_test.go b/tests/suites/secretmanager/access/additional_privilege_test.godeleted file mode 100644index 0bb2015741..0000000000--- a/tests/suites/secretmanager/access/additional_privilege_test.go+++ /dev/null@@ -1,125 +0,0 @@-package access_test--import (- "bytes"- "encoding/json"- "fmt"- "net/http"- "testing"- "time"-- "github.com/Infisical/infisical/tests/clients/api"- "github.com/Infisical/infisical/tests/fixture"- "github.com/Infisical/infisical/tests/harness"- "github.com/Infisical/infisical/tests/internal/apierr"- "github.com/stretchr/testify/require"-)--func TestAdditionalPrivilege_Create(t *testing.T) {- t.Parallel()- h := harness.From(t)-- jsonBody := func(t *testing.T, body map[string]any) *bytes.Reader {- t.Helper()- raw, err := json.Marshal(body)- require.NoError(t, err)- return bytes.NewReader(raw)- }- readSecrets := []map[string]any{{"subject": "secrets", "action": "read"}}-- routes := []struct {- name string- call func(t *testing.T, proj *fixture.Project, user, identity *harness.Principal) (int, []byte)- }{- {"the user privilege route", func(t *testing.T, proj *fixture.Project, user, _ *harness.Principal) (int, []byte) {- res, err := proj.Tenant().Admin.API.CreateUserProjectAdditionalPrivilegeWithBodyWithResponse(t.Context(), "application/json",- jsonBody(t, map[string]any{- "projectMembershipId": membershipID(t, proj, user),- "permissions": readSecrets,- "type": map[string]any{"isTemporary": false},- }))- require.NoError(t, err)- return res.StatusCode(), res.Body- }},- {"the v1 permanent identity privilege route", func(t *testing.T, proj *fixture.Project, _, identity *harness.Principal) (int, []byte) {- res, err := proj.Tenant().Admin.API.CreateIdentityProjectPermanentPrivilegeV1WithBodyWithResponse(t.Context(), "application/json",- jsonBody(t, map[string]any{- "identityId": identity.ID.String(),- "projectSlug": proj.Slug,- "permissions": readSecrets,- }))- require.NoError(t, err)- return res.StatusCode(), res.Body- }},- {"the v1 temporary identity privilege route", func(t *testing.T, proj *fixture.Project, _, identity *harness.Principal) (int, []byte) {- res, err := proj.Tenant().Admin.API.CreateIdentityProjectTemporaryPrivilegeV1WithBodyWithResponse(t.Context(), "application/json",- jsonBody(t, map[string]any{- "identityId": identity.ID.String(),- "projectSlug": proj.Slug,- "permissions": readSecrets,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().UTC().Format(time.RFC3339),- }))- require.NoError(t, err)- return res.StatusCode(), res.Body- }},- {"the v2 identity privilege route", func(t *testing.T, proj *fixture.Project, _, identity *harness.Principal) (int, []byte) {- res, err := proj.Tenant().Admin.API.CreateIdentityProjectAdditionalPrivilegeWithBodyWithResponse(t.Context(), "application/json",- jsonBody(t, map[string]any{- "identityId": identity.ID.String(),- "projectId": proj.ID,- "permissions": readSecrets,- "type": map[string]any{"isTemporary": false},- }))- require.NoError(t, err)- return res.StatusCode(), res.Body- }},- }-- for _, route := range routes {- t.Run(fmt.Sprintf("should refuse %s on a new project and create nothing", route.name), func(t *testing.T) {- t.Parallel()-- // Setup- proj := fixture.NewProject(t, h.NewTenant(t), fixture.WithProjectType("secret-manager"))- user := proj.NewUser(t, fixture.WithRoles("viewer"))- identity := proj.NewMachineIdentity(t, fixture.WithRoles("viewer"))-- // Action- status, body := route.call(t, proj, user, identity)-- // Assert- require.Equalf(t, http.StatusBadRequest, status, "answered %s", apierr.Body(body))- require.Contains(t, string(body), "Additional privileges are not available")- require.Empty(t, userPrivileges(t, proj, user))- require.Empty(t, identityPrivileges(t, proj, identity))- })- }-}--func userPrivileges(t *testing.T, proj *fixture.Project, user *harness.Principal) []string {- t.Helper()- res, err := proj.Tenant().Admin.API.ListUserProjectAdditionalPrivilegesWithResponse(t.Context(),- &api.ListUserProjectAdditionalPrivilegesParams{ProjectMembershipId: membershipID(t, proj, user)})- require.NoError(t, err)- require.NotNilf(t, res.JSON200, "listing user privileges returned %d: %s", res.StatusCode(), apierr.Body(res.Body))- ids := []string{}- for _, p := range res.JSON200.Privileges {- ids = append(ids, p.Id.String())- }- return ids-}--func identityPrivileges(t *testing.T, proj *fixture.Project, identity *harness.Principal) []string {- t.Helper()- res, err := proj.Tenant().Admin.API.ListIdentityProjectAdditionalPrivilegesWithResponse(t.Context(),- &api.ListIdentityProjectAdditionalPrivilegesParams{IdentityId: identity.ID.String(), ProjectId: proj.ID})- require.NoError(t, err)- require.NotNilf(t, res.JSON200, "listing identity privileges returned %d: %s", res.StatusCode(), apierr.Body(res.Body))- ids := []string{}- for _, p := range res.JSON200.Privileges {- ids = append(ids, p.Id.String())- }- return ids-}