Skip to content

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

fix tests

adilson55b322f7350a
diff --git a/backend/src/services/delegated-approval/dispatch/delegated-approval-dispatch-consumer.test.ts b/backend/src/services/delegated-approval/dispatch/delegated-approval-dispatch-consumer.test.ts
index f74aa54f08..dd46063c79 100644
--- a/backend/src/services/delegated-approval/dispatch/delegated-approval-dispatch-consumer.test.ts
+++ b/backend/src/services/delegated-approval/dispatch/delegated-approval-dispatch-consumer.test.ts
@@ -15,6 +15,7 @@ import {
import { DelegatedApprovalPolicyType, DelegatedApprovalRequestStatus } from "../delegated-approval-enums";
import { DELEGATED_APPROVAL_DISPATCH_REQUESTED_EVENT } from "../delegated-approval-events";
import { TDelegatedApprovalRequestDetails } from "../delegated-approval-schemas";
+import { DELEGATED_APPROVAL_DISPATCH_RETRY_HINT } from "./delegated-approval-dispatch-constants";
import { delegatedApprovalDispatchConsumerFactory } from "./delegated-approval-dispatch-consumer";
vi.mock("@app/lib/logger", () => ({
@@ -46,8 +47,7 @@ vi.mock("@app/services/app-connection/app-connection-fns", () => ({
const DELEGATED_REQUEST_ID = "11111111-1111-1111-1111-111111111111";
const ORG_ID = "22222222-2222-2222-2222-222222222222";
-const RETRY_REASON =
- "ServiceNow did not respond. Infisical will retry automatically. If it keeps failing, send the request again.";
+const RETRY_REASON = `ServiceNow did not respond. ${DELEGATED_APPROVAL_DISPATCH_RETRY_HINT}`;
const SERVICENOW_RECORD = { type: DelegatedApprovalPolicyType.ServiceNow, recordNumber: "INFAR1000000" };
const pendingDelegatedRequest = {
diff --git a/tests/suites/secretmanager/approvals/delegated_access_request_test.go b/tests/suites/secretmanager/approvals/delegated_access_request_test.go
index 88b2e42c9d..9894c001e1 100644
--- a/tests/suites/secretmanager/approvals/delegated_access_request_test.go
+++ b/tests/suites/secretmanager/approvals/delegated_access_request_test.go
@@ -165,7 +165,7 @@ func TestDelegatedAccessRequest_Decision(t *testing.T) {
func TestDelegatedAccessRequest_CallbackLimit(t *testing.T) {
t.Parallel()
- t.Run("should close the request when ServiceNow calls back a sixth time", func(t *testing.T) {
+ t.Run("should keep the request open when ServiceNow calls back a sixth time while its decision is being read", func(t *testing.T) {
t.Parallel()
// Setup
@@ -178,29 +178,11 @@ func TestDelegatedAccessRequest_CallbackLimit(t *testing.T) {
code := req.callback(t, req.record.CallbackToken)
// Assert
- require.Equal(t, http.StatusForbidden, code)
- closed := req.current(t)
- require.Equal(t, delegatedState{status: "rejected", delegated: "failed", reason: closed.reason}, closed)
- require.Contains(t, closed.reason, "called back more than 5 times")
- })
-
- t.Run("should refuse an approval that arrives after the limit closed the request", func(t *testing.T) {
- t.Parallel()
-
- // Setup
- req := newWaitingDelegatedRequest(t)
- for range 6 {
- req.callback(t, req.record.CallbackToken)
- }
- req.sn.Seed(t, servicenow.Approved(req.record.SysID))
-
- // Action
- code := req.callback(t, req.record.CallbackToken)
-
- // Assert
- require.Equal(t, http.StatusForbidden, code)
- require.False(t, req.current(t).granted)
- require.Equal(t, http.StatusForbidden, req.readSecret(t))
+ require.Equal(t, http.StatusOK, code)
+ req.sn.ExpectEvent[servicenow.AccessRequestRead](t, nil, fakenet.Within(outboxWait))
+ req.sn.ExpectNoEvent[servicenow.AccessRequestRead](t, nil, fakenet.Within(quietWait))
+ open := req.current(t)
+ require.Equal(t, delegatedState{status: "pending", delegated: "waiting_approval", reason: open.reason}, open)
})
t.Run("should keep the request open when a sixth callback arrives without a token", func(t *testing.T) {