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: updated test based on main
=19f6c9513d16
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.tsindex b1381562ea..91d01be566 100644--- a/backend/src/services/project/project-service.ts+++ b/backend/src/services/project/project-service.ts@@ -293,12 +293,14 @@ export const projectServiceFactory = ({throw new ForbiddenRequestError({ message: "You don't have permission to create a project" });}+ // Read before the transaction: a plan cache miss queries on its own connection.+ const plan = await licenseService.getPlan(organization.id);+const results = await (trx || projectDAL).transaction(async (tx) => {await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.CreateProject(organization.id)]);// Check workspace limit inside the transaction after acquiring the lock// We count directly from the database to get the accurate count, not the cached plan value- const plan = await licenseService.getPlan(organization.id);if (plan.workspaceLimit !== null && type === ProjectType.SecretManager) {const currentProjectCount = await projectDAL.countOfBillableOrgProjects(organization.id, tx);if (currentProjectCount >= plan.workspaceLimit) {@@ -692,7 +694,7 @@ export const projectServiceFactory = ({// Skip this if the creator was already added via template with their configured rolesif (actor === ActorType.USER && !creatorAddedViaTemplate) {// Find public key of user- const user = await userDAL.findUserEncKeyByUserId(actorId);+ const user = await userDAL.findUserEncKeyByUserId(actorId, tx);if (!user) {throw new Error("User not found");diff --git a/tests/suites/secretmanager/approvals/enforcement_test.go b/tests/suites/secretmanager/approvals/enforcement_test.goindex 47a4bd9a8a..b9b5d155eb 100644--- a/tests/suites/secretmanager/approvals/enforcement_test.go+++ b/tests/suites/secretmanager/approvals/enforcement_test.go@@ -96,7 +96,7 @@ func TestSecretApprovalRequest_Bypass(t *testing.T) {// Assertrequire.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "Doesn't have minimum approvals needed", res.JSON400.Message)+ require.Contains(t, res.JSON400.Message, "needs 1 approval(s) on step 1 and has 0")require.Equal(t, "open", getRequest(t, proj, held.ID).Status)require.Empty(t, secretmanager.ListSecrets(t, proj, "dev"))})@@ -118,7 +118,7 @@ func TestSecretApprovalRequest_Bypass(t *testing.T) {// Assertrequire.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "Doesn't have minimum approvals needed", res.JSON400.Message)+ require.Contains(t, res.JSON400.Message, "needs 1 approval(s) on step 1 and has 0")require.Equal(t, "open", getRequest(t, proj, held.ID).Status)require.Empty(t, secretmanager.ListSecrets(t, proj, "dev"))})@@ -140,7 +140,7 @@ func TestSecretApprovalRequest_Bypass(t *testing.T) {// Assertrequire.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "Doesn't have minimum approvals needed", res.JSON400.Message)+ require.Contains(t, res.JSON400.Message, "needs 1 approval(s) on step 1 and has 0")require.Empty(t, secretmanager.ListSecrets(t, proj, "dev"))})}diff --git a/tests/suites/secretmanager/approvals/secret_change_request_test.go b/tests/suites/secretmanager/approvals/secret_change_request_test.goindex c94330ffa0..8e0ad66f8f 100644--- a/tests/suites/secretmanager/approvals/secret_change_request_test.go+++ b/tests/suites/secretmanager/approvals/secret_change_request_test.go@@ -343,7 +343,7 @@ func TestSecretApprovalRequest_Review(t *testing.T) {// Assertrequire.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "Doesn't have minimum approvals needed", res.JSON400.Message)+ require.Contains(t, res.JSON400.Message, "needs 1 approval(s) on step 1 and has 0")require.Equal(t, "open", getRequest(t, p.proj, held.ID).Status)require.Empty(t, secretmanager.ListSecrets(t, p.proj, "dev"))})@@ -361,7 +361,7 @@ func TestSecretApprovalRequest_Review(t *testing.T) {// Assertrequire.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "Doesn't have minimum approvals needed", res.JSON400.Message)+ require.Contains(t, res.JSON400.Message, "needs 1 approval(s) on step 1 and has 0")require.Empty(t, secretmanager.ListSecrets(t, p.proj, "dev"))})@@ -565,7 +565,7 @@ func TestSecretApprovalRequest_Status(t *testing.T) {require.Equal(t, http.StatusBadRequest, review.StatusCode())require.Equal(t, "You can only review open approval requests", review.JSON400.Message)require.Equal(t, http.StatusBadRequest, mergeClosed.StatusCode())- require.Equal(t, "You can only approve or reject open approval requests", mergeClosed.JSON400.Message)+ require.Equal(t, "You can only merge open approval requests", mergeClosed.JSON400.Message)require.Empty(t, secretmanager.ListSecrets(t, p.proj, "dev"))require.Equal(t, http.StatusOK, setStatus(t, p.committer, held.ID, api.UpdateSecretApprovalRequestStatusJSONBodyStatusOpen).StatusCode())@@ -609,7 +609,8 @@ func TestSecretApprovalRequest_Status(t *testing.T) {// Assertrequire.NoError(t, err)require.Equal(t, http.StatusBadRequest, res.StatusCode())- require.Equal(t, "The policy associated with this secret approval request has been deleted.", res.JSON400.Message)+ require.Equal(t, "You can only merge open approval requests", res.JSON400.Message,+ "deleting the policy closes its requests, so the merge is refused as closed")require.Empty(t, secretmanager.ListSecrets(t, p.proj, "dev"))})