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
feat: added more test
=06bc47f03b0a
diff --git a/backend-go/go.mod b/backend-go/go.modindex 3b21b843d2..47c2928e3a 100644--- a/backend-go/go.mod+++ b/backend-go/go.mod@@ -67,6 +67,7 @@ require (github.com/jackc/puddle/v2 v2.2.2 // indirectgithub.com/joho/godotenv v1.5.1 // indirectgithub.com/klauspost/compress v1.18.3 // indirect+ github.com/klauspost/cpuid/v2 v2.2.7 // indirectgithub.com/knadh/koanf/maps v0.1.2 // indirectgithub.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirectgithub.com/magiconair/properties v1.8.10 // indirectdiff --git a/backend-go/go.sum b/backend-go/go.sumindex b14e2b287a..70a3329b97 100644--- a/backend-go/go.sum+++ b/backend-go/go.sum@@ -159,8 +159,8 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAgithub.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=-github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=-github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=+github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=+github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI=github.com/knadh/koanf/parsers/dotenv v1.1.1 h1:vfiRFsxq0ouiVs4t+R/VVA3TMrX5+VH14iEX6J5B1s4=diff --git a/backend-go/internal/server/api/secretmanager/secrets/secrets_permission_integration_test.go b/backend-go/internal/server/api/secretmanager/secrets/secrets_permission_integration_test.goindex e2a773b524..0d53181783 100644--- a/backend-go/internal/server/api/secretmanager/secrets/secrets_permission_integration_test.go+++ b/backend-go/internal/server/api/secretmanager/secrets/secrets_permission_integration_test.go@@ -14,6 +14,7 @@ import (gensecrets "github.com/infisical/api/internal/server/gen/secrets""github.com/infisical/api/internal/services/auth""github.com/infisical/api/internal/services/permission"+ "github.com/infisical/api/internal/testutil/infra")// listSecrets is a helper that calls ListSecretsV4 with the given identity context.@@ -210,11 +211,11 @@ func TestIdentityCustomRole_EnvironmentScoped(t *testing.T) {nodejs.CreateSecret(t, proj.ID, "dev", "/", "DEV_SECRET", "dev-value")nodejs.CreateSecret(t, proj.ID, "staging", "/", "STAGING_SECRET", "staging-value")- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "dev-only-reader", "Dev Only Reader", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "dev-only-reader", "Dev Only Reader", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},- "conditions": map[string]any{+ Subject: "secrets",+ Action: []string{"read"},+ Conditions: map[string]any{"environment": "dev",},},@@ -258,11 +259,11 @@ func TestIdentityCustomRole_PathScoped(t *testing.T) {nodejs.CreateSecret(t, proj.ID, proj.EnvSlug, "/app/config", "CONFIG_SECRET", "config-value")nodejs.CreateSecret(t, proj.ID, proj.EnvSlug, "/other", "OTHER_SECRET", "other-value")- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "app-reader", "App Path Reader", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "app-reader", "App Path Reader", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},- "conditions": map[string]any{+ Subject: "secrets",+ Action: []string{"read"},+ Conditions: map[string]any{"secretPath": map[string]any{"$glob": "/app/**",},@@ -368,11 +369,11 @@ func TestGroupCustomRole_UserInheritsCustomPermissions(t *testing.T) {nodejs.CreateSecret(t, proj.ID, "dev", "/", "DEV_SECRET", "dev-value")nodejs.CreateSecret(t, proj.ID, "staging", "/", "STAGING_SECRET", "staging-value")- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "group-dev-reader", "Group Dev Reader", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "group-dev-reader", "Group Dev Reader", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},- "conditions": map[string]any{+ Subject: "secrets",+ Action: []string{"read"},+ Conditions: map[string]any{"environment": "dev",},},@@ -420,11 +421,11 @@ func TestIdentityAdditionalPrivilege_ExtendsRole(t *testing.T) {identity := nodejs.CreateIdentity(t, "addl-priv-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",- "conditions": map[string]any{+ Subject: "secrets",+ Action: "read",+ Conditions: map[string]any{"environment": "dev",},},@@ -465,20 +466,20 @@ func TestIdentityMultipleAdditionalPrivileges_Merge(t *testing.T) {nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")// Add two separate additional privileges- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",- "conditions": map[string]any{+ Subject: "secrets",+ Action: "read",+ Conditions: map[string]any{"environment": "dev",},},})- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",- "conditions": map[string]any{+ Subject: "secrets",+ Action: "read",+ Conditions: map[string]any{"environment": "staging",},},@@ -516,17 +517,17 @@ func TestIdentityTemporaryRole_ActiveGrantsAccess(t *testing.T) {nodejs.CreateSecret(t, proj.ID, proj.EnvSlug, "/", "TEMP_SECRET", "temp-value")identity := nodejs.CreateIdentity(t, "temp-active-identity")- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "no-access",- "isTemporary": false,+ Role: "no-access",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().UTC().Format(time.RFC3339),},})@@ -549,17 +550,17 @@ func TestIdentityTemporaryRole_ExpiredDeniesAccess(t *testing.T) {nodejs.CreateSecret(t, proj.ID, proj.EnvSlug, "/", "EXPIRED_SECRET", "expired-value")identity := nodejs.CreateIdentity(t, "temp-expired-identity")- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "no-access",- "isTemporary": false,+ Role: "no-access",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),},})@@ -582,17 +583,17 @@ func TestIdentityTemporaryRole_MixedWithPermanent(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-mixed-identity")// Permanent viewer + expired temporary admin- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "viewer",- "isTemporary": false,+ Role: "viewer",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),},})@@ -618,10 +619,10 @@ func TestIdentityTemporaryAdditionalPrivilege_Active(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-addl-active-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",+ Subject: "secrets",+ Action: "read",},}, "1h", time.Now().UTC().Format(time.RFC3339))@@ -645,10 +646,10 @@ func TestIdentityTemporaryAdditionalPrivilege_Expired(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-addl-expired-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",+ Subject: "secrets",+ Action: "read",},}, "1h", time.Now().Add(-2*time.Hour).UTC().Format(time.RFC3339))diff --git a/backend-go/internal/services/permission/permission_integration_test.go b/backend-go/internal/services/permission/permission_integration_test.goindex a6ba286750..ac7a475bd6 100644--- a/backend-go/internal/services/permission/permission_integration_test.go+++ b/backend-go/internal/services/permission/permission_integration_test.go@@ -416,10 +416,10 @@ func TestIdentityCustomRole_SecretsReadCreateOnly(t *testing.T) {nodejs := stack.NodeJS()// Create a custom role that allows only reading and creating secrets- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "secrets-read-create", "Secrets Read Create", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "secrets-read-create", "Secrets Read Create", []infra.Permission{{- "subject": "secrets",- "action": []string{"read", "create"},+ Subject: "secrets",+ Action: []string{"read", "create"},},})@@ -452,10 +452,10 @@ func TestIdentityCustomRole_SecretsReadCreateOnly(t *testing.T) {func TestUserCustomRole_SecretsReadCreateOnly(t *testing.T) {nodejs := stack.NodeJS()- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "user-secrets-rc", "User Secrets Read Create", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "user-secrets-rc", "User Secrets Read Create", []infra.Permission{{- "subject": "secrets",- "action": []string{"read", "create"},+ Subject: "secrets",+ Action: []string{"read", "create"},},})@@ -485,11 +485,11 @@ func TestIdentityCustomRole_EnvironmentScoped(t *testing.T) {nodejs := stack.NodeJS()// Create a custom role that allows reading secrets only in "dev" environment- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "dev-reader", "Dev Secret Reader", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "dev-reader", "Dev Secret Reader", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},- "conditions": map[string]any{+ Subject: "secrets",+ Action: []string{"read"},+ Conditions: map[string]any{"environment": "dev",},},@@ -521,11 +521,11 @@ func TestIdentityCustomRole_GlobSecretPath(t *testing.T) {nodejs := stack.NodeJS()// Create a custom role with $glob condition on secretPath- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "path-reader", "Path Scoped Reader", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "path-reader", "Path Scoped Reader", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},- "conditions": map[string]any{+ Subject: "secrets",+ Action: []string{"read"},+ Conditions: map[string]any{"secretPath": map[string]any{"$glob": "/app/**",},@@ -605,14 +605,14 @@ func TestGroupViewer_UserInheritsReadOnly(t *testing.T) {func TestGroupCustomRole_UserInheritsCustomPermissions(t *testing.T) {nodejs := stack.NodeJS()- customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "group-secrets-ro", "Group Secrets ReadOnly", []map[string]any{+ customRole := nodejs.CreateCustomProjectRole(t, proj.ID, "group-secrets-ro", "Group Secrets ReadOnly", []infra.Permission{{- "subject": "secrets",- "action": []string{"read"},+ Subject: "secrets",+ Action: []string{"read"},},{- "subject": "secret-folders",- "action": []string{"read"},+ Subject: "secret-folders",+ Action: []string{"read"},},})@@ -676,10 +676,10 @@ func TestIdentityAdditionalPrivilege_ExtendsRole(t *testing.T) {// Give identity viewer role (read-only) then add additional privilege for secret creationidentity := nodejs.CreateIdentity(t, "addl-priv-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "viewer")- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "create",+ Subject: "secrets",+ Action: "create",},})@@ -705,11 +705,11 @@ func TestIdentityAdditionalPrivilege_WithConditions(t *testing.T) {// Give identity no-access role, then add scoped additional privilegeidentity := nodejs.CreateIdentity(t, "addl-priv-scoped-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",- "conditions": map[string]any{+ Subject: "secrets",+ Action: "read",+ Conditions: map[string]any{"environment": "dev",},},@@ -732,21 +732,31 @@ func TestIdentityAdditionalPrivilege_WithConditions(t *testing.T) {func TestUserAdditionalPrivilege_ExtendsRole(t *testing.T) {nodejs := stack.NodeJS()- // The user additional privilege API is JWT-only (no identity token).- // Add bootstrap admin user to project so their userToken can make the call.- nodejs.AddUserToProject(t, proj.ID, nodejs.UserEmail(), []string{"admin"})+ // Create project using user JWT so bootstrap user is automatically a member.+ // This is needed because the user additional privilege API requires user JWT auth.+ testProj := nodejs.CreateProjectAsUser(t, "user-addl-priv-test")// Give user viewer role, then add additional privilege for secret edituser := nodejs.InviteAndCreateUser(t, "[email protected]")- nodejs.AddUserToProject(t, proj.ID, user.Email, []string{"viewer"})- nodejs.CreateUserAdditionalPrivilege(t, user.ID, proj.ID, []map[string]any{+ nodejs.AddUserToProjectAsUser(t, testProj.ID, user.Email, []string{"viewer"})+ nodejs.CreateUserAdditionalPrivilege(t, user.ID, testProj.ID, []infra.Permission{{- "subject": "secrets",- "action": "edit",+ Subject: "secrets",+ Action: "edit",},})- result := getProjectPermission(t, permission.ActorTypeUser, user.ID)+ // Use testProj.ID instead of the shared proj.ID+ svc := newPermissionService()+ result, err := svc.GetProjectPermission(context.Background(), &permission.GetProjectPermissionArgs{+ Actor: permission.ActorTypeUser,+ ActorID: uuid.MustParse(user.ID),+ ProjectID: testProj.ID,+ ActorAuthMethod: "",+ ActorOrgID: uuid.MustParse(nodejs.OrgID()),+ ActionProjectType: permission.ActionProjectTypeSecretManager,+ })+ require.NoError(t, err)ability := result.Permission.Ability// Base viewer permissions@@ -768,16 +778,16 @@ func TestIdentityMultipleAdditionalPrivileges_Merge(t *testing.T) {identity := nodejs.CreateIdentity(t, "multi-addl-priv-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",+ Subject: "secrets",+ Action: "read",},})- nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secret-folders",- "action": "read",+ Subject: "secret-folders",+ Action: "read",},})@@ -802,17 +812,17 @@ func TestIdentityTemporaryRole_ActiveGrantsAccess(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-role-active-identity")// API requires at least one permanent role; use no-access as the permanent base- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "no-access",- "isTemporary": false,+ Role: "no-access",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().UTC().Format(time.RFC3339),},})@@ -832,17 +842,17 @@ func TestIdentityTemporaryRole_ExpiredDeniesAccess(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-role-expired-identity")// Permanent no-access + expired temporary admin (started 2h ago, range 1h)- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "no-access",- "isTemporary": false,+ Role: "no-access",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),},})@@ -872,17 +882,17 @@ func TestIdentityTemporaryRole_MixedWithPermanent(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-role-mixed-identity")// Permanent viewer + expired temporary admin- nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []map[string]any{+ nodejs.AddIdentityToProjectWithRoles(t, proj.ID, identity.ID, []infra.RoleAssignment{{- "role": "viewer",- "isTemporary": false,+ Role: "viewer",+ IsTemporary: false,},{- "role": "admin",- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": "1h",- "temporaryAccessStartTime": time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),+ Role: "admin",+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: "1h",+ TemporaryAccessStartTime: time.Now().Add(-2 * time.Hour).UTC().Format(time.RFC3339),},})@@ -909,10 +919,10 @@ func TestIdentityTemporaryAdditionalPrivilege_ActiveGrantsAccess(t *testing.T) {identity := nodejs.CreateIdentity(t, "temp-addl-active-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")- nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",+ Subject: "secrets",+ Action: "read",},}, "1h", time.Now().UTC().Format(time.RFC3339))@@ -932,10 +942,10 @@ func TestIdentityTemporaryAdditionalPrivilege_ExpiredDeniesAccess(t *testing.T)identity := nodejs.CreateIdentity(t, "temp-addl-expired-identity")nodejs.AddIdentityToProject(t, proj.ID, identity.ID, "no-access")// Start 2h ago, range 1h → expired- nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []map[string]any{+ nodejs.CreateIdentityTemporaryAdditionalPrivilege(t, identity.ID, proj.ID, []infra.Permission{{- "subject": "secrets",- "action": "read",+ Subject: "secrets",+ Action: "read",},}, "1h", time.Now().Add(-2*time.Hour).UTC().Format(time.RFC3339))diff --git a/backend-go/internal/testutil/infra/nodejs.go b/backend-go/internal/testutil/infra/nodejs.goindex 9777976e72..34150cb598 100644--- a/backend-go/internal/testutil/infra/nodejs.go+++ b/backend-go/internal/testutil/infra/nodejs.go@@ -132,12 +132,12 @@ func startNodeJS(ctx context.Context, networkName string, files []testcontainers// bootstrap creates the initial admin user, org, and machine identity,// then logs in to obtain a user JWT. Uses log.Fatalf since it runs in TestMain.func (n *NodeJSService) bootstrap() {- var bootstrapResp map[string]any+ var bootstrapResp BootstrapResponseresp, err := n.client.R().- SetBody(map[string]any{- "email": "[email protected]",- "password": "testpassword123",- "organization": "test-org",+ SetBody(BootstrapRequest{+ Email: "[email protected]",+ Password: "testpassword123",+ Organization: "test-org",}).SetResult(&bootstrapResp).Post("/api/v1/admin/bootstrap")@@ -148,16 +148,16 @@ func (n *NodeJSService) bootstrap() {log.Fatalf("infra.bootstrap: returned %d: %s", resp.StatusCode(), resp.String())}- n.orgID = jsonStr(bootstrapResp, "organization.id")- n.identityToken = jsonStr(bootstrapResp, "identity.credentials.token")- n.userEmail = jsonStr(bootstrapResp, "user.email")- n.userID = jsonStr(bootstrapResp, "user.id")+ n.orgID = bootstrapResp.Organization.ID+ n.identityToken = bootstrapResp.Identity.Credentials.Token+ n.userEmail = bootstrapResp.User.Email+ n.userID = bootstrapResp.User.ID- var loginResp map[string]any+ var loginResp LoginResponseresp, err = n.client.R().- SetBody(map[string]any{- "email": n.userEmail,- "password": "testpassword123",+ SetBody(LoginRequest{+ Email: n.userEmail,+ Password: "testpassword123",}).SetResult(&loginResp).Post("/api/v3/auth/login")@@ -167,14 +167,13 @@ func (n *NodeJSService) bootstrap() {if resp.IsError() {log.Fatalf("infra.bootstrap: login returned %d: %s", resp.StatusCode(), resp.String())}- loginToken := jsonStr(loginResp, "accessToken")// Select organization to get an org-scoped JWT (required for org-level API calls).- var selectOrgResp map[string]any+ var selectOrgResp SelectOrgResponseresp, err = n.client.R().- SetHeader("Authorization", "Bearer "+loginToken).- SetBody(map[string]any{- "organizationId": n.orgID,+ SetHeader("Authorization", "Bearer "+loginResp.AccessToken).+ SetBody(SelectOrgRequest{+ OrganizationID: n.orgID,}).SetResult(&selectOrgResp).Post("/api/v3/auth/select-organization")@@ -184,19 +183,19 @@ func (n *NodeJSService) bootstrap() {if resp.IsError() {log.Fatalf("infra.bootstrap: select-org returned %d: %s", resp.StatusCode(), resp.String())}- n.userToken = jsonStr(selectOrgResp, "token")+ n.userToken = selectOrgResp.Token}// MustCreateProject creates a new project via the Node.js API.// Safe to call from TestMain — uses log.Fatalf on error.func (n *NodeJSService) MustCreateProject(name string) *ProjectSeed {- var projectResp map[string]any+ var projectResp CreateProjectResponseresp, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectName": name,- "slug": fmt.Sprintf("test-%s", name),- "type": "secret-manager",+ SetBody(CreateProjectRequest{+ ProjectName: name,+ Slug: fmt.Sprintf("test-%s", name),+ Type: "secret-manager",}).SetResult(&projectResp).Post("/api/v1/projects")@@ -208,8 +207,8 @@ func (n *NodeJSService) MustCreateProject(name string) *ProjectSeed {}return &ProjectSeed{- ID: jsonStr(projectResp, "project.id"),- Slug: jsonStr(projectResp, "project.slug"),+ ID: projectResp.Project.ID,+ Slug: projectResp.Project.Slug,EnvSlug: "dev",}}@@ -225,13 +224,13 @@ func (n *NodeJSService) CreateProject(t *testing.T, name string) *ProjectSeed {slug = slug[:36]}- var projectResp map[string]any+ var projectResp CreateProjectResponseresp, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectName": name,- "slug": slug,- "type": "secret-manager",+ SetBody(CreateProjectRequest{+ ProjectName: name,+ Slug: slug,+ Type: "secret-manager",}).SetResult(&projectResp).Post("/api/v1/projects")@@ -243,8 +242,8 @@ func (n *NodeJSService) CreateProject(t *testing.T, name string) *ProjectSeed {}return &ProjectSeed{- ID: jsonStr(projectResp, "project.id"),- Slug: jsonStr(projectResp, "project.slug"),+ ID: projectResp.Project.ID,+ Slug: projectResp.Project.Slug,EnvSlug: "dev",}}@@ -264,47 +263,17 @@ func (n *NodeJSService) DeleteProject(t *testing.T, projectID string) {}}-// jsonStr extracts a string value from a nested JSON map using dot-separated path.-func jsonStr(m map[string]any, path string) string {- keys := splitDotPath(path)- current := any(m)-- for _, key := range keys {- obj, ok := current.(map[string]any)- if !ok {- return ""- }- current = obj[key]- }-- s, _ := current.(string)- return s-}--func splitDotPath(path string) []string {- var keys []string- start := 0- for i := 0; i < len(path); i++ {- if path[i] == '.' {- keys = append(keys, path[start:i])- start = i + 1- }- }- keys = append(keys, path[start:])- return keys-}-// CreateIdentity creates a new machine identity in the bootstrap org.func (n *NodeJSService) CreateIdentity(t *testing.T, name string) *IdentitySeed {t.Helper()- var resp map[string]any+ var resp CreateIdentityResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "name": name,- "organizationId": n.orgID,- "role": "no-access",+ SetBody(CreateIdentityRequest{+ Name: name,+ OrganizationID: n.orgID,+ Role: "no-access",}).SetResult(&resp).Post("/api/v1/identities")@@ -316,7 +285,7 @@ func (n *NodeJSService) CreateIdentity(t *testing.T, name string) *IdentitySeed}return &IdentitySeed{- ID: jsonStr(resp, "identity.id"),+ ID: resp.Identity.ID,Name: name,}}@@ -327,8 +296,8 @@ func (n *NodeJSService) AddIdentityToProject(t *testing.T, projectID, identityIDr, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "role": role,+ SetBody(AddIdentityToProjectRequest{+ Role: role,}).Post(fmt.Sprintf("/api/v1/projects/%s/memberships/identities/%s", projectID, identityID))if err != nil {@@ -342,13 +311,13 @@ func (n *NodeJSService) AddIdentityToProject(t *testing.T, projectID, identityID// AddIdentityToProjectWithRoles adds a machine identity to a project with a roles array.// Each role entry can include temporary access fields (isTemporary, temporaryMode, temporaryRange,// temporaryAccessStartTime).-func (n *NodeJSService) AddIdentityToProjectWithRoles(t *testing.T, projectID, identityID string, roles []map[string]any) {+func (n *NodeJSService) AddIdentityToProjectWithRoles(t *testing.T, projectID, identityID string, roles []RoleAssignment) {t.Helper()r, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "roles": roles,+ SetBody(AddIdentityToProjectWithRolesRequest{+ Roles: roles,}).Post(fmt.Sprintf("/api/v1/projects/%s/memberships/identities/%s", projectID, identityID))if err != nil {@@ -368,9 +337,9 @@ func (n *NodeJSService) InviteAndCreateUser(t *testing.T, email string) *UserSee// 1. Invite user to org (requires user JWT auth with org context)r, err := n.client.R().SetAuthToken(n.userToken).- SetBody(map[string]any{- "inviteeEmails": []string{email},- "organizationId": n.orgID,+ SetBody(InviteToOrgRequest{+ InviteeEmails: []string{email},+ OrganizationID: n.orgID,}).Post("/api/v1/invite-org/signup")if err != nil {@@ -398,14 +367,27 @@ func (n *NodeJSService) InviteAndCreateUser(t *testing.T, email string) *UserSee}// AddUserToProject adds a user (by email) to a project with the given role slugs.+// Uses identity token for authentication.func (n *NodeJSService) AddUserToProject(t *testing.T, projectID, email string, roleSlugs []string) {t.Helper()+ n.addUserToProjectWithToken(t, projectID, email, roleSlugs, n.identityToken)+}++// AddUserToProjectAsUser adds a user (by email) to a project using the bootstrap user's JWT.+// Use this when the identity isn't a member of the project.+func (n *NodeJSService) AddUserToProjectAsUser(t *testing.T, projectID, email string, roleSlugs []string) {+ t.Helper()+ n.addUserToProjectWithToken(t, projectID, email, roleSlugs, n.userToken)+}++func (n *NodeJSService) addUserToProjectWithToken(t *testing.T, projectID, email string, roleSlugs []string, token string) {+ t.Helper()r, err := n.client.R().- SetAuthToken(n.identityToken).- SetBody(map[string]any{- "emails": []string{email},- "roleSlugs": roleSlugs,+ SetAuthToken(token).+ SetBody(AddUserToProjectRequest{+ Emails: []string{email},+ RoleSlugs: roleSlugs,}).Post(fmt.Sprintf("/api/v1/projects/%s/memberships", projectID))if err != nil {@@ -416,20 +398,55 @@ func (n *NodeJSService) AddUserToProject(t *testing.T, projectID, email string,}}+// CreateProjectAsUser creates a project using the bootstrap user's JWT.+// This makes the bootstrap user automatically a member of the project,+// which is needed for user-only APIs like user additional privileges.+func (n *NodeJSService) CreateProjectAsUser(t *testing.T, name string) *ProjectSeed {+ t.Helper()++ b := make([]byte, 4)+ rand.Read(b)+ slug := fmt.Sprintf("t-%s-%x", name, b)+ if len(slug) > 36 {+ slug = slug[:36]+ }++ var projectResp CreateProjectResponse+ resp, err := n.client.R().+ SetAuthToken(n.userToken).+ SetBody(CreateProjectRequest{+ ProjectName: name,+ Slug: slug,+ Type: "secret-manager",+ }).+ SetResult(&projectResp).+ Post("/api/v1/projects")+ if err != nil {+ t.Fatalf("infra.CreateProjectAsUser: request failed: %v", err)+ }+ if resp.IsError() {+ t.Fatalf("infra.CreateProjectAsUser: returned %d: %s", resp.StatusCode(), resp.String())+ }++ return &ProjectSeed{+ ID: projectResp.Project.ID,+ Slug: projectResp.Project.Slug,+ EnvSlug: "dev",+ }+}+// CreateCustomProjectRole creates a custom project role with the given permissions.// Requires the "rbac" EE feature to be enabled (see WithEEFeatures).-// Permissions is a slice of permission objects, each with "subject", "action", and-// optionally "conditions" and "inverted" fields.-func (n *NodeJSService) CreateCustomProjectRole(t *testing.T, projectID, slug, name string, permissions []map[string]any) *CustomRoleSeed {+func (n *NodeJSService) CreateCustomProjectRole(t *testing.T, projectID, slug, name string, permissions []Permission) *CustomRoleSeed {t.Helper()- var resp map[string]any+ var resp CreateCustomRoleResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "slug": slug,- "name": name,- "permissions": permissions,+ SetBody(CreateCustomRoleRequest{+ Slug: slug,+ Name: name,+ Permissions: permissions,}).SetResult(&resp).Post(fmt.Sprintf("/api/v1/projects/%s/roles", projectID))@@ -441,9 +458,9 @@ func (n *NodeJSService) CreateCustomProjectRole(t *testing.T, projectID, slug, n}return &CustomRoleSeed{- ID: jsonStr(resp, "role.id"),- Slug: jsonStr(resp, "role.slug"),- Name: jsonStr(resp, "role.name"),+ ID: resp.Role.ID,+ Slug: resp.Role.Slug,+ Name: resp.Role.Name,}}@@ -452,12 +469,12 @@ func (n *NodeJSService) CreateCustomProjectRole(t *testing.T, projectID, slug, nfunc (n *NodeJSService) CreateGroup(t *testing.T, name string) *GroupSeed {t.Helper()- var resp map[string]any+ var resp CreateGroupResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "name": name,- "role": "no-access",+ SetBody(CreateGroupRequest{+ Name: name,+ Role: "no-access",}).SetResult(&resp).Post("/api/v1/groups")@@ -469,9 +486,9 @@ func (n *NodeJSService) CreateGroup(t *testing.T, name string) *GroupSeed {}return &GroupSeed{- ID: jsonStr(resp, "id"),- Name: jsonStr(resp, "name"),- Slug: jsonStr(resp, "slug"),+ ID: resp.ID,+ Name: resp.Name,+ Slug: resp.Slug,}}@@ -484,7 +501,7 @@ func (n *NodeJSService) AddUserToGroup(t *testing.T, groupID, username string) {r, err := n.client.R().SetAuthToken(n.userToken).SetHeader("Content-Type", "application/json").- SetBody("{}").+ SetBody(struct{}{}).Post(fmt.Sprintf("/api/v1/groups/%s/users/%s", groupID, username))if err != nil {t.Fatalf("infra.AddUserToGroup: request failed: %v", err)@@ -500,8 +517,8 @@ func (n *NodeJSService) AddGroupToProject(t *testing.T, projectID, groupID, roler, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "role": role,+ SetBody(AddGroupToProjectRequest{+ Role: role,}).Post(fmt.Sprintf("/api/v1/projects/%s/memberships/groups/%s", projectID, groupID))if err != nil {@@ -514,18 +531,16 @@ func (n *NodeJSService) AddGroupToProject(t *testing.T, projectID, groupID, role// CreateIdentityAdditionalPrivilege creates a permanent additional privilege// for an identity in a project via the V2 Node.js API.-func (n *NodeJSService) CreateIdentityAdditionalPrivilege(t *testing.T, identityID, projectID string, permissions []map[string]any) {+func (n *NodeJSService) CreateIdentityAdditionalPrivilege(t *testing.T, identityID, projectID string, permissions []Permission) {t.Helper()r, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "identityId": identityID,- "projectId": projectID,- "permissions": permissions,- "type": map[string]any{- "isTemporary": false,- },+ SetBody(CreateIdentityPrivilegeRequest{+ IdentityID: identityID,+ ProjectID: projectID,+ Permissions: permissions,+ Type: PrivilegeType{IsTemporary: false},}).Post("/api/v2/identity-project-additional-privilege/")if err != nil {@@ -539,20 +554,20 @@ func (n *NodeJSService) CreateIdentityAdditionalPrivilege(t *testing.T, identity// CreateIdentityTemporaryAdditionalPrivilege creates a temporary additional privilege// for an identity in a project. temporaryRange is a duration string (e.g. "1h", "30s").// temporaryAccessStartTime is an ISO-8601 datetime string.-func (n *NodeJSService) CreateIdentityTemporaryAdditionalPrivilege(t *testing.T, identityID, projectID string, permissions []map[string]any, temporaryRange, temporaryAccessStartTime string) {+func (n *NodeJSService) CreateIdentityTemporaryAdditionalPrivilege(t *testing.T, identityID, projectID string, permissions []Permission, temporaryRange, temporaryAccessStartTime string) {t.Helper()r, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "identityId": identityID,- "projectId": projectID,- "permissions": permissions,- "type": map[string]any{- "isTemporary": true,- "temporaryMode": "relative",- "temporaryRange": temporaryRange,- "temporaryAccessStartTime": temporaryAccessStartTime,+ SetBody(CreateIdentityPrivilegeRequest{+ IdentityID: identityID,+ ProjectID: projectID,+ Permissions: permissions,+ Type: PrivilegeType{+ IsTemporary: true,+ TemporaryMode: "relative",+ TemporaryRange: temporaryRange,+ TemporaryAccessStartTime: temporaryAccessStartTime,},}).Post("/api/v2/identity-project-additional-privilege/")@@ -567,7 +582,7 @@ func (n *NodeJSService) CreateIdentityTemporaryAdditionalPrivilege(t *testing.T,// CreateUserAdditionalPrivilege creates a permanent additional privilege// for a user in a project via the Node.js API.// Requires looking up the project membership ID from the DB.-func (n *NodeJSService) CreateUserAdditionalPrivilege(t *testing.T, userID, projectID string, permissions []map[string]any) {+func (n *NodeJSService) CreateUserAdditionalPrivilege(t *testing.T, userID, projectID string, permissions []Permission) {t.Helper()if n.db == nil {@@ -585,12 +600,10 @@ func (n *NodeJSService) CreateUserAdditionalPrivilege(t *testing.T, userID, projr, err := n.client.R().SetAuthToken(n.userToken).- SetBody(map[string]any{- "projectMembershipId": membershipID,- "permissions": permissions,- "type": map[string]any{- "isTemporary": false,- },+ SetBody(CreateUserPrivilegeRequest{+ ProjectMembershipID: membershipID,+ Permissions: permissions,+ Type: PrivilegeType{IsTemporary: false},}).Post("/api/v1/user-project-additional-privilege/")if err != nil {@@ -613,15 +626,15 @@ type SecretSeed struct {func (n *NodeJSService) CreateSecret(t *testing.T, projectID, environment, secretPath, key, value string) *SecretSeed {t.Helper()- var resp map[string]any+ var resp CreateSecretResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectId": projectID,- "environment": environment,- "secretPath": secretPath,- "secretValue": value,- "type": "shared",+ SetBody(CreateSecretRequest{+ ProjectID: projectID,+ Environment: environment,+ SecretPath: secretPath,+ SecretValue: value,+ Type: "shared",}).SetResult(&resp).Post(fmt.Sprintf("/api/v4/secrets/%s", key))@@ -633,7 +646,7 @@ func (n *NodeJSService) CreateSecret(t *testing.T, projectID, environment, secre}return &SecretSeed{- ID: jsonStr(resp, "secret.id"),+ ID: resp.Secret.ID,Key: key,Value: value,Version: 1,@@ -644,16 +657,16 @@ func (n *NodeJSService) CreateSecret(t *testing.T, projectID, environment, secrefunc (n *NodeJSService) CreateSecretWithTags(t *testing.T, projectID, environment, secretPath, key, value string, tagIDs []string) *SecretSeed {t.Helper()- var resp map[string]any+ var resp CreateSecretResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectId": projectID,- "environment": environment,- "secretPath": secretPath,- "secretValue": value,- "type": "shared",- "tagIds": tagIDs,+ SetBody(CreateSecretRequest{+ ProjectID: projectID,+ Environment: environment,+ SecretPath: secretPath,+ SecretValue: value,+ Type: "shared",+ TagIDs: tagIDs,}).SetResult(&resp).Post(fmt.Sprintf("/api/v4/secrets/%s", key))@@ -665,7 +678,7 @@ func (n *NodeJSService) CreateSecretWithTags(t *testing.T, projectID, environmen}return &SecretSeed{- ID: jsonStr(resp, "secret.id"),+ ID: resp.Secret.ID,Key: key,Value: value,Version: 1,@@ -682,14 +695,14 @@ type FolderSeed struct {func (n *NodeJSService) CreateFolder(t *testing.T, projectID, environment, path, name string) *FolderSeed {t.Helper()- var resp map[string]any+ var resp CreateFolderResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectId": projectID,- "environment": environment,- "path": path,- "name": name,+ SetBody(CreateFolderRequest{+ ProjectID: projectID,+ Environment: environment,+ Path: path,+ Name: name,}).SetResult(&resp).Post("/api/v2/folders")@@ -701,7 +714,7 @@ func (n *NodeJSService) CreateFolder(t *testing.T, projectID, environment, path,}return &FolderSeed{- ID: jsonStr(resp, "folder.id"),+ ID: resp.Folder.ID,Name: name,}}@@ -715,16 +728,16 @@ type SecretImportSeed struct {func (n *NodeJSService) CreateSecretImport(t *testing.T, projectID, environment, path, importEnv, importPath string) *SecretImportSeed {t.Helper()- var resp map[string]any+ var resp CreateSecretImportResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "projectId": projectID,- "environment": environment,- "path": path,- "import": map[string]any{- "environment": importEnv,- "path": importPath,+ SetBody(CreateSecretImportRequest{+ ProjectID: projectID,+ Environment: environment,+ Path: path,+ Import: SecretImportTarget{+ Environment: importEnv,+ Path: importPath,},}).SetResult(&resp).@@ -737,7 +750,7 @@ func (n *NodeJSService) CreateSecretImport(t *testing.T, projectID, environment,}return &SecretImportSeed{- ID: jsonStr(resp, "secretImport.id"),+ ID: resp.SecretImport.ID,}}@@ -752,12 +765,12 @@ type EnvironmentSeed struct {func (n *NodeJSService) CreateEnvironment(t *testing.T, projectID, slug, name string) *EnvironmentSeed {t.Helper()- var resp map[string]any+ var resp CreateEnvironmentResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "slug": slug,- "name": name,+ SetBody(CreateEnvironmentRequest{+ Slug: slug,+ Name: name,}).SetResult(&resp).Post(fmt.Sprintf("/api/v1/projects/%s/environments", projectID))@@ -769,7 +782,7 @@ func (n *NodeJSService) CreateEnvironment(t *testing.T, projectID, slug, name st}return &EnvironmentSeed{- ID: jsonStr(resp, "environment.id"),+ ID: resp.Environment.ID,Slug: slug,Name: name,}@@ -786,13 +799,13 @@ type TagSeed struct {func (n *NodeJSService) CreateTag(t *testing.T, projectID, slug, name, color string) *TagSeed {t.Helper()- var resp map[string]any+ var resp CreateTagResponser, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "slug": slug,- "name": name,- "color": color,+ SetBody(CreateTagRequest{+ Slug: slug,+ Name: name,+ Color: color,}).SetResult(&resp).Post(fmt.Sprintf("/api/v1/projects/%s/tags", projectID))@@ -804,7 +817,7 @@ func (n *NodeJSService) CreateTag(t *testing.T, projectID, slug, name, color str}return &TagSeed{- ID: jsonStr(resp, "tag.id"),+ ID: resp.Tag.ID,Slug: slug,Name: name,}@@ -818,15 +831,15 @@ func (n *NodeJSService) GetIdentityAccessToken(t *testing.T, identityID string)// First, create a universal auth method for the identityr, err := n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "identityId": identityID,- "accessTokenTrustedIps": []map[string]any{{"ipAddress": "0.0.0.0/0"}},- "accessTokenTTL": 3600,- "accessTokenMaxTTL": 7200,- "accessTokenNumUsesLimit": 0,- "clientSecretTrustedIps": []map[string]any{{"ipAddress": "0.0.0.0/0"}},- "clientSecretNumUsesLimit": 0,- "isClientSecretRotationEnabled": false,+ SetBody(CreateUniversalAuthRequest{+ IdentityID: identityID,+ AccessTokenTrustedIPs: []IPAddress{{IPAddress: "0.0.0.0/0"}},+ AccessTokenTTL: 3600,+ AccessTokenMaxTTL: 7200,+ AccessTokenNumUsesLimit: 0,+ ClientSecretTrustedIPs: []IPAddress{{IPAddress: "0.0.0.0/0"}},+ ClientSecretNumUsesLimit: 0,+ IsClientSecretRotationEnabled: false,}).Post("/api/v1/auth/universal-auth/identities/" + identityID)if err != nil {@@ -837,13 +850,13 @@ func (n *NodeJSService) GetIdentityAccessToken(t *testing.T, identityID string)}// Then create a client secret- var clientSecretResp map[string]any+ var clientSecretResp CreateClientSecretResponser, err = n.client.R().SetAuthToken(n.identityToken).- SetBody(map[string]any{- "description": "test-client-secret",- "ttl": 0,- "numUsesLimit": 0,+ SetBody(CreateClientSecretRequest{+ Description: "test-client-secret",+ TTL: 0,+ NumUsesLimit: 0,}).SetResult(&clientSecretResp).Post("/api/v1/auth/universal-auth/identities/" + identityID + "/client-secrets")@@ -854,15 +867,15 @@ func (n *NodeJSService) GetIdentityAccessToken(t *testing.T, identityID string)t.Fatalf("infra.GetIdentityAccessToken: create client secret returned %d: %s", r.StatusCode(), r.String())}- clientID := jsonStr(clientSecretResp, "clientSecretData.clientId")- clientSecret := jsonStr(clientSecretResp, "clientSecretData.clientSecretPrefix") + jsonStr(clientSecretResp, "clientSecret")+ clientID := clientSecretResp.ClientSecretData.ClientID+ clientSecret := clientSecretResp.ClientSecretData.ClientSecretPrefix + clientSecretResp.ClientSecret// Finally, login to get the access token- var loginResp map[string]any+ var loginResp UniversalAuthLoginResponser, err = n.client.R().- SetBody(map[string]any{- "clientId": clientID,- "clientSecret": clientSecret,+ SetBody(UniversalAuthLoginRequest{+ ClientID: clientID,+ ClientSecret: clientSecret,}).SetResult(&loginResp).Post("/api/v1/auth/universal-auth/login")@@ -873,5 +886,5 @@ func (n *NodeJSService) GetIdentityAccessToken(t *testing.T, identityID string)t.Fatalf("infra.GetIdentityAccessToken: login returned %d: %s", r.StatusCode(), r.String())}- return jsonStr(loginResp, "accessToken")+ return loginResp.AccessToken}diff --git a/backend-go/internal/testutil/infra/nodejs_types.go b/backend-go/internal/testutil/infra/nodejs_types.gonew file mode 100644index 0000000000..d15251a80d--- /dev/null+++ b/backend-go/internal/testutil/infra/nodejs_types.go@@ -0,0 +1,297 @@+package infra++// Request and response types for Node.js API calls.+// These provide type safety without requiring full OpenAPI code generation.++// BootstrapRequest is the request body for POST /api/v1/admin/bootstrap.+type BootstrapRequest struct {+ Email string `json:"email"`+ Password string `json:"password"`+ Organization string `json:"organization"`+}++// BootstrapResponse is the response from POST /api/v1/admin/bootstrap.+type BootstrapResponse struct {+ Organization struct {+ ID string `json:"id"`+ } `json:"organization"`+ Identity struct {+ Credentials struct {+ Token string `json:"token"`+ } `json:"credentials"`+ } `json:"identity"`+ User struct {+ ID string `json:"id"`+ Email string `json:"email"`+ } `json:"user"`+}++// LoginRequest is the request body for POST /api/v3/auth/login.+type LoginRequest struct {+ Email string `json:"email"`+ Password string `json:"password"`+}++// LoginResponse is the response from POST /api/v3/auth/login.+type LoginResponse struct {+ AccessToken string `json:"accessToken"`+}++// SelectOrgRequest is the request body for POST /api/v3/auth/select-organization.+type SelectOrgRequest struct {+ OrganizationID string `json:"organizationId"`+}++// SelectOrgResponse is the response from POST /api/v3/auth/select-organization.+type SelectOrgResponse struct {+ Token string `json:"token"`+}++// CreateProjectRequest is the request body for POST /api/v1/projects.+type CreateProjectRequest struct {+ ProjectName string `json:"projectName"`+ Slug string `json:"slug"`+ Type string `json:"type"`+}++// CreateProjectResponse is the response from POST /api/v1/projects.+type CreateProjectResponse struct {+ Project struct {+ ID string `json:"id"`+ Slug string `json:"slug"`+ } `json:"project"`+}++// CreateIdentityRequest is the request body for POST /api/v1/identities.+type CreateIdentityRequest struct {+ Name string `json:"name"`+ OrganizationID string `json:"organizationId"`+ Role string `json:"role"`+}++// CreateIdentityResponse is the response from POST /api/v1/identities.+type CreateIdentityResponse struct {+ Identity struct {+ ID string `json:"id"`+ } `json:"identity"`+}++// AddIdentityToProjectRequest is the request body for POST /api/v1/projects/{id}/memberships/identities/{id}.+type AddIdentityToProjectRequest struct {+ Role string `json:"role,omitempty"`+}++// RoleAssignment represents a role with optional temporary access settings.+type RoleAssignment struct {+ Role string `json:"role"`+ IsTemporary bool `json:"isTemporary,omitempty"`+ TemporaryMode string `json:"temporaryMode,omitempty"`+ TemporaryRange string `json:"temporaryRange,omitempty"`+ TemporaryAccessStartTime string `json:"temporaryAccessStartTime,omitempty"`+}++// AddIdentityToProjectWithRolesRequest is the request body with roles array.+type AddIdentityToProjectWithRolesRequest struct {+ Roles []RoleAssignment `json:"roles"`+}++// InviteToOrgRequest is the request body for POST /api/v1/invite-org/signup.+type InviteToOrgRequest struct {+ InviteeEmails []string `json:"inviteeEmails"`+ OrganizationID string `json:"organizationId"`+}++// AddUserToProjectRequest is the request body for POST /api/v1/projects/{id}/memberships.+type AddUserToProjectRequest struct {+ Emails []string `json:"emails"`+ RoleSlugs []string `json:"roleSlugs"`+}++// Permission represents a CASL permission rule.+type Permission struct {+ Subject string `json:"subject"`+ Action any `json:"action"`+ Conditions map[string]any `json:"conditions,omitempty"`+ Inverted bool `json:"inverted,omitempty"`+}++// CreateCustomRoleRequest is the request body for POST /api/v1/projects/{id}/roles.+type CreateCustomRoleRequest struct {+ Slug string `json:"slug"`+ Name string `json:"name"`+ Permissions []Permission `json:"permissions"`+}++// CreateCustomRoleResponse is the response from POST /api/v1/projects/{id}/roles.+type CreateCustomRoleResponse struct {+ Role struct {+ ID string `json:"id"`+ Slug string `json:"slug"`+ Name string `json:"name"`+ } `json:"role"`+}++// CreateGroupRequest is the request body for POST /api/v1/groups.+type CreateGroupRequest struct {+ Name string `json:"name"`+ Role string `json:"role"`+}++// CreateGroupResponse is the response from POST /api/v1/groups.+type CreateGroupResponse struct {+ ID string `json:"id"`+ Name string `json:"name"`+ Slug string `json:"slug"`+}++// AddGroupToProjectRequest is the request body for POST /api/v1/projects/{id}/memberships/groups/{id}.+type AddGroupToProjectRequest struct {+ Role string `json:"role"`+}++// PrivilegeType specifies whether a privilege is temporary.+type PrivilegeType struct {+ IsTemporary bool `json:"isTemporary"`+ TemporaryMode string `json:"temporaryMode,omitempty"`+ TemporaryRange string `json:"temporaryRange,omitempty"`+ TemporaryAccessStartTime string `json:"temporaryAccessStartTime,omitempty"`+}++// CreateIdentityPrivilegeRequest is the request body for POST /api/v2/identity-project-additional-privilege.+type CreateIdentityPrivilegeRequest struct {+ IdentityID string `json:"identityId"`+ ProjectID string `json:"projectId"`+ Permissions []Permission `json:"permissions"`+ Type PrivilegeType `json:"type"`+}++// CreateUserPrivilegeRequest is the request body for POST /api/v1/user-project-additional-privilege.+type CreateUserPrivilegeRequest struct {+ ProjectMembershipID string `json:"projectMembershipId"`+ Permissions []Permission `json:"permissions"`+ Type PrivilegeType `json:"type"`+}++// CreateSecretRequest is the request body for POST /api/v4/secrets/{key}.+type CreateSecretRequest struct {+ ProjectID string `json:"projectId"`+ Environment string `json:"environment"`+ SecretPath string `json:"secretPath"`+ SecretValue string `json:"secretValue"`+ Type string `json:"type"`+ TagIDs []string `json:"tagIds,omitempty"`+}++// CreateSecretResponse is the response from POST /api/v4/secrets/{key}.+type CreateSecretResponse struct {+ Secret struct {+ ID string `json:"id"`+ } `json:"secret"`+}++// CreateFolderRequest is the request body for POST /api/v2/folders.+type CreateFolderRequest struct {+ ProjectID string `json:"projectId"`+ Environment string `json:"environment"`+ Path string `json:"path"`+ Name string `json:"name"`+}++// CreateFolderResponse is the response from POST /api/v2/folders.+type CreateFolderResponse struct {+ Folder struct {+ ID string `json:"id"`+ } `json:"folder"`+}++// SecretImportTarget specifies the source for a secret import.+type SecretImportTarget struct {+ Environment string `json:"environment"`+ Path string `json:"path"`+}++// CreateSecretImportRequest is the request body for POST /api/v2/secret-imports.+type CreateSecretImportRequest struct {+ ProjectID string `json:"projectId"`+ Environment string `json:"environment"`+ Path string `json:"path"`+ Import SecretImportTarget `json:"import"`+}++// CreateSecretImportResponse is the response from POST /api/v2/secret-imports.+type CreateSecretImportResponse struct {+ SecretImport struct {+ ID string `json:"id"`+ } `json:"secretImport"`+}++// CreateEnvironmentRequest is the request body for POST /api/v1/projects/{id}/environments.+type CreateEnvironmentRequest struct {+ Slug string `json:"slug"`+ Name string `json:"name"`+}++// CreateEnvironmentResponse is the response from POST /api/v1/projects/{id}/environments.+type CreateEnvironmentResponse struct {+ Environment struct {+ ID string `json:"id"`+ } `json:"environment"`+}++// CreateTagRequest is the request body for POST /api/v1/projects/{id}/tags.+type CreateTagRequest struct {+ Slug string `json:"slug"`+ Name string `json:"name"`+ Color string `json:"color"`+}++// CreateTagResponse is the response from POST /api/v1/projects/{id}/tags.+type CreateTagResponse struct {+ Tag struct {+ ID string `json:"id"`+ } `json:"tag"`+}++// IPAddress represents a trusted IP address.+type IPAddress struct {+ IPAddress string `json:"ipAddress"`+}++// CreateUniversalAuthRequest is the request body for POST /api/v1/auth/universal-auth/identities/{id}.+type CreateUniversalAuthRequest struct {+ IdentityID string `json:"identityId"`+ AccessTokenTrustedIPs []IPAddress `json:"accessTokenTrustedIps"`+ AccessTokenTTL int `json:"accessTokenTTL"`+ AccessTokenMaxTTL int `json:"accessTokenMaxTTL"`+ AccessTokenNumUsesLimit int `json:"accessTokenNumUsesLimit"`+ ClientSecretTrustedIPs []IPAddress `json:"clientSecretTrustedIps"`+ ClientSecretNumUsesLimit int `json:"clientSecretNumUsesLimit"`+ IsClientSecretRotationEnabled bool `json:"isClientSecretRotationEnabled"`+}++// CreateClientSecretRequest is the request body for POST /api/v1/auth/universal-auth/identities/{id}/client-secrets.+type CreateClientSecretRequest struct {+ Description string `json:"description"`+ TTL int `json:"ttl"`+ NumUsesLimit int `json:"numUsesLimit"`+}++// CreateClientSecretResponse is the response from POST /api/v1/auth/universal-auth/identities/{id}/client-secrets.+type CreateClientSecretResponse struct {+ ClientSecretData struct {+ ClientID string `json:"clientId"`+ ClientSecretPrefix string `json:"clientSecretPrefix"`+ } `json:"clientSecretData"`+ ClientSecret string `json:"clientSecret"`+}++// UniversalAuthLoginRequest is the request body for POST /api/v1/auth/universal-auth/login.+type UniversalAuthLoginRequest struct {+ ClientID string `json:"clientId"`+ ClientSecret string `json:"clientSecret"`+}++// UniversalAuthLoginResponse is the response from POST /api/v1/auth/universal-auth/login.+type UniversalAuthLoginResponse struct {+ AccessToken string `json:"accessToken"`+}