Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix test

Thiago Araujo da Silva6d6ce031361e
diff --git a/backend/e2e-test/routes/v1/sub-org-group-link-identity.spec.ts b/backend/e2e-test/routes/v1/sub-org-group-link-identity.spec.ts
index 7c65912143..71982facf9 100644
--- a/backend/e2e-test/routes/v1/sub-org-group-link-identity.spec.ts
+++ b/backend/e2e-test/routes/v1/sub-org-group-link-identity.spec.ts
@@ -169,6 +169,13 @@ describe("Linking root groups to a sub-organization with a machine identity", ()
const [otherGroup] = await testDb(TableName.Groups)
.insert({ orgId: otherOrg.id, name: `other-grp-${suffix}`, slug: `other-grp-${suffix}` })
.returning("*");
+ const [otherMembership] = await testDb(TableName.Membership)
+ .insert({ isActive: true, scope: AccessScope.Organization, scopeOrgId: otherOrg.id, actorGroupId: otherGroup.id })
+ .returning("*");
+ await testDb(TableName.MembershipRole).insert({
+ membershipId: otherMembership.id,
+ role: OrgMembershipRole.NoAccess
+ });
try {
const headers = { authorization: `Bearer ${adminSubOrgToken}` };
@@ -181,15 +188,17 @@ describe("Linking root groups to a sub-organization with a machine identity", ()
headers,
body: { roles: [{ role: OrgMembershipRole.Member }] }
});
- expect(updateRes.statusCode).toBe(400);
+ expect(updateRes.statusCode).toBe(404);
expect(updateRes.json().message).toBe(`Group with ID '${id}' not found`);
// eslint-disable-next-line no-await-in-loop
const deleteRes = await testServer.inject({ method: "DELETE", url, headers });
- expect(deleteRes.statusCode).toBe(400);
+ expect(deleteRes.statusCode).toBe(404);
expect(deleteRes.json().message).toBe(`Group with ID '${id}' not found`);
}
} finally {
+ await testDb(TableName.MembershipRole).where({ membershipId: otherMembership.id }).del();
+ await testDb(TableName.Membership).where({ id: otherMembership.id }).del();
await testDb(TableName.Groups).where({ id: otherGroup.id }).del();
await testDb(TableName.Organization).where({ id: otherOrg.id }).del();
}
diff --git a/backend/src/services/membership-group/org/org-membership-group-factory.ts b/backend/src/services/membership-group/org/org-membership-group-factory.ts
index 0b66d694e1..0115dc13eb 100644
--- a/backend/src/services/membership-group/org/org-membership-group-factory.ts
+++ b/backend/src/services/membership-group/org/org-membership-group-factory.ts
@@ -13,7 +13,7 @@ import {
validatePrivilegeChangeOperation
} from "@app/ee/services/permission/permission-fns";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
-import { BadRequestError, InternalServerError, PermissionBoundaryError } from "@app/lib/errors";
+import { BadRequestError, InternalServerError, NotFoundError, PermissionBoundaryError } from "@app/lib/errors";
import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
import { requestMemoize } from "@app/lib/request-context/request-memoizer";
import { OrgServiceActor } from "@app/lib/types";
@@ -77,7 +77,7 @@ export const newOrgMembershipGroupFactory = ({
const $getGroupInActorScope = async (actor: OrgServiceActor, groupId: string) => {
const group = await groupDAL.findById(groupId);
if (!group || (group.orgId !== actor.orgId && group.orgId !== actor.rootOrgId)) {
- throw new BadRequestError({ message: `Group with ID '${groupId}' not found` });
+ throw new NotFoundError({ message: `Group with ID '${groupId}' not found` });
}
return group;
};