Skip to content

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

test: add smoke test

adilson518b2495c470
diff --git a/CLAUDE.md b/CLAUDE.md
index 35418e6857..77ab1520a0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -194,9 +194,13 @@ the body carries no decision, which a later worker reads back from the provider.
wrong token for a known record still burns the request, and on the sixth callback sets the row `failed` with a
readable `statusReason` and cancels the attached approval request in the same transaction, so the policy is freed
and the UI stops offering Cancel. Every other refusal (bad or missing token, request not `waiting_approval`)
-gets one neutral 403 while the reason goes to the log. An accepted callback only emits an outbox event: `eventType` is the body's event and
-`idempotencyKey` is the delegated request id plus the attempt count, so a repeat of one delivery is dropped
-while a fresh notification after an earlier read-back ran out of retries is not. The
+gets one neutral 403 while the reason goes to the log. An accepted callback only emits an outbox event, and
+only when it wins `claimDecisionRead`: a conditional update of `decisionReadRequestedAt`, in the emit's
+transaction, that one of any number of concurrent callbacks wins. A repeat while a read-back is still in
+flight gets the same 200 and emits nothing; a claim older than `DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS`
+(70 minutes, past the outbox's last retry) has expired, so a fresh notification after an earlier read-back
+ran out of retries still starts one. `eventType` is the
+body's event and `idempotencyKey` is the delegated request id plus the attempt count. The
`delegated-approval-decision` consumer (`backend/src/services/delegated-approval-decision/`, a thin outbox
adapter over `delegatedApprovalDecisionService.applyDecision`) then reads the decision back through the
policy's app connection: `TDelegatedApprovalProvider.fetchDecision` returns `pending` or a decision with
diff --git a/backend/src/db/migrations/20261015145100_external-approvals.ts b/backend/src/db/migrations/20261015145100_external-approvals.ts
index d95ce0095e..e3ff62a94a 100644
--- a/backend/src/db/migrations/20261015145100_external-approvals.ts
+++ b/backend/src/db/migrations/20261015145100_external-approvals.ts
@@ -32,6 +32,7 @@ export async function up(knex: Knex): Promise<void> {
t.binary("encryptedCallbackToken").nullable();
t.text("statusReason").nullable();
t.string("providerRequestId").nullable().index();
+ t.timestamp("decisionReadRequestedAt", { useTz: true }).nullable();
t.timestamps(true, true, true);
});
diff --git a/backend/src/db/schemas/delegated-approval-requests.ts b/backend/src/db/schemas/delegated-approval-requests.ts
index 5baf4ecb16..d302b92a11 100644
--- a/backend/src/db/schemas/delegated-approval-requests.ts
+++ b/backend/src/db/schemas/delegated-approval-requests.ts
@@ -16,6 +16,7 @@ export const DelegatedApprovalRequestsSchema = z.object({
encryptedCallbackToken: zodBuffer.nullable().optional(),
statusReason: z.string().nullable().optional(),
providerRequestId: z.string().nullable().optional(),
+ decisionReadRequestedAt: z.date().nullable().optional(),
createdAt: z.date(),
updatedAt: z.date(),
callbackAttempts: z.number().default(0)
diff --git a/backend/src/ee/routes/v1/access-approval-request-router.ts b/backend/src/ee/routes/v1/access-approval-request-router.ts
index 779520deca..fa94fc4469 100644
--- a/backend/src/ee/routes/v1/access-approval-request-router.ts
+++ b/backend/src/ee/routes/v1/access-approval-request-router.ts
@@ -148,6 +148,7 @@ export const registerAccessApprovalRequestRouter = async (server: FastifyZodProv
url: "/",
method: "GET",
schema: {
+ operationId: "listAccessApprovalRequests",
querystring: z.object({
projectSlug: z.string().trim(),
authorUserId: z.string().trim().optional(),
diff --git a/backend/src/services/delegated-approval-callback/delegated-approval-callback-constants.ts b/backend/src/services/delegated-approval-callback/delegated-approval-callback-constants.ts
index 2481cd3a28..7676c930fd 100644
--- a/backend/src/services/delegated-approval-callback/delegated-approval-callback-constants.ts
+++ b/backend/src/services/delegated-approval-callback/delegated-approval-callback-constants.ts
@@ -12,6 +12,9 @@ export const DELEGATED_APPROVAL_CALLBACK_TOKEN_MAX_LENGTH = 256;
export const DELEGATED_APPROVAL_CALLBACK_MAX_ATTEMPTS = 5;
+// Longer than the outbox keeps retrying one read-back, which ends about an hour after its first attempt.
+export const DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS = 70 * 60_000;
+
export const DELEGATED_APPROVAL_CALLBACK_REJECTED_MESSAGE = "Callback rejected.";
export const DELEGATED_APPROVAL_CALLBACK_ATTEMPTS_EXHAUSTED_REASON = `The delegated approval system called back more than ${DELEGATED_APPROVAL_CALLBACK_MAX_ATTEMPTS} times, so Infisical no longer accepts its decision for this request. Create the request again.`;
diff --git a/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.test.ts b/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.test.ts
index aaa4686f37..c13aff00f5 100644
--- a/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.test.ts
+++ b/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.test.ts
@@ -21,7 +21,8 @@ import { KmsDataKey } from "@app/services/kms/kms-types";
// eslint-disable-next-line import/first
import {
DELEGATED_APPROVAL_CALLBACK_MAX_ATTEMPTS,
- DELEGATED_APPROVAL_CALLBACK_PATH
+ DELEGATED_APPROVAL_CALLBACK_PATH,
+ DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS
} from "./delegated-approval-callback-constants";
// eslint-disable-next-line import/first
import { DelegatedApprovalCallbackEvent } from "./delegated-approval-callback-enums";
@@ -42,8 +43,9 @@ const makeService = ({
const delegatedApprovalRequestDAL = {
update: vi.fn(async (_filter: unknown, patch: object) => (stored ? [{ id: "delegated-1", ...patch }] : [])),
transaction: vi.fn(async (cb: (tx: unknown) => Promise<unknown>) => cb(TX)),
- findById: vi.fn(async () => currentRow),
- findByProviderRequestId: vi.fn(async (): Promise<unknown> => null)
+ findById: vi.fn(async (): Promise<unknown> => currentRow),
+ findByProviderRequestId: vi.fn(async (): Promise<unknown> => null),
+ claimDecisionRead: vi.fn(async (): Promise<unknown> => ({ id: "delegated-1" }))
};
const kmsService = {
createCipherPairWithDataKey: vi.fn(async () => ({
@@ -276,16 +278,55 @@ describe("handleCallback", () => {
type: KmsDataKey.Organization,
orgId: "org-1"
});
- expect(eventEmitter.emit).toHaveBeenCalledWith({
- eventType: EVENT,
- idempotencyKey: "delegated-1:1",
- payload: {
- delegatedRequestId: "delegated-1",
- approvalRequestId: "request-1",
- orgId: "org-1",
- event: EVENT,
- externalId: EXTERNAL_ID
- }
- });
+ expect(eventEmitter.emit).toHaveBeenCalledWith(
+ {
+ eventType: EVENT,
+ idempotencyKey: "delegated-1:1",
+ payload: {
+ delegatedRequestId: "delegated-1",
+ approvalRequestId: "request-1",
+ orgId: "org-1",
+ event: EVENT,
+ externalId: EXTERNAL_ID
+ }
+ },
+ TX
+ );
+ });
+
+ test("claims the read-back in the emit's transaction, expiring claims older than their TTL", async () => {
+ vi.useFakeTimers({ now: new Date("2026-10-21T12:00:00.000Z") });
+ try {
+ const { service, delegatedApprovalRequestDAL } = makeCallbackService();
+
+ await service.handleCallback(callback());
+
+ expect(delegatedApprovalRequestDAL.claimDecisionRead).toHaveBeenCalledWith(
+ { id: "delegated-1", staleBefore: new Date(Date.now() - DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS) },
+ TX
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
+ test("accepts a repeat without emitting while another read-back holds the claim", async () => {
+ const { service, delegatedApprovalRequestDAL, eventEmitter } = makeCallbackService();
+ delegatedApprovalRequestDAL.claimDecisionRead.mockResolvedValue(null);
+ delegatedApprovalRequestDAL.findById.mockResolvedValue(makeDelegatedRequest());
+
+ await expect(service.handleCallback(callback())).resolves.toEqual({ delegatedRequestId: "delegated-1" });
+ expect(eventEmitter.emit).not.toHaveBeenCalled();
+ });
+
+ test("rejects a callback whose request stopped awaiting a decision before the claim", async () => {
+ const { service, delegatedApprovalRequestDAL, eventEmitter } = makeCallbackService();
+ delegatedApprovalRequestDAL.claimDecisionRead.mockResolvedValue(null);
+ delegatedApprovalRequestDAL.findById.mockResolvedValue(
+ makeDelegatedRequest({ status: DelegatedApprovalRequestStatus.Approved })
+ );
+
+ await expect(service.handleCallback(callback())).rejects.toBeInstanceOf(ForbiddenRequestError);
+ expect(eventEmitter.emit).not.toHaveBeenCalled();
});
});
diff --git a/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.ts b/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.ts
index 5bac5ed8ee..8688e8271e 100644
--- a/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.ts
+++ b/backend/src/services/delegated-approval-callback/delegated-approval-callback-service.ts
@@ -9,7 +9,8 @@ import {
DELEGATED_APPROVAL_CALLBACK_ATTEMPTS_EXHAUSTED_REASON,
DELEGATED_APPROVAL_CALLBACK_MAX_ATTEMPTS,
DELEGATED_APPROVAL_CALLBACK_PATH,
- DELEGATED_APPROVAL_CALLBACK_TOKEN_PREFIX
+ DELEGATED_APPROVAL_CALLBACK_TOKEN_PREFIX,
+ DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS
} from "./delegated-approval-callback-constants";
import { TDelegatedApprovalCallbackEventPayload } from "./delegated-approval-callback-events";
import { generateCallbackToken, isTokenMatch, rejectApprovalCallback } from "./delegated-approval-callback-fns";
@@ -119,10 +120,28 @@ export const delegatedApprovalCallbackServiceFactory = ({
event,
externalId
};
- await eventEmitter.emit({ eventType: event, idempotencyKey: `${delegatedRequest.id}:${attempts}`, payload });
+ // A read-back already in flight will see the decision this callback announces, so a repeat only
+ // starts another once that one has had time to finish.
+ const outcome = await delegatedApprovalRequestDAL.transaction(async (tx) => {
+ const claimed = await delegatedApprovalRequestDAL.claimDecisionRead(
+ { id: delegatedRequest.id, staleBefore: new Date(Date.now() - DELEGATED_APPROVAL_DECISION_READ_CLAIM_TTL_MS) },
+ tx
+ );
+ if (!claimed) {
+ const current = await delegatedApprovalRequestDAL.findById(delegatedRequest.id, tx);
+ return current?.status === DelegatedApprovalRequestStatus.WaitingApproval ? "deduplicated" : "closed";
+ }
+
+ await eventEmitter.emit({ eventType: event, idempotencyKey: `${delegatedRequest.id}:${attempts}`, payload }, tx);
+ return "accepted";
+ });
+
+ if (outcome === "closed") {
+ throw rejectApprovalCallback("request is not awaiting a decision", logContext);
+ }
logger.info(
- `Delegated approval callback accepted [delegatedRequestId=${delegatedRequest.id}] [approvalRequestId=${delegatedRequest.requestId}] [event=${event}] [attempt=${attempts}]`
+ `Delegated approval callback ${outcome} [delegatedRequestId=${delegatedRequest.id}] [approvalRequestId=${delegatedRequest.requestId}] [event=${event}] [attempt=${attempts}]`
);
return { delegatedRequestId: delegatedRequest.id };
diff --git a/backend/src/services/delegated-approval-callback/delegated-approval-callback-types.ts b/backend/src/services/delegated-approval-callback/delegated-approval-callback-types.ts
index b21d0ea30d..8e886542a3 100644
--- a/backend/src/services/delegated-approval-callback/delegated-approval-callback-types.ts
+++ b/backend/src/services/delegated-approval-callback/delegated-approval-callback-types.ts
@@ -9,7 +9,7 @@ import { DelegatedApprovalCallbackEvent } from "./delegated-approval-callback-en
export type TDelegatedApprovalCallbackServiceFactoryDep = {
delegatedApprovalRequestDAL: Pick<
TDelegatedApprovalRequestDALFactory,
- "findById" | "findByProviderRequestId" | "transaction" | "update"
+ "claimDecisionRead" | "findById" | "findByProviderRequestId" | "transaction" | "update"
>;
approvalRequestDAL: Pick<TApprovalRequestDALFactory, "transaction" | "findByIdForUpdate" | "updateById">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
diff --git a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts
index 4f59237f44..fae3e2b659 100644
--- a/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts
+++ b/backend/src/services/delegated-approval-decision/delegated-approval-decision-service.ts
@@ -207,7 +207,6 @@ export const delegatedApprovalDecisionServiceFactory = ({
}
const { delegatedRequest, approvalRequest, delegatedPolicy } = delegatedApprovalContext;
- // move this to a helper function
if (DELEGATED_APPROVAL_FINAL_STATE.has(delegatedRequest.status as DelegatedApprovalRequestStatus)) {
logger.info(
`Delegated approval request was already finalized, skipping decision [delegatedRequestId=${delegatedRequestId}] [status=${delegatedRequest.status}]`
@@ -235,8 +234,6 @@ export const delegatedApprovalDecisionServiceFactory = ({
return { status: EventResultStatus.Delivered };
}
- // finished helper function
-
const delegatedApprovalName =
delegatedPolicy && Object.hasOwn(DELEGATED_APPROVAL_NAME_MAP, delegatedPolicy.type)
? DELEGATED_APPROVAL_NAME_MAP[delegatedPolicy.type as DelegatedApprovalPolicyType]
@@ -249,8 +246,6 @@ export const delegatedApprovalDecisionServiceFactory = ({
delegatedApprovalType: delegatedApprovalName ?? "the delegated approval system"
};
- // move this to a helper function
-
if (!delegatedPolicy) {
return $terminal(
context,
diff --git a/backend/src/services/delegated-approval/delegated-approval-request-dal.ts b/backend/src/services/delegated-approval/delegated-approval-request-dal.ts
index 92154ce09d..c5bbec4cdd 100644
--- a/backend/src/services/delegated-approval/delegated-approval-request-dal.ts
+++ b/backend/src/services/delegated-approval/delegated-approval-request-dal.ts
@@ -1,8 +1,12 @@
+import { Knex } from "knex";
+
import { TDbClient } from "@app/db";
import { TableName, TDelegatedApprovalRequests } from "@app/db/schemas";
import { DatabaseError } from "@app/lib/errors";
import { ormify, selectAllTableCols } from "@app/lib/knex";
+import { DelegatedApprovalRequestStatus } from "./delegated-approval-enums";
+
export type TDelegatedApprovalRequestDALFactory = ReturnType<typeof delegatedApprovalRequestDALFactory>;
export type TDelegatedApprovalRequestWithApprovalRequest = TDelegatedApprovalRequests & {
@@ -35,5 +39,22 @@ export const delegatedApprovalRequestDALFactory = (db: TDbClient) => {
}
};
- return { ...orm, findByProviderRequestId };
+ // Concurrent claims on one row serialize on its lock, and the loser re-evaluates the WHERE against the
+ // winner's write, so only one caller gets the row back.
+ const claimDecisionRead = async ({ id, staleBefore }: { id: string; staleBefore: Date }, tx?: Knex) => {
+ try {
+ const [row] = await (tx || db)(TableName.DelegatedApprovalRequests)
+ .where({ id, status: DelegatedApprovalRequestStatus.WaitingApproval })
+ .where((qb) => {
+ void qb.whereNull("decisionReadRequestedAt").orWhere("decisionReadRequestedAt", "<", staleBefore);
+ })
+ .update({ decisionReadRequestedAt: new Date() })
+ .returning("*");
+ return (row as TDelegatedApprovalRequests | undefined) ?? null;
+ } catch (error) {
+ throw new DatabaseError({ error, name: "DelegatedApprovalRequest: claimDecisionRead" });
+ }
+ };
+
+ return { ...orm, findByProviderRequestId, claimDecisionRead };
};
diff --git a/backend/src/services/delegated-approval/providers/servicenow/servicenow-fns.ts b/backend/src/services/delegated-approval/providers/servicenow/servicenow-fns.ts
index 711f9be6fd..f81fe2d263 100644
--- a/backend/src/services/delegated-approval/providers/servicenow/servicenow-fns.ts
+++ b/backend/src/services/delegated-approval/providers/servicenow/servicenow-fns.ts
@@ -8,7 +8,6 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums
import { TAppConnection } from "@app/services/app-connection/app-connection-types";
import { TServiceNowConnection } from "@app/services/app-connection/servicenow";
import { ApprovalPolicyType } from "@app/services/approval-policy/approval-policy-enums";
-import { DELEGATED_APPROVAL_CALLBACK_PATH } from "@app/services/delegated-approval-callback/delegated-approval-callback-constants";
import { DelegatedApprovalCallbackEvent } from "@app/services/delegated-approval-callback/delegated-approval-callback-enums";
import { DelegatedApprovalDecision } from "@app/services/delegated-approval-decision/delegated-approval-decision-enums";
import { TDelegatedApprovalDecisionReadResult } from "@app/services/delegated-approval-decision/delegated-approval-decision-types";
@@ -28,8 +27,8 @@ import {
import { ServiceNowDecision, ServiceNowRequestOperation, ServiceNowRequestType } from "./servicenow-enums";
import {
ServiceNowAccessRequestPayloadSchema,
- ServiceNowAccessResponseRecordSchema,
ServiceNowAccessRequestResponseSchema,
+ ServiceNowAccessResponseRecordSchema,
ServiceNowErrorResponseSchema
} from "./servicenow-schemas";
import {
@@ -92,7 +91,7 @@ export const buildServiceNowAccessRequestPayload = (
): TServiceNowAccessRequestPayload => {
const parsed = ServiceNowAccessRequestPayloadSchema.safeParse({
request_id: input.approvalRequestId,
- callback_url: `https://columbus-stretchable-omega.ngrok-free.dev${DELEGATED_APPROVAL_CALLBACK_PATH}`,
+ callback_url: input.callback.url,
callback_token: input.callback.token,
product_type: input.productType,
...(input.project ? { project_id: input.project.id, project_name: input.project.name } : {}),
diff --git a/tests/clients/api/api.gen.go b/tests/clients/api/api.gen.go
index 9a295b42c0..5a9246efe8 100644
--- a/tests/clients/api/api.gen.go
+++ b/tests/clients/api/api.gen.go
@@ -786,6 +786,141 @@ func (e UpdateAccessApprovalPolicy500JSONResponseBodyStatusCode) Valid() bool {
}
}
+// Defines values for ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus.
+const (
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusApproved ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "approved"
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusFailed ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "failed"
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusFailedDispatch ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "failed_dispatch"
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusPendingDispatch ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "pending_dispatch"
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusRejected ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "rejected"
+ ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusWaitingApproval ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus = "waiting_approval"
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus enum.
+func (e ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusApproved:
+ return true
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusFailed:
+ return true
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusFailedDispatch:
+ return true
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusPendingDispatch:
+ return true
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusRejected:
+ return true
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatusWaitingApproval:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType.
+const (
+ ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalTypeServicenow ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType = "servicenow"
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType enum.
+func (e ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalTypeServicenow:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests400JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests400JSONResponseBodyStatusCodeN400 ListAccessApprovalRequests400JSONResponseBodyStatusCode = 400
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests400JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests400JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests400JSONResponseBodyStatusCodeN400:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests401JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests401JSONResponseBodyStatusCodeN401 ListAccessApprovalRequests401JSONResponseBodyStatusCode = 401
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests401JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests401JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests401JSONResponseBodyStatusCodeN401:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests403JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests403JSONResponseBodyStatusCodeN403 ListAccessApprovalRequests403JSONResponseBodyStatusCode = 403
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests403JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests403JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests403JSONResponseBodyStatusCodeN403:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests404JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests404JSONResponseBodyStatusCodeN404 ListAccessApprovalRequests404JSONResponseBodyStatusCode = 404
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests404JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests404JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests404JSONResponseBodyStatusCodeN404:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests422JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests422JSONResponseBodyStatusCodeN422 ListAccessApprovalRequests422JSONResponseBodyStatusCode = 422
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests422JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests422JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests422JSONResponseBodyStatusCodeN422:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for ListAccessApprovalRequests500JSONResponseBodyStatusCode.
+const (
+ ListAccessApprovalRequests500JSONResponseBodyStatusCodeN500 ListAccessApprovalRequests500JSONResponseBodyStatusCode = 500
+)
+
+// Valid indicates whether the value is a known member of the ListAccessApprovalRequests500JSONResponseBodyStatusCode enum.
+func (e ListAccessApprovalRequests500JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case ListAccessApprovalRequests500JSONResponseBodyStatusCodeN500:
+ return true
+ default:
+ return false
+ }
+}
+
// Defines values for CreateAccessApprovalRequest400JSONResponseBodyStatusCode.
const (
CreateAccessApprovalRequest400JSONResponseBodyStatusCodeN400 CreateAccessApprovalRequest400JSONResponseBodyStatusCode = 400
@@ -4386,6 +4521,126 @@ func (e ListProjectSecretsDetails500JSONResponseBodyStatusCode) Valid() bool {
}
}
+// Defines values for HandleDelegatedApprovalCallbackJSONBodyEvent.
+const (
+ SecretsManagementAccessRequest HandleDelegatedApprovalCallbackJSONBodyEvent = "secrets_management.access_request"
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallbackJSONBodyEvent enum.
+func (e HandleDelegatedApprovalCallbackJSONBodyEvent) Valid() bool {
+ switch e {
+ case SecretsManagementAccessRequest:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallbackJSONBodyVersion.
+const (
+ N1 HandleDelegatedApprovalCallbackJSONBodyVersion = 1
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallbackJSONBodyVersion enum.
+func (e HandleDelegatedApprovalCallbackJSONBodyVersion) Valid() bool {
+ switch e {
+ case N1:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback400JSONResponseBodyStatusCodeN400 HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode = 400
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback400JSONResponseBodyStatusCodeN400:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback401JSONResponseBodyStatusCodeN401 HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode = 401
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback401JSONResponseBodyStatusCodeN401:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback403JSONResponseBodyStatusCodeN403 HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode = 403
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback403JSONResponseBodyStatusCodeN403:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback404JSONResponseBodyStatusCodeN404 HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode = 404
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback404JSONResponseBodyStatusCodeN404:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback422JSONResponseBodyStatusCodeN422 HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode = 422
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback422JSONResponseBodyStatusCodeN422:
+ return true
+ default:
+ return false
+ }
+}
+
+// Defines values for HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode.
+const (
+ HandleDelegatedApprovalCallback500JSONResponseBodyStatusCodeN500 HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode = 500
+)
+
+// Valid indicates whether the value is a known member of the HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode enum.
+func (e HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode) Valid() bool {
+ switch e {
+ case HandleDelegatedApprovalCallback500JSONResponseBodyStatusCodeN500:
+ return true
+ default:
+ return false
+ }
+}
+
// Defines values for ListEmailDomains400JSONResponseBodyStatusCode.
const (
ListEmailDomains400JSONResponseBodyStatusCodeN400 ListEmailDomains400JSONResponseBodyStatusCode = 400
@@ -7961,16 +8216,16 @@ func (e MergeSecretApprovalRequest500JSONResponseBodyStatusCode) Valid() bool {
// Defines values for ReviewSecretApprovalRequestJSONBodyStatus.
const (
- Approved ReviewSecretApprovalRequestJSONBodyStatus = "approved"
- Rejected ReviewSecretApprovalRequestJSONBodyStatus = "rejected"
+ ReviewSecretApprovalRequestJSONBodyStatusApproved ReviewSecretApprovalRequestJSONBodyStatus = "approved"
+ ReviewSecretApprovalRequestJSONBodyStatusRejected ReviewSecretApprovalRequestJSONBodyStatus = "rejected"
)
// Valid indicates whether the value is a known member of the ReviewSecretApprovalRequestJSONBodyStatus enum.
func (e ReviewSecretApprovalRequestJSONBodyStatus) Valid() bool {
switch e {
- case Approved:
+ case ReviewSecretApprovalRequestJSONBodyStatusApproved:
return true
- case Rejected:
+ case ReviewSecretApprovalRequestJSONBodyStatusRejected:
return true
default:
return false
@@ -13748,6 +14003,37 @@ type UpdateAccessApprovalPolicy422JSONResponseBodyStatusCode float32
// UpdateAccessApprovalPolicy500JSONResponseBodyStatusCode defines parameters for UpdateAccessApprovalPolicy.
type UpdateAccessApprovalPolicy500JSONResponseBodyStatusCode float32
+// ListAccessApprovalRequestsParams defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequestsParams struct {
+ ProjectSlug string `form:"projectSlug" json:"projectSlug"`
+ AuthorUserId *string `form:"authorUserId,omitempty" json:"authorUserId,omitempty"`
+ EnvSlug *string `form:"envSlug,omitempty" json:"envSlug,omitempty"`
+}
+
+// ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus string
+
+// ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType string
+
+// ListAccessApprovalRequests400JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests400JSONResponseBodyStatusCode float32
+
+// ListAccessApprovalRequests401JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests401JSONResponseBodyStatusCode float32
+
+// ListAccessApprovalRequests403JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests403JSONResponseBodyStatusCode float32
+
+// ListAccessApprovalRequests404JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests404JSONResponseBodyStatusCode float32
+
+// ListAccessApprovalRequests422JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests422JSONResponseBodyStatusCode float32
+
+// ListAccessApprovalRequests500JSONResponseBodyStatusCode defines parameters for ListAccessApprovalRequests.
+type ListAccessApprovalRequests500JSONResponseBodyStatusCode float32
+
// CreateAccessApprovalRequestJSONBody defines parameters for CreateAccessApprovalRequest.
type CreateAccessApprovalRequestJSONBody struct {
IsTemporary bool `json:"isTemporary"`
@@ -17127,6 +17413,50 @@ type ListProjectSecretsDetails422JSONResponseBodyStatusCode float32
// ListProjectSecretsDetails500JSONResponseBodyStatusCode defines parameters for ListProjectSecretsDetails.
type ListProjectSecretsDetails500JSONResponseBodyStatusCode float32
+// HandleDelegatedApprovalCallbackJSONBody defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallbackJSONBody struct {
+ Details struct {
+ // ExternalId The delegated approval system's record ID for the request.
+ ExternalId string `json:"externalId"`
+ } `json:"details"`
+
+ // Event The event Infisical named when it created the request, returned unchanged.
+ Event HandleDelegatedApprovalCallbackJSONBodyEvent `json:"event"`
+
+ // Version The callback contract version.
+ Version HandleDelegatedApprovalCallbackJSONBodyVersion `json:"version"`
+}
+
+// HandleDelegatedApprovalCallbackParams defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallbackParams struct {
+ // InfisicalApprovalToken The callback token Infisical issued when it sent the request.
+ InfisicalApprovalToken *string `json:"infisical-approval-token,omitempty"`
+}
+
+// HandleDelegatedApprovalCallbackJSONBodyEvent defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallbackJSONBodyEvent string
+
+// HandleDelegatedApprovalCallbackJSONBodyVersion defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallbackJSONBodyVersion float32
+
+// HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode float32
+
+// HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode float32
+
+// HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode float32
+
+// HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode float32
+
+// HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode float32
+
+// HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode defines parameters for HandleDelegatedApprovalCallback.
+type HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode float32
+
// ListEmailDomains400JSONResponseBodyStatusCode defines parameters for ListEmailDomains.
type ListEmailDomains400JSONResponseBodyStatusCode float32
@@ -21012,6 +21342,9 @@ type CreateUniversalAuthClientSecretJSONRequestBody CreateUniversalAuthClientSec
// LoginWithUniversalAuthJSONRequestBody defines body for LoginWithUniversalAuth for application/json ContentType.
type LoginWithUniversalAuthJSONRequestBody LoginWithUniversalAuthJSONBody
+// HandleDelegatedApprovalCallbackJSONRequestBody defines body for HandleDelegatedApprovalCallback for application/json ContentType.
+type HandleDelegatedApprovalCallbackJSONRequestBody HandleDelegatedApprovalCallbackJSONBody
+
// CreateEmailDomainJSONRequestBody defines body for CreateEmailDomain for application/json ContentType.
type CreateEmailDomainJSONRequestBody CreateEmailDomainJSONBody
@@ -26483,6 +26816,9 @@ type ClientInterface interface {
// Takes a body of the `application/json` content type.
UpdateAccessApprovalPolicy(ctx context.Context, policyId string, body UpdateAccessApprovalPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
+ // ListAccessApprovalRequests performs a GET /api/v1/access-approvals/requests (the `ListAccessApprovalRequests` operationId) request.
+ ListAccessApprovalRequests(ctx context.Context, params *ListAccessApprovalRequestsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
+
// CreateAccessApprovalRequestWithBody performs a POST /api/v1/access-approvals/requests (the `CreateAccessApprovalRequest` operationId) request,
// with any type of body and a specified content type.
CreateAccessApprovalRequestWithBody(ctx context.Context, params *CreateAccessApprovalRequestParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
@@ -26580,6 +26916,18 @@ type ClientInterface interface {
// List project secrets details.
ListProjectSecretsDetails(ctx context.Context, params *ListProjectSecretsDetailsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
+ // HandleDelegatedApprovalCallbackWithBody performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request,
+ // with any type of body and a specified content type.
+ //
+ // Receive a decision notification from a delegated approval system.
+ HandleDelegatedApprovalCallbackWithBody(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
+
+ // HandleDelegatedApprovalCallback performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request.
+ // Takes a body of the `application/json` content type.
+ //
+ // Receive a decision notification from a delegated approval system.
+ HandleDelegatedApprovalCallback(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, body HandleDelegatedApprovalCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
+
// ListEmailDomains performs a GET /api/v1/email-domains (the `ListEmailDomains` operationId) request.
ListEmailDomains(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
@@ -27352,6 +27700,19 @@ func (c *Client) UpdateAccessApprovalPolicy(ctx context.Context, policyId string
return c.Client.Do(req)
}
+// ListAccessApprovalRequests performs a GET /api/v1/access-approvals/requests (the `ListAccessApprovalRequests` operationId) request.
+func (c *Client) ListAccessApprovalRequests(ctx context.Context, params *ListAccessApprovalRequestsParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
+ req, err := NewListAccessApprovalRequestsRequest(c.Server, params)
+ if err != nil {
+ return nil, err
+ }
+ req = req.WithContext(ctx)
+ if err := c.applyEditors(ctx, req, reqEditors); err != nil {
+ return nil, err
+ }
+ return c.Client.Do(req)
+}
+
// CreateAccessApprovalRequestWithBody performs a POST /api/v1/access-approvals/requests (the `CreateAccessApprovalRequest` operationId) request,
// with any type of body and a specified content type.
func (c *Client) CreateAccessApprovalRequestWithBody(ctx context.Context, params *CreateAccessApprovalRequestParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
@@ -27639,6 +28000,38 @@ func (c *Client) ListProjectSecretsDetails(ctx context.Context, params *ListProj
return c.Client.Do(req)
}
+// HandleDelegatedApprovalCallbackWithBody performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request,
+// with any type of body and a specified content type.
+//
+// Receive a decision notification from a delegated approval system.
+func (c *Client) HandleDelegatedApprovalCallbackWithBody(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
+ req, err := NewHandleDelegatedApprovalCallbackRequestWithBody(c.Server, params, contentType, body)
+ if err != nil {
+ return nil, err
+ }
+ req = req.WithContext(ctx)
+ if err := c.applyEditors(ctx, req, reqEditors); err != nil {
+ return nil, err
+ }
+ return c.Client.Do(req)
+}
+
+// HandleDelegatedApprovalCallback performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request.
+// Takes a body of the `application/json` content type.
+//
+// Receive a decision notification from a delegated approval system.
+func (c *Client) HandleDelegatedApprovalCallback(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, body HandleDelegatedApprovalCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
+ req, err := NewHandleDelegatedApprovalCallbackRequest(c.Server, params, body)
+ if err != nil {
+ return nil, err
+ }
+ req = req.WithContext(ctx)
+ if err := c.applyEditors(ctx, req, reqEditors); err != nil {
+ return nil, err
+ }
+ return c.Client.Do(req)
+}
+
// ListEmailDomains performs a GET /api/v1/email-domains (the `ListEmailDomains` operationId) request.
func (c *Client) ListEmailDomains(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewListEmailDomainsRequest(c.Server)
@@ -30011,6 +30404,80 @@ func NewUpdateAccessApprovalPolicyRequestWithBody(server string, policyId string
return req, nil
}
+// NewListAccessApprovalRequestsRequest constructs an http.Request for the ListAccessApprovalRequests method
+func NewListAccessApprovalRequestsRequest(server string, params *ListAccessApprovalRequestsParams) (*http.Request, error) {
+ var err error
+
+ serverURL, err := url.Parse(server)
+ if err != nil {
+ return nil, err
+ }
+
+ operationPath := fmt.Sprintf("/api/v1/access-approvals/requests")
+ if operationPath[0] == '/' {
+ operationPath = "." + operationPath
+ }
+
+ queryURL, err := serverURL.Parse(operationPath)
+ if err != nil {
+ return nil, err
+ }
+
+ if params != nil {
+ // queryValues collects non-styled parameters (passthrough, JSON)
+ // that are safe to round-trip through url.Values.Encode().
+ queryValues := queryURL.Query()
+ // rawQueryFragments collects pre-encoded query fragments from
+ // styled parameters, preserving literal commas as delimiters
+ // per the OpenAPI spec (e.g. "color=blue,black,brown").
+ var rawQueryFragments []string
+
+ if queryFrag, err := runtime.StyleParamWithOptions("form", true, "projectSlug", params.ProjectSlug, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
+ return nil, err
+ } else {
+ for _, qp := range strings.Split(queryFrag, "&") {
+ rawQueryFragments = append(rawQueryFragments, qp)
+ }
+ }
+
+ if params.AuthorUserId != nil {
+
+ if queryFrag, err := runtime.StyleParamWithOptions("form", true, "authorUserId", *params.AuthorUserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
+ return nil, err
+ } else {
+ for _, qp := range strings.Split(queryFrag, "&") {
+ rawQueryFragments = append(rawQueryFragments, qp)
+ }
+ }
+
+ }
+
+ if params.EnvSlug != nil {
+
+ if queryFrag, err := runtime.StyleParamWithOptions("form", true, "envSlug", *params.EnvSlug, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
+ return nil, err
+ } else {
+ for _, qp := range strings.Split(queryFrag, "&") {
+ rawQueryFragments = append(rawQueryFragments, qp)
+ }
+ }
+
+ }
+
+ if encoded := queryValues.Encode(); encoded != "" {
+ rawQueryFragments = append(rawQueryFragments, encoded)
+ }
+ queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
+ }
+
+ req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
+ if err != nil {
+ return nil, err
+ }
+
+ return req, nil
+}
+
// NewCreateAccessApprovalRequestRequest calls the generic CreateAccessApprovalRequest builder with application/json body
func NewCreateAccessApprovalRequestRequest(server string, params *CreateAccessApprovalRequestParams, body CreateAccessApprovalRequestJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
@@ -30655,6 +31122,61 @@ func NewListProjectSecretsDetailsRequest(server string, params *ListProjectSecre
return req, nil
}
+// NewHandleDelegatedApprovalCallbackRequest calls the generic HandleDelegatedApprovalCallback builder with application/json body
+func NewHandleDelegatedApprovalCallbackRequest(server string, params *HandleDelegatedApprovalCallbackParams, body HandleDelegatedApprovalCallbackJSONRequestBody) (*http.Request, error) {
+ var bodyReader io.Reader
+ buf, err := json.Marshal(body)
+ if err != nil {
+ return nil, err
+ }
+ bodyReader = bytes.NewReader(buf)
+ return NewHandleDelegatedApprovalCallbackRequestWithBody(server, params, "application/json", bodyReader)
+}
+
+// NewHandleDelegatedApprovalCallbackRequestWithBody constructs an http.Request for the HandleDelegatedApprovalCallback method, with any body, and a specified content type
+func NewHandleDelegatedApprovalCallbackRequestWithBody(server string, params *HandleDelegatedApprovalCallbackParams, contentType string, body io.Reader) (*http.Request, error) {
+ var err error
+
+ serverURL, err := url.Parse(server)
+ if err != nil {
+ return nil, err
+ }
+
+ operationPath := fmt.Sprintf("/api/v1/delegated-approvals/callback")
+ if operationPath[0] == '/' {
+ operationPath = "." + operationPath
+ }
+
+ queryURL, err := serverURL.Parse(operationPath)
+ if err != nil {
+ return nil, err
+ }
+
+ req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
+ if err != nil {
+ return nil, err
+ }
+
+ req.Header.Add("Content-Type", contentType)
+
+ if params != nil {
+
+ if params.InfisicalApprovalToken != nil {
+ var headerParam0 string
+
+ headerParam0, err = runtime.StyleParamWithOptions("simple", false, "infisical-approval-token", *params.InfisicalApprovalToken, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""})
+ if err != nil {
+ return nil, err
+ }
+
+ req.Header.Set("infisical-approval-token", headerParam0)
+ }
+
+ }
+
+ return req, nil
+}
+
// NewListEmailDomainsRequest constructs an http.Request for the ListEmailDomains method
func NewListEmailDomainsRequest(server string) (*http.Request, error) {
var err error
@@ -35572,6 +36094,11 @@ type ClientWithResponsesInterface interface {
// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
UpdateAccessApprovalPolicyWithResponse(ctx context.Context, policyId string, body UpdateAccessApprovalPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAccessApprovalPolicyResponse, error)
+ // ListAccessApprovalRequestsWithResponse performs a GET /api/v1/access-approvals/requests (the `ListAccessApprovalRequests` operationId) request.
+ //
+ // Returns a wrapper object for the known response body format(s).
+ ListAccessApprovalRequestsWithResponse(ctx context.Context, params *ListAccessApprovalRequestsParams, reqEditors ...RequestEditorFn) (*ListAccessApprovalRequestsResponse, error)
+
// CreateAccessApprovalRequestWithBodyWithResponse performs a POST /api/v1/access-approvals/requests (the `CreateAccessApprovalRequest` operationId) request,
// with any type of body and a specified content type.
//
@@ -35691,6 +36218,20 @@ type ClientWithResponsesInterface interface {
// Returns a wrapper object for the known response body format(s).
ListProjectSecretsDetailsWithResponse(ctx context.Context, params *ListProjectSecretsDetailsParams, reqEditors ...RequestEditorFn) (*ListProjectSecretsDetailsResponse, error)
+ // HandleDelegatedApprovalCallbackWithBodyWithResponse performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request,
+ // with any type of body and a specified content type.
+ //
+ // Receive a decision notification from a delegated approval system.
+ //
+ // Returns a wrapper object for the known response body format(s).
+ HandleDelegatedApprovalCallbackWithBodyWithResponse(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*HandleDelegatedApprovalCallbackResponse, error)
+
+ // HandleDelegatedApprovalCallbackWithResponse performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request.
+ // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
+ //
+ // Receive a decision notification from a delegated approval system.
+ HandleDelegatedApprovalCallbackWithResponse(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, body HandleDelegatedApprovalCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*HandleDelegatedApprovalCallbackResponse, error)
+
// ListEmailDomainsWithResponse performs a GET /api/v1/email-domains (the `ListEmailDomains` operationId) request.
//
// Returns a wrapper object for the known response body format(s).
@@ -37627,6 +38168,337 @@ func (r UpdateAccessApprovalPolicyResponse) ContentType() string {
return ""
}
+type ListAccessApprovalRequestsResponse struct {
+ Body []byte
+ HTTPResponse *http.Response
+ // JSON200 the response for an HTTP 200 `application/json` response
+ JSON200 *struct {
+ Requests []struct {
+ ApprovedAt *time.Time `json:"approvedAt,omitempty"`
+ ApprovedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"approvedByUser"`
+ ApprovedByUserId *openapi_types.UUID `json:"approvedByUserId,omitempty"`
+ BypassReason *string `json:"bypassReason,omitempty"`
+ CreatedAt time.Time `json:"createdAt"`
+ DelegatedApproval *struct {
+ // Status Where the request stands in the delegated approval system that reviews it.
+ Status ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus `json:"status"`
+
+ // StatusReason Why the request is not progressing in, or could not be completed by, the delegated approval system, when that is the case.
+ StatusReason *string `json:"statusReason"`
+ } `json:"delegatedApproval,omitempty"`
+ EditNote *string `json:"editNote,omitempty"`
+ EditedByUserId *openapi_types.UUID `json:"editedByUserId,omitempty"`
+ EnvironmentName string `json:"environmentName"`
+ ExpiresAt *time.Time `json:"expiresAt,omitempty"`
+ Id openapi_types.UUID `json:"id"`
+ IsApproved bool `json:"isApproved"`
+ IsTemporary bool `json:"isTemporary"`
+ Note *string `json:"note,omitempty"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ Policy struct {
+ AllowedSelfApprovals bool `json:"allowedSelfApprovals"`
+ Approvals float32 `json:"approvals"`
+ Approvers []struct {
+ ApprovalsRequired *float32 `json:"approvalsRequired,omitempty"`
+ Email *string `json:"email,omitempty"`
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Sequence *float32 `json:"sequence,omitempty"`
+ UserId *string `json:"userId,omitempty"`
+ Username *string `json:"username,omitempty"`
+ } `json:"approvers"`
+ Bypassers []string `json:"bypassers"`
+ DelegatedApproval *struct {
+ // Type The delegated approval system that reviews requests made against this policy.
+ Type ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType `json:"type"`
+ } `json:"delegatedApproval,omitempty"`
+ DeletedAt *time.Time `json:"deletedAt,omitempty"`
+ EnforcementLevel string `json:"enforcementLevel"`
+ EnvId string `json:"envId"`
+ Id *string `json:"id"`
+ MaxTimePeriod *string `json:"maxTimePeriod,omitempty"`
+ Name string `json:"name"`
+ RequestExpirationTime *string `json:"requestExpirationTime,omitempty"`
+ SecretPath *string `json:"secretPath,omitempty"`
+ } `json:"policy"`
+ PolicyId *openapi_types.UUID `json:"policyId"`
+ Privilege *struct {
+ IsTemporary bool `json:"isTemporary"`
+ MembershipId string `json:"membershipId"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ TemporaryAccessEndTime *time.Time `json:"temporaryAccessEndTime,omitempty"`
+ TemporaryAccessStartTime *time.Time `json:"temporaryAccessStartTime,omitempty"`
+ TemporaryMode *string `json:"temporaryMode,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ } `json:"privilege"`
+ PrivilegeDeletedAt *time.Time `json:"privilegeDeletedAt,omitempty"`
+ PrivilegeId *openapi_types.UUID `json:"privilegeId,omitempty"`
+ RequestedByUser struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"requestedByUser"`
+ RequestedByUserId openapi_types.UUID `json:"requestedByUserId"`
+ Reviewers []struct {
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Status string `json:"status"`
+ UserId string `json:"userId"`
+ } `json:"reviewers"`
+ RevokedAt *time.Time `json:"revokedAt,omitempty"`
+ RevokedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"revokedByUser"`
+ RevokedByUserId *openapi_types.UUID `json:"revokedByUserId,omitempty"`
+ Status *string `json:"status,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ UpdatedAt time.Time `json:"updatedAt"`
+ } `json:"requests"`
+ }
+ // JSON400 the response for an HTTP 400 `application/json` response
+ JSON400 *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests400JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON401 the response for an HTTP 401 `application/json` response
+ JSON401 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests401JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON403 the response for an HTTP 403 `application/json` response
+ JSON403 *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests403JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON404 the response for an HTTP 404 `application/json` response
+ JSON404 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests404JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON422 the response for an HTTP 422 `application/json` response
+ JSON422 *struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests422JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON500 the response for an HTTP 500 `application/json` response
+ JSON500 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests500JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+}
+
+// GetJSON200 returns the response for an HTTP 200 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON200() *struct {
+ Requests []struct {
+ ApprovedAt *time.Time `json:"approvedAt,omitempty"`
+ ApprovedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"approvedByUser"`
+ ApprovedByUserId *openapi_types.UUID `json:"approvedByUserId,omitempty"`
+ BypassReason *string `json:"bypassReason,omitempty"`
+ CreatedAt time.Time `json:"createdAt"`
+ DelegatedApproval *struct {
+ // Status Where the request stands in the delegated approval system that reviews it.
+ Status ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus `json:"status"`
+
+ // StatusReason Why the request is not progressing in, or could not be completed by, the delegated approval system, when that is the case.
+ StatusReason *string `json:"statusReason"`
+ } `json:"delegatedApproval,omitempty"`
+ EditNote *string `json:"editNote,omitempty"`
+ EditedByUserId *openapi_types.UUID `json:"editedByUserId,omitempty"`
+ EnvironmentName string `json:"environmentName"`
+ ExpiresAt *time.Time `json:"expiresAt,omitempty"`
+ Id openapi_types.UUID `json:"id"`
+ IsApproved bool `json:"isApproved"`
+ IsTemporary bool `json:"isTemporary"`
+ Note *string `json:"note,omitempty"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ Policy struct {
+ AllowedSelfApprovals bool `json:"allowedSelfApprovals"`
+ Approvals float32 `json:"approvals"`
+ Approvers []struct {
+ ApprovalsRequired *float32 `json:"approvalsRequired,omitempty"`
+ Email *string `json:"email,omitempty"`
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Sequence *float32 `json:"sequence,omitempty"`
+ UserId *string `json:"userId,omitempty"`
+ Username *string `json:"username,omitempty"`
+ } `json:"approvers"`
+ Bypassers []string `json:"bypassers"`
+ DelegatedApproval *struct {
+ // Type The delegated approval system that reviews requests made against this policy.
+ Type ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType `json:"type"`
+ } `json:"delegatedApproval,omitempty"`
+ DeletedAt *time.Time `json:"deletedAt,omitempty"`
+ EnforcementLevel string `json:"enforcementLevel"`
+ EnvId string `json:"envId"`
+ Id *string `json:"id"`
+ MaxTimePeriod *string `json:"maxTimePeriod,omitempty"`
+ Name string `json:"name"`
+ RequestExpirationTime *string `json:"requestExpirationTime,omitempty"`
+ SecretPath *string `json:"secretPath,omitempty"`
+ } `json:"policy"`
+ PolicyId *openapi_types.UUID `json:"policyId"`
+ Privilege *struct {
+ IsTemporary bool `json:"isTemporary"`
+ MembershipId string `json:"membershipId"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ TemporaryAccessEndTime *time.Time `json:"temporaryAccessEndTime,omitempty"`
+ TemporaryAccessStartTime *time.Time `json:"temporaryAccessStartTime,omitempty"`
+ TemporaryMode *string `json:"temporaryMode,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ } `json:"privilege"`
+ PrivilegeDeletedAt *time.Time `json:"privilegeDeletedAt,omitempty"`
+ PrivilegeId *openapi_types.UUID `json:"privilegeId,omitempty"`
+ RequestedByUser struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"requestedByUser"`
+ RequestedByUserId openapi_types.UUID `json:"requestedByUserId"`
+ Reviewers []struct {
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Status string `json:"status"`
+ UserId string `json:"userId"`
+ } `json:"reviewers"`
+ RevokedAt *time.Time `json:"revokedAt,omitempty"`
+ RevokedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"revokedByUser"`
+ RevokedByUserId *openapi_types.UUID `json:"revokedByUserId,omitempty"`
+ Status *string `json:"status,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ UpdatedAt time.Time `json:"updatedAt"`
+ } `json:"requests"`
+} {
+ return r.JSON200
+}
+
+// GetJSON400 returns the response for an HTTP 400 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON400() *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests400JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON400
+}
+
+// GetJSON401 returns the response for an HTTP 401 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON401() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests401JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON401
+}
+
+// GetJSON403 returns the response for an HTTP 403 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON403() *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests403JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON403
+}
+
+// GetJSON404 returns the response for an HTTP 404 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON404() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests404JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON404
+}
+
+// GetJSON422 returns the response for an HTTP 422 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON422() *struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests422JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON422
+}
+
+// GetJSON500 returns the response for an HTTP 500 `application/json` response
+func (r ListAccessApprovalRequestsResponse) GetJSON500() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests500JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON500
+}
+
+// GetBody returns the raw response body bytes
+func (r ListAccessApprovalRequestsResponse) GetBody() []byte {
+ return r.Body
+}
+
+// Status returns HTTPResponse.Status
+func (r ListAccessApprovalRequestsResponse) Status() string {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.Status
+ }
+ return http.StatusText(0)
+}
+
+// StatusCode returns HTTPResponse.StatusCode
+func (r ListAccessApprovalRequestsResponse) StatusCode() int {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.StatusCode
+ }
+ return 0
+}
+
+// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
+func (r ListAccessApprovalRequestsResponse) ContentType() string {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.Header.Get("Content-Type")
+ }
+ return ""
+}
+
type CreateAccessApprovalRequestResponse struct {
Body []byte
HTTPResponse *http.Response
@@ -39926,6 +40798,157 @@ func (r ListProjectSecretsDetailsResponse) ContentType() string {
return ""
}
+type HandleDelegatedApprovalCallbackResponse struct {
+ Body []byte
+ HTTPResponse *http.Response
+ // JSON200 the response for an HTTP 200 `application/json` response
+ JSON200 *struct {
+ Message string `json:"message"`
+ }
+ // JSON400 the response for an HTTP 400 `application/json` response
+ JSON400 *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON401 the response for an HTTP 401 `application/json` response
+ JSON401 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON403 the response for an HTTP 403 `application/json` response
+ JSON403 *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON404 the response for an HTTP 404 `application/json` response
+ JSON404 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON422 the response for an HTTP 422 `application/json` response
+ JSON422 *struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ // JSON500 the response for an HTTP 500 `application/json` response
+ JSON500 *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+}
+
+// GetJSON200 returns the response for an HTTP 200 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON200() *struct {
+ Message string `json:"message"`
+} {
+ return r.JSON200
+}
+
+// GetJSON400 returns the response for an HTTP 400 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON400() *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON400
+}
+
+// GetJSON401 returns the response for an HTTP 401 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON401() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON401
+}
+
+// GetJSON403 returns the response for an HTTP 403 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON403() *struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON403
+}
+
+// GetJSON404 returns the response for an HTTP 404 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON404() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON404
+}
+
+// GetJSON422 returns the response for an HTTP 422 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON422() *struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON422
+}
+
+// GetJSON500 returns the response for an HTTP 500 `application/json` response
+func (r HandleDelegatedApprovalCallbackResponse) GetJSON500() *struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode `json:"statusCode"`
+} {
+ return r.JSON500
+}
+
+// GetBody returns the raw response body bytes
+func (r HandleDelegatedApprovalCallbackResponse) GetBody() []byte {
+ return r.Body
+}
+
+// Status returns HTTPResponse.Status
+func (r HandleDelegatedApprovalCallbackResponse) Status() string {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.Status
+ }
+ return http.StatusText(0)
+}
+
+// StatusCode returns HTTPResponse.StatusCode
+func (r HandleDelegatedApprovalCallbackResponse) StatusCode() int {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.StatusCode
+ }
+ return 0
+}
+
+// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
+func (r HandleDelegatedApprovalCallbackResponse) ContentType() string {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.Header.Get("Content-Type")
+ }
+ return ""
+}
+
type ListEmailDomainsResponse struct {
Body []byte
HTTPResponse *http.Response
@@ -55841,6 +56864,17 @@ func (c *ClientWithResponses) UpdateAccessApprovalPolicyWithResponse(ctx context
return ParseUpdateAccessApprovalPolicyResponse(rsp)
}
+// ListAccessApprovalRequestsWithResponse performs a GET /api/v1/access-approvals/requests (the `ListAccessApprovalRequests` operationId) request.
+//
+// Returns a wrapper object for the known response body format(s).
+func (c *ClientWithResponses) ListAccessApprovalRequestsWithResponse(ctx context.Context, params *ListAccessApprovalRequestsParams, reqEditors ...RequestEditorFn) (*ListAccessApprovalRequestsResponse, error) {
+ rsp, err := c.ListAccessApprovalRequests(ctx, params, reqEditors...)
+ if err != nil {
+ return nil, err
+ }
+ return ParseListAccessApprovalRequestsResponse(rsp)
+}
+
// CreateAccessApprovalRequestWithBodyWithResponse performs a POST /api/v1/access-approvals/requests (the `CreateAccessApprovalRequest` operationId) request,
// with any type of body and a specified content type.
//
@@ -56074,6 +57108,32 @@ func (c *ClientWithResponses) ListProjectSecretsDetailsWithResponse(ctx context.
return ParseListProjectSecretsDetailsResponse(rsp)
}
+// HandleDelegatedApprovalCallbackWithBodyWithResponse performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request,
+// with any type of body and a specified content type.
+//
+// Receive a decision notification from a delegated approval system.
+//
+// Returns a wrapper object for the known response body format(s).
+func (c *ClientWithResponses) HandleDelegatedApprovalCallbackWithBodyWithResponse(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*HandleDelegatedApprovalCallbackResponse, error) {
+ rsp, err := c.HandleDelegatedApprovalCallbackWithBody(ctx, params, contentType, body, reqEditors...)
+ if err != nil {
+ return nil, err
+ }
+ return ParseHandleDelegatedApprovalCallbackResponse(rsp)
+}
+
+// HandleDelegatedApprovalCallbackWithResponse performs a POST /api/v1/delegated-approvals/callback (the `HandleDelegatedApprovalCallback` operationId) request.
+// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
+//
+// Receive a decision notification from a delegated approval system.
+func (c *ClientWithResponses) HandleDelegatedApprovalCallbackWithResponse(ctx context.Context, params *HandleDelegatedApprovalCallbackParams, body HandleDelegatedApprovalCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*HandleDelegatedApprovalCallbackResponse, error) {
+ rsp, err := c.HandleDelegatedApprovalCallback(ctx, params, body, reqEditors...)
+ if err != nil {
+ return nil, err
+ }
+ return ParseHandleDelegatedApprovalCallbackResponse(rsp)
+}
+
// ListEmailDomainsWithResponse performs a GET /api/v1/email-domains (the `ListEmailDomains` operationId) request.
//
// Returns a wrapper object for the known response body format(s).
@@ -58509,6 +59569,198 @@ func ParseUpdateAccessApprovalPolicyResponse(rsp *http.Response) (*UpdateAccessA
return response, nil
}
+// ParseListAccessApprovalRequestsResponse parses an HTTP response from a ListAccessApprovalRequestsWithResponse call
+func ParseListAccessApprovalRequestsResponse(rsp *http.Response) (*ListAccessApprovalRequestsResponse, error) {
+ bodyBytes, err := io.ReadAll(rsp.Body)
+ defer func() { _ = rsp.Body.Close() }()
+ if err != nil {
+ return nil, err
+ }
+
+ response := &ListAccessApprovalRequestsResponse{
+ Body: bodyBytes,
+ HTTPResponse: rsp,
+ }
+
+ switch {
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
+ var dest struct {
+ Requests []struct {
+ ApprovedAt *time.Time `json:"approvedAt,omitempty"`
+ ApprovedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"approvedByUser"`
+ ApprovedByUserId *openapi_types.UUID `json:"approvedByUserId,omitempty"`
+ BypassReason *string `json:"bypassReason,omitempty"`
+ CreatedAt time.Time `json:"createdAt"`
+ DelegatedApproval *struct {
+ // Status Where the request stands in the delegated approval system that reviews it.
+ Status ListAccessApprovalRequests200JSONResponseBodyRequestsDelegatedApprovalStatus `json:"status"`
+
+ // StatusReason Why the request is not progressing in, or could not be completed by, the delegated approval system, when that is the case.
+ StatusReason *string `json:"statusReason"`
+ } `json:"delegatedApproval,omitempty"`
+ EditNote *string `json:"editNote,omitempty"`
+ EditedByUserId *openapi_types.UUID `json:"editedByUserId,omitempty"`
+ EnvironmentName string `json:"environmentName"`
+ ExpiresAt *time.Time `json:"expiresAt,omitempty"`
+ Id openapi_types.UUID `json:"id"`
+ IsApproved bool `json:"isApproved"`
+ IsTemporary bool `json:"isTemporary"`
+ Note *string `json:"note,omitempty"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ Policy struct {
+ AllowedSelfApprovals bool `json:"allowedSelfApprovals"`
+ Approvals float32 `json:"approvals"`
+ Approvers []struct {
+ ApprovalsRequired *float32 `json:"approvalsRequired,omitempty"`
+ Email *string `json:"email,omitempty"`
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Sequence *float32 `json:"sequence,omitempty"`
+ UserId *string `json:"userId,omitempty"`
+ Username *string `json:"username,omitempty"`
+ } `json:"approvers"`
+ Bypassers []string `json:"bypassers"`
+ DelegatedApproval *struct {
+ // Type The delegated approval system that reviews requests made against this policy.
+ Type ListAccessApprovalRequests200JSONResponseBodyRequestsPolicyDelegatedApprovalType `json:"type"`
+ } `json:"delegatedApproval,omitempty"`
+ DeletedAt *time.Time `json:"deletedAt,omitempty"`
+ EnforcementLevel string `json:"enforcementLevel"`
+ EnvId string `json:"envId"`
+ Id *string `json:"id"`
+ MaxTimePeriod *string `json:"maxTimePeriod,omitempty"`
+ Name string `json:"name"`
+ RequestExpirationTime *string `json:"requestExpirationTime,omitempty"`
+ SecretPath *string `json:"secretPath,omitempty"`
+ } `json:"policy"`
+ PolicyId *openapi_types.UUID `json:"policyId"`
+ Privilege *struct {
+ IsTemporary bool `json:"isTemporary"`
+ MembershipId string `json:"membershipId"`
+ Permissions interface{} `json:"permissions,omitempty"`
+ TemporaryAccessEndTime *time.Time `json:"temporaryAccessEndTime,omitempty"`
+ TemporaryAccessStartTime *time.Time `json:"temporaryAccessStartTime,omitempty"`
+ TemporaryMode *string `json:"temporaryMode,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ } `json:"privilege"`
+ PrivilegeDeletedAt *time.Time `json:"privilegeDeletedAt,omitempty"`
+ PrivilegeId *openapi_types.UUID `json:"privilegeId,omitempty"`
+ RequestedByUser struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"requestedByUser"`
+ RequestedByUserId openapi_types.UUID `json:"requestedByUserId"`
+ Reviewers []struct {
+ IsOrgMembershipActive *bool `json:"isOrgMembershipActive,omitempty"`
+ Status string `json:"status"`
+ UserId string `json:"userId"`
+ } `json:"reviewers"`
+ RevokedAt *time.Time `json:"revokedAt,omitempty"`
+ RevokedByUser *struct {
+ Email *string `json:"email,omitempty"`
+ FirstName *string `json:"firstName,omitempty"`
+ LastName *string `json:"lastName,omitempty"`
+ UserId string `json:"userId"`
+ Username string `json:"username"`
+ } `json:"revokedByUser"`
+ RevokedByUserId *openapi_types.UUID `json:"revokedByUserId,omitempty"`
+ Status *string `json:"status,omitempty"`
+ TemporaryRange *string `json:"temporaryRange,omitempty"`
+ UpdatedAt time.Time `json:"updatedAt"`
+ } `json:"requests"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON200 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
+ var dest struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests400JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON400 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests401JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON401 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
+ var dest struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests403JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON403 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests404JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON404 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
+ var dest struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests422JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON422 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode ListAccessApprovalRequests500JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON500 = &dest
+
+ }
+
+ return response, nil
+}
+
// ParseCreateAccessApprovalRequestResponse parses an HTTP response from a CreateAccessApprovalRequestWithResponse call
func ParseCreateAccessApprovalRequestResponse(rsp *http.Response) (*CreateAccessApprovalRequestResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)
@@ -59950,6 +61202,108 @@ func ParseListProjectSecretsDetailsResponse(rsp *http.Response) (*ListProjectSec
return response, nil
}
+// ParseHandleDelegatedApprovalCallbackResponse parses an HTTP response from a HandleDelegatedApprovalCallbackWithResponse call
+func ParseHandleDelegatedApprovalCallbackResponse(rsp *http.Response) (*HandleDelegatedApprovalCallbackResponse, error) {
+ bodyBytes, err := io.ReadAll(rsp.Body)
+ defer func() { _ = rsp.Body.Close() }()
+ if err != nil {
+ return nil, err
+ }
+
+ response := &HandleDelegatedApprovalCallbackResponse{
+ Body: bodyBytes,
+ HTTPResponse: rsp,
+ }
+
+ switch {
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
+ var dest struct {
+ Message string `json:"message"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON200 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
+ var dest struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback400JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON400 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback401JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON401 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
+ var dest struct {
+ Details interface{} `json:"details,omitempty"`
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback403JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON403 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback404JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON404 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
+ var dest struct {
+ Error string `json:"error"`
+ Message interface{} `json:"message,omitempty"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback422JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON422 = &dest
+
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
+ var dest struct {
+ Error string `json:"error"`
+ Message string `json:"message"`
+ ReqId string `json:"reqId"`
+ StatusCode HandleDelegatedApprovalCallback500JSONResponseBodyStatusCode `json:"statusCode"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON500 = &dest
+
+ }
+
+ return response, nil
+}
+
// ParseListEmailDomainsResponse parses an HTTP response from a ListEmailDomainsWithResponse call
func ParseListEmailDomainsResponse(rsp *http.Response) (*ListEmailDomainsResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)
diff --git a/tests/clients/api/oapi-codegen.yaml b/tests/clients/api/oapi-codegen.yaml
index a640f44227..b7e7d480d2 100644
--- a/tests/clients/api/oapi-codegen.yaml
+++ b/tests/clients/api/oapi-codegen.yaml
@@ -87,6 +87,8 @@ output-options:
- updateAccessApprovalPolicy
- getAccessApprovalPolicy
- createAccessApprovalRequest
+ - listAccessApprovalRequests
+ - handleDelegatedApprovalCallback
- createGroup
- addUserToGroup
- removeUserFromGroup
diff --git a/tests/fakes/servicenow/controlplane.go b/tests/fakes/servicenow/controlplane.go
new file mode 100644
index 0000000000..d8c7b88b66
--- /dev/null
+++ b/tests/fakes/servicenow/controlplane.go
@@ -0,0 +1,40 @@
+package servicenow
+
+import (
+ "testing"
+
+ "github.com/Infisical/infisical/tests/infra/fakenet"
+)
+
+// ControlPlane is a test's view of one ServiceNow instance inside fakenet.
+type ControlPlane struct {
+ *fakenet.Scope[Instance]
+}
+
+// Open returns the instance an integration user addresses.
+func Open(tt *testing.T, adminURL, username string) *ControlPlane {
+ tt.Helper()
+ return &ControlPlane{fakenet.Open[Instance](tt, adminURL, Service.Host(), username)}
+}
+
+// AccessRequest is the record Infisical created for an approval request. Nil until the
+// request has been sent.
+func (cp *ControlPlane) AccessRequest(tt *testing.T, requestID string) *AccessRequest {
+ tt.Helper()
+ for _, rec := range cp.State(tt).AccessRequests {
+ if rec.RequestID == requestID {
+ return rec
+ }
+ }
+ return nil
+}
+
+// Approved records an approver approving a record as it was sent.
+func Approved(sysID string) any {
+ return Instance{AccessRequests: map[string]*AccessRequest{sysID: {Decision: "approved"}}}
+}
+
+// Rejected records an approver rejecting a record.
+func Rejected(sysID, notes string) any {
+ return Instance{AccessRequests: map[string]*AccessRequest{sysID: {Decision: "rejected", DecisionNotes: notes}}}
+}
diff --git a/tests/fakes/servicenow/events.go b/tests/fakes/servicenow/events.go
new file mode 100644
index 0000000000..be4e8020b6
--- /dev/null
+++ b/tests/fakes/servicenow/events.go
@@ -0,0 +1,15 @@
+package servicenow
+
+// AccessRequestDetail identifies a record of the Infisical Approvals application.
+type AccessRequestDetail struct {
+ SysID string `json:"sysId"`
+ RequestID string `json:"requestId"`
+}
+
+type AccessRequestCreated struct{ AccessRequestDetail }
+
+// AccessRequestRead is Infisical reading a record back to learn its decision.
+type AccessRequestRead struct{ AccessRequestDetail }
+
+func (AccessRequestCreated) EventName() string { return "servicenow.access-request-created" }
+func (AccessRequestRead) EventName() string { return "servicenow.access-request-read" }
diff --git a/tests/fakes/servicenow/fake.go b/tests/fakes/servicenow/fake.go
index 1cad3f4327..caf6407955 100644
--- a/tests/fakes/servicenow/fake.go
+++ b/tests/fakes/servicenow/fake.go
@@ -1,8 +1,12 @@
package servicenow
import (
+ "crypto/rand"
+ "encoding/hex"
"encoding/json"
+ "fmt"
"net/http"
+ "strings"
"github.com/Infisical/infisical/tests/infra/fakenet"
)
@@ -14,6 +18,9 @@ import (
// through fakenet's DNS and CA, never by pointing the connection at fakenet itself.
var Service = service{host: "harness.service-now.com"}
+// accessRequestPath is the Scripted REST API the Infisical Approvals application serves.
+const accessRequestPath = "/api/x_infis_approvals/v1/infisical/access_request"
+
type service struct{ host string }
func (s service) Host() string { return s.host }
@@ -24,8 +31,12 @@ func (service) Scope(r *http.Request) (string, bool) {
return user, ok
}
-func (service) New(fakenet.Emitter) fakenet.Fake {
- in := &Instance{UserSysID: "6816f79cc0a8016401c5a33be04be441"}
+func (service) New(events fakenet.Emitter) fakenet.Fake {
+ in := &Instance{
+ UserSysID: "6816f79cc0a8016401c5a33be04be441",
+ AccessRequests: map[string]*AccessRequest{},
+ events: events,
+ }
in.mux = in.routes()
return in
}
@@ -39,6 +50,9 @@ func (in *Instance) routes() *http.ServeMux {
// so the fake answers it by existing rather than because a test registered anything.
mux.HandleFunc("GET /api/now/ui/user/current_user", in.currentUser)
+ mux.HandleFunc("POST "+accessRequestPath, in.createAccessRequest)
+ mux.HandleFunc("GET "+accessRequestPath+"/{sysID}", in.readAccessRequest)
+
return mux
}
@@ -51,13 +65,88 @@ func (in *Instance) currentUser(w http.ResponseWriter, r *http.Request) {
})
}
+func (in *Instance) createAccessRequest(w http.ResponseWriter, r *http.Request) {
+ var body struct {
+ RequestID string `json:"request_id"`
+ CallbackURL string `json:"callback_url"`
+ CallbackToken string `json:"callback_token"`
+ Environment string `json:"environment"`
+ SecretPath string `json:"secret_path"`
+ RequestorEmail string `json:"requestor_email"`
+ Permissions []string `json:"permissions"`
+ }
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ writeError(w, http.StatusBadRequest, "Request body is not valid JSON")
+ return
+ }
+ if body.RequestID == "" || body.CallbackURL == "" || body.CallbackToken == "" {
+ writeError(w, http.StatusBadRequest, "request_id, callback_url and callback_token are required")
+ return
+ }
+
+ in.mu.Lock()
+ defer in.mu.Unlock()
+
+ // The application keeps one record per request_id, so a resend after a lost
+ // response gets back the record it already made instead of a second one.
+ for _, rec := range in.AccessRequests {
+ if rec.RequestID == body.RequestID {
+ writeJSON(w, http.StatusConflict, map[string]any{"result": map[string]any{"sys_id": rec.SysID}})
+ return
+ }
+ }
+
+ rec := &AccessRequest{
+ SysID: newSysID(),
+ RequestID: body.RequestID,
+ CallbackURL: body.CallbackURL,
+ CallbackToken: body.CallbackToken,
+ Environment: body.Environment,
+ SecretPath: body.SecretPath,
+ RequestorEmail: body.RequestorEmail,
+ Permissions: body.Permissions,
+ }
+ in.AccessRequests[rec.SysID] = rec
+ in.events.Publish(AccessRequestCreated{rec.detail()})
+ writeJSON(w, http.StatusCreated, map[string]any{"result": map[string]any{"sys_id": rec.SysID}})
+}
+
+func (in *Instance) readAccessRequest(w http.ResponseWriter, r *http.Request) {
+ in.mu.Lock()
+ defer in.mu.Unlock()
+
+ rec, ok := in.AccessRequests[r.PathValue("sysID")]
+ if !ok {
+ writeError(w, http.StatusNotFound, "No Record found")
+ return
+ }
+
+ state := "awaiting_approval"
+ if rec.Decision != "" {
+ state = "callback_pending"
+ }
+ in.events.Publish(AccessRequestRead{rec.detail()})
+ writeJSON(w, http.StatusOK, map[string]any{"result": map[string]any{
+ "success": true,
+ "data": map[string]any{
+ "sys_id": rec.SysID,
+ "request_id": rec.RequestID,
+ "permissions": strings.Join(rec.Permissions, "\n"),
+ "state": state,
+ "decision": nullable(rec.Decision),
+ "decision_notes": nullable(rec.DecisionNotes),
+ },
+ }})
+}
+
func (in *Instance) Snapshot() ([]byte, error) {
in.mu.Lock()
defer in.mu.Unlock()
return json.Marshal(in)
}
-// Seed merges a partial instance in, so a test names only what it cares about.
+// Seed merges a partial instance in, so a test names only what it cares about. A
+// record is only ever decided here, never created: Infisical is what creates them.
func (in *Instance) Seed(raw []byte) error {
var seed Instance
if err := json.Unmarshal(raw, &seed); err != nil {
@@ -69,11 +158,37 @@ func (in *Instance) Seed(raw []byte) error {
if seed.UserSysID != "" {
in.UserSysID = seed.UserSysID
}
+ for sysID, decided := range seed.AccessRequests {
+ rec, ok := in.AccessRequests[sysID]
+ if !ok {
+ return fmt.Errorf("servicenow fake: no access request %q to decide", sysID)
+ }
+ rec.Decision, rec.DecisionNotes = decided.Decision, decided.DecisionNotes
+ }
return nil
}
+// newSysID is shaped like ServiceNow's: 32 lowercase hex characters.
+func newSysID() string {
+ b := make([]byte, 16)
+ _, _ = rand.Read(b)
+ return hex.EncodeToString(b)
+}
+
+// nullable reports an empty field as null, which is how ServiceNow sends one.
+func nullable(s string) any {
+ if s == "" {
+ return nil
+ }
+ return s
+}
+
func writeJSON(w http.ResponseWriter, status int, body any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(body)
}
+
+func writeError(w http.ResponseWriter, status int, msg string) {
+ writeJSON(w, status, map[string]any{"error": map[string]string{"message": msg}, "status": "failure"})
+}
diff --git a/tests/fakes/servicenow/fake_test.go b/tests/fakes/servicenow/fake_test.go
index 985bf30cbd..e191bdd22f 100644
--- a/tests/fakes/servicenow/fake_test.go
+++ b/tests/fakes/servicenow/fake_test.go
@@ -1,6 +1,7 @@
package servicenow_test
import (
+ "bytes"
"encoding/json"
"io"
"net/http"
@@ -43,3 +44,80 @@ func TestCurrentUser(t *testing.T) {
require.NoError(t, json.Unmarshal(body, &reply))
require.Equal(t, "integration-user", reply.Result.UserName)
}
+
+func TestAccessRequests(t *testing.T) {
+ t.Parallel()
+
+ send := func(t *testing.T, fake http.Handler, method, path string, body any) (int, []byte) {
+ t.Helper()
+ var payload io.Reader
+ if body != nil {
+ raw, err := json.Marshal(body)
+ require.NoError(t, err)
+ payload = bytes.NewReader(raw)
+ }
+ rec := httptest.NewRecorder()
+ fake.ServeHTTP(rec, httptest.NewRequestWithContext(t.Context(), method, path, payload))
+ return rec.Code, rec.Body.Bytes()
+ }
+ create := func(t *testing.T, fake http.Handler, requestID string) (int, string) {
+ t.Helper()
+ code, body := send(t, fake, http.MethodPost, "/api/x_infis_approvals/v1/infisical/access_request", map[string]any{
+ "request_id": requestID,
+ "callback_url": "https://infisical.test/api/v1/delegated-approvals/callback",
+ "callback_token": "inf_ext_token",
+ "permissions": []string{"secrets: read", "secret-folders: read"},
+ })
+ var reply struct {
+ Result struct {
+ SysID string `json:"sys_id"`
+ } `json:"result"`
+ }
+ require.NoErrorf(t, json.Unmarshal(body, &reply), "create: %s", body)
+ return code, reply.Result.SysID
+ }
+
+ t.Run("should report the decision an approver recorded when the record is read back", func(t *testing.T) {
+ t.Parallel()
+
+ // Setup
+ fake := servicenow.Service.New(fakenet.Emitter{})
+ _, sysID := create(t, fake, "request-1")
+ raw, err := json.Marshal(servicenow.Approved(sysID))
+ require.NoError(t, err)
+ require.NoError(t, fake.Seed(raw))
+
+ // Action
+ code, body := send(t, fake, http.MethodGet, "/api/x_infis_approvals/v1/infisical/access_request/"+sysID, nil)
+
+ // Assert
+ require.Equalf(t, http.StatusOK, code, "read back: %s", body)
+ var reply struct {
+ Result struct {
+ Data struct {
+ RequestID string `json:"request_id"`
+ Permissions string `json:"permissions"`
+ Decision *string `json:"decision"`
+ } `json:"data"`
+ } `json:"result"`
+ }
+ require.NoError(t, json.Unmarshal(body, &reply))
+ require.Equal(t, "secrets: read\nsecret-folders: read", reply.Result.Data.Permissions)
+ require.Equal(t, new("approved"), reply.Result.Data.Decision)
+ })
+
+ t.Run("should return the record it already holds when the same request is sent twice", func(t *testing.T) {
+ t.Parallel()
+
+ // Setup
+ fake := servicenow.Service.New(fakenet.Emitter{})
+ _, first := create(t, fake, "request-1")
+
+ // Action
+ code, second := create(t, fake, "request-1")
+
+ // Assert
+ require.Equal(t, http.StatusConflict, code)
+ require.Equal(t, first, second)
+ })
+}
diff --git a/tests/fakes/servicenow/state.go b/tests/fakes/servicenow/state.go
index 5fc145e527..ac588ab720 100644
--- a/tests/fakes/servicenow/state.go
+++ b/tests/fakes/servicenow/state.go
@@ -8,13 +8,38 @@ package servicenow
import (
"net/http"
"sync"
+
+ "github.com/Infisical/infisical/tests/infra/fakenet"
)
// Instance is one ServiceNow instance as one integration user sees it, addressed by
// the username a test invented.
type Instance struct {
- UserSysID string `json:"userSysId"`
+ UserSysID string `json:"userSysId"`
+ AccessRequests map[string]*AccessRequest `json:"accessRequests"`
+
+ mu sync.Mutex
+ mux *http.ServeMux
+ events fakenet.Emitter
+}
+
+// AccessRequest is a record of the Infisical Approvals application, keyed by its sys_id.
+// Everything above Decision is what Infisical sent; Decision and DecisionNotes are what
+// an approver records in ServiceNow, and stay empty until a test seeds them.
+type AccessRequest struct {
+ SysID string `json:"sysId"`
+ RequestID string `json:"requestId"`
+ CallbackURL string `json:"callbackUrl"`
+ CallbackToken string `json:"callbackToken"`
+ Environment string `json:"environment"`
+ SecretPath string `json:"secretPath"`
+ RequestorEmail string `json:"requestorEmail"`
+ Permissions []string `json:"permissions"`
+
+ Decision string `json:"decision,omitempty"`
+ DecisionNotes string `json:"decisionNotes,omitempty"`
+}
- mu sync.Mutex
- mux *http.ServeMux
+func (rec *AccessRequest) detail() AccessRequestDetail {
+ return AccessRequestDetail{SysID: rec.SysID, RequestID: rec.RequestID}
}
diff --git a/tests/harness/infisical/infisical.go b/tests/harness/infisical/infisical.go
index 444de9b509..5926cb355d 100644
--- a/tests/harness/infisical/infisical.go
+++ b/tests/harness/infisical/infisical.go
@@ -96,7 +96,9 @@ func (m *module) Start(ctx context.Context, d infra.Deps) (infra.Handle, error)
// every call it makes and has no hand-written client to fall back on, so a
// route missing from the spec is a route no test can reach.
"OPENAPI_FULL_SPEC": "true",
- "SITE_URL": fmt.Sprintf("http://%s:%d", self, port),
+ // https although the server listens on plain http: nothing dials SITE_URL, and a
+ // delegated approval system refuses a callback URL that is not https.
+ "SITE_URL": fmt.Sprintf("https://%s:%d", self, port),
}
if m.runModes != "" {
env["INFISICAL_RUN_MODES"] = m.runModes
@@ -171,7 +173,7 @@ func (h *Handle) BaseURL(m infra.Mode) string { return h.Endpoint(m).URL("http")
// SiteURL is the SITE_URL the server was started with: the SAML audience, and the
// origin of every redirect it builds. Not reachable from the test process.
-func (h *Handle) SiteURL() string { return h.BaseURL(infra.Internal) }
+func (h *Handle) SiteURL() string { return h.Endpoint(infra.Internal).URL("https") }
// Logs is what a failure dumps. Under a Shared profile one instance serves every
// parallel tenant, so a caller filters by org id rather than printing all of it.
diff --git a/tests/suites/secretmanager/approvals/delegated_access_request_test.go b/tests/suites/secretmanager/approvals/delegated_access_request_test.go
new file mode 100644
index 0000000000..551db90cd3
--- /dev/null
+++ b/tests/suites/secretmanager/approvals/delegated_access_request_test.go
@@ -0,0 +1,282 @@
+package approvals_test
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/Infisical/infisical/tests/clients/api"
+ "github.com/Infisical/infisical/tests/fakes/servicenow"
+ "github.com/Infisical/infisical/tests/fixture"
+ "github.com/Infisical/infisical/tests/fixture/secretmanager"
+ "github.com/Infisical/infisical/tests/harness"
+ "github.com/Infisical/infisical/tests/infra/fakenet"
+ "github.com/Infisical/infisical/tests/internal/apierr"
+ "github.com/Infisical/infisical/tests/internal/spec"
+ "github.com/Infisical/infisical/tests/internal/wait"
+ "github.com/google/uuid"
+ "github.com/stretchr/testify/require"
+)
+
+// Sending a request to ServiceNow and reading its decision back both go through the
+// event outbox, whose relay polls every 10 seconds and has no manual trigger.
+const outboxWait = 30 * time.Second
+
+// quietWait is how long nothing has to happen: past one relay poll, and short of the 30
+// second backoff before a read-back that found no decision runs again.
+const quietWait = 20 * time.Second
+
+func TestDelegatedAccessRequest_Decision(t *testing.T) {
+ t.Parallel()
+
+ t.Run("should grant the requester access when ServiceNow approves", func(t *testing.T) {
+ t.Parallel()
+
+ // Setup
+ req := newWaitingDelegatedRequest(t)
+ req.sn.Seed(t, servicenow.Approved(req.record.SysID))
+
+ // Action
+ code := req.callback(t, req.record.CallbackToken)
+
+ // Assert
+ require.Equal(t, http.StatusOK, code)
+ require.Equal(t, delegatedState{status: "approved", delegated: "approved", granted: true}, req.await(t, "approved"))
+ wait.Until(t, "the requester to read the secret", func() bool { return req.readSecret(t) == http.StatusOK },
+ wait.Timeout(outboxWait), wait.Interval(time.Second))
+ })
+
+ t.Run("should close the request without a grant when ServiceNow rejects", func(t *testing.T) {
+ t.Parallel()
+
+ // Setup
+ req := newWaitingDelegatedRequest(t)
+ req.sn.Seed(t, servicenow.Rejected(req.record.SysID, "Not during the release freeze."))
+
+ // Action
+ code := req.callback(t, req.record.CallbackToken)
+
+ // Assert
+ require.Equal(t, http.StatusOK, code)
+ require.Equal(t, delegatedState{status: "rejected", delegated: "rejected"}, req.await(t, "rejected"))
+ require.Equal(t, http.StatusForbidden, req.readSecret(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.Parallel()
+
+ // Setup
+ req := newWaitingDelegatedRequest(t)
+ for range 5 {
+ require.Equal(t, http.StatusOK, req.callback(t, req.record.CallbackToken))
+ }
+
+ // Action
+ 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))
+ })
+}
+
+func TestDelegatedAccessRequest_CallbackToken(t *testing.T) {
+ t.Parallel()
+
+ t.Run("should not read the decision when the token belongs to another request", func(t *testing.T) {
+ t.Parallel()
+
+ // Setup
+ req, other := newWaitingDelegatedRequest(t), newWaitingDelegatedRequest(t)
+ req.sn.Seed(t, servicenow.Approved(req.record.SysID))
+
+ // Action
+ code := req.callback(t, other.record.CallbackToken)
+
+ // Assert
+ require.Equal(t, http.StatusForbidden, code)
+ req.sn.ExpectNoEvent[servicenow.AccessRequestRead](t, nil, fakenet.Within(quietWait))
+ require.Equal(t, delegatedState{status: "pending", delegated: "waiting_approval"}, req.current(t))
+ })
+}
+
+func TestDelegatedAccessRequest_DuplicateCallback(t *testing.T) {
+ t.Parallel()
+
+ t.Run("should read the decision once when the same callback arrives twice at once", func(t *testing.T) {
+ t.Parallel()
+ spec.Why(t, "The decision is left pending so that every read-back that runs is visible; one that "+
+ "found a decision would close the request, and a second would then have nothing to read.")
+
+ // Setup
+ req := newWaitingDelegatedRequest(t)
+ client := req.tn.Anonymous(t)
+
+ // Action
+ codes, errs := make([]int, 2), make([]error, 2)
+ var wg sync.WaitGroup
+ for i := range codes {
+ wg.Go(func() {
+ codes[i], errs[i] = sendCallback(t.Context(), client, req.record.SysID, req.record.CallbackToken)
+ })
+ }
+ wg.Wait()
+
+ // Assert
+ require.NoError(t, errors.Join(errs...))
+ require.Equal(t, []int{http.StatusOK, http.StatusOK}, codes)
+ req.sn.ExpectEvent[servicenow.AccessRequestRead](t, nil, fakenet.Within(outboxWait))
+ req.sn.ExpectNoEvent[servicenow.AccessRequestRead](t, nil, fakenet.Within(quietWait))
+ })
+}
+
+// delegatedRequest is an access request ServiceNow holds and has not decided yet. The
+// test plays ServiceNow's side: it decides in the fake and sends the callback itself.
+type delegatedRequest struct {
+ tn *harness.Tenant
+ proj *fixture.Project
+ requester *harness.Principal
+ sn *servicenow.ControlPlane
+ id uuid.UUID
+ record *servicenow.AccessRequest
+}
+
+// newWaitingDelegatedRequest has a requester with no access ask to read dev:/, where a
+// delegated policy sends the request to ServiceNow.
+func newWaitingDelegatedRequest(t *testing.T) *delegatedRequest {
+ t.Helper()
+ tn := harness.From(t).NewTenant(t)
+ proj := fixture.NewProject(t, tn, fixture.WithProjectType("secret-manager"))
+ conn := newDelegatedApprovalSystem(t, tn)
+ newDelegatedAccessPolicy(t, proj, conn)
+ secretmanager.CreateSecret(t, proj, "dev", "DB_PASSWORD", "hunter2")
+ req := &delegatedRequest{
+ tn: tn,
+ proj: proj,
+ requester: proj.NewUser(t, fixture.WithPrincipalName("requester"), fixture.WithRoles("no-access")),
+ sn: servicenow.Open(t, conn.FakenetAdmin(t), conn.Nonce()),
+ }
+
+ req.id = requestAccess(t, req.requester, proj, "dev", "/")
+ req.sn.ExpectEvent[servicenow.AccessRequestCreated](t, func(e servicenow.AccessRequestCreated) bool {
+ return e.RequestID == req.id.String()
+ }, fakenet.Within(outboxWait))
+ req.await(t, "waiting_approval")
+ req.record = req.sn.AccessRequest(t, req.id.String())
+ return req
+}
+
+// delegatedState is the request as its requester sees it: Infisical's status, the
+// delegated approval system's status and why it stopped, and whether access was granted.
+type delegatedState struct {
+ status string
+ delegated string
+ reason string
+ granted bool
+}
+
+func (r *delegatedRequest) state(ctx context.Context) (delegatedState, error) {
+ res, err := r.requester.API.ListAccessApprovalRequestsWithResponse(ctx,
+ &api.ListAccessApprovalRequestsParams{ProjectSlug: r.proj.Slug})
+ if err != nil {
+ return delegatedState{}, err
+ }
+ if res.JSON200 == nil {
+ return delegatedState{}, fmt.Errorf("listing access requests returned %d: %s", res.StatusCode(), apierr.Body(res.Body))
+ }
+ for _, item := range res.JSON200.Requests {
+ if item.Id != r.id {
+ continue
+ }
+ st := delegatedState{granted: item.Privilege != nil}
+ if item.Status != nil {
+ st.status = *item.Status
+ }
+ if item.DelegatedApproval != nil {
+ st.delegated = string(item.DelegatedApproval.Status)
+ if item.DelegatedApproval.StatusReason != nil {
+ st.reason = *item.DelegatedApproval.StatusReason
+ }
+ }
+ return st, nil
+ }
+ return delegatedState{}, fmt.Errorf("access request %s is not listed", r.id)
+}
+
+// await waits for the delegated approval system's status to reach want.
+func (r *delegatedRequest) await(t *testing.T, want string) delegatedState {
+ t.Helper()
+ got, err := wait.For(t.Context(), func(ctx context.Context) (delegatedState, bool, error) {
+ st, err := r.state(ctx)
+ return st, err == nil && st.delegated == want, err
+ }, wait.Timeout(outboxWait))
+ require.NoErrorf(t, err, "waiting for the delegated request to reach %s", want)
+ return got
+}
+
+func (r *delegatedRequest) current(t *testing.T) delegatedState {
+ t.Helper()
+ st, err := r.state(t.Context())
+ require.NoError(t, err)
+ return st
+}
+
+// callback sends what ServiceNow sends once an approver decides.
+func (r *delegatedRequest) callback(t *testing.T, token string) int {
+ t.Helper()
+ code, err := sendCallback(t.Context(), r.tn.Anonymous(t), r.record.SysID, token)
+ require.NoError(t, err)
+ return code
+}
+
+// sendCallback takes no *testing.T so it can run on another goroutine.
+func sendCallback(ctx context.Context, client *api.ClientWithResponses, sysID, token string) (int, error) {
+ body := api.HandleDelegatedApprovalCallbackJSONRequestBody{Version: api.N1, Event: api.SecretsManagementAccessRequest}
+ body.Details.ExternalId = sysID
+ res, err := client.HandleDelegatedApprovalCallbackWithResponse(ctx,
+ &api.HandleDelegatedApprovalCallbackParams{InfisicalApprovalToken: &token}, body)
+ if err != nil {
+ return 0, err
+ }
+ return res.StatusCode(), nil
+}
+
+func (r *delegatedRequest) readSecret(t *testing.T) int {
+ t.Helper()
+ res, err := r.requester.API.GetSecretByNameV4WithResponse(t.Context(), "DB_PASSWORD", &api.GetSecretByNameV4Params{
+ ProjectId: r.proj.ID,
+ Environment: new("dev"),
+ SecretPath: new("/"),
+ })
+ require.NoError(t, err)
+ return res.StatusCode()
+}
diff --git a/tests/suites/secretmanager/approvals/enforcement_test.go b/tests/suites/secretmanager/approvals/enforcement_test.go
index b9b5d155eb..4e9de022ca 100644
--- a/tests/suites/secretmanager/approvals/enforcement_test.go
+++ b/tests/suites/secretmanager/approvals/enforcement_test.go
@@ -225,7 +225,7 @@ func TestSecretApprovalRequest_MachineIdentityBypass(t *testing.T) {
// Action
review, err := identity.API.ReviewSecretApprovalRequestWithResponse(t.Context(), held.ID,
- api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.Approved})
+ api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.ReviewSecretApprovalRequestJSONBodyStatusApproved})
require.NoError(t, err)
merged, err := identity.API.MergeSecretApprovalRequestWithResponse(t.Context(), held.ID,
api.MergeSecretApprovalRequestJSONRequestBody{})
diff --git a/tests/suites/secretmanager/approvals/helpers_test.go b/tests/suites/secretmanager/approvals/helpers_test.go
index a0cc3a3506..5b148f540c 100644
--- a/tests/suites/secretmanager/approvals/helpers_test.go
+++ b/tests/suites/secretmanager/approvals/helpers_test.go
@@ -201,7 +201,7 @@ func newProtectedProject(t *testing.T, configs ...policyConfig) protectedProject
func approve(t *testing.T, reviewer *harness.Principal, id uuid.UUID) {
t.Helper()
res, err := reviewer.API.ReviewSecretApprovalRequestWithResponse(t.Context(), id,
- api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.Approved})
+ api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.ReviewSecretApprovalRequestJSONBodyStatusApproved})
require.NoError(t, err)
require.Equalf(t, http.StatusOK, res.StatusCode(), "approving %s returned %s", id, apierr.Body(res.Body))
}
diff --git a/tests/suites/secretmanager/approvals/secret_access_policy_test.go b/tests/suites/secretmanager/approvals/secret_access_policy_test.go
index 1ff618ae83..b6ff500a0e 100644
--- a/tests/suites/secretmanager/approvals/secret_access_policy_test.go
+++ b/tests/suites/secretmanager/approvals/secret_access_policy_test.go
@@ -125,7 +125,7 @@ func newDelegatedAccessPolicy(t *testing.T, proj *fixture.Project, conn *fixture
}
// requestAccess fails unless the requester's ask to read a folder is left pending.
-func requestAccess(t *testing.T, requester *harness.Principal, proj *fixture.Project, env, secretPath string) {
+func requestAccess(t *testing.T, requester *harness.Principal, proj *fixture.Project, env, secretPath string) uuid.UUID {
t.Helper()
body := jsonBody(t, map[string]any{
"permissions": []any{
@@ -138,6 +138,7 @@ func requestAccess(t *testing.T, requester *harness.Principal, proj *fixture.Pro
require.NoError(t, err)
require.NotNilf(t, res.JSON200, "requesting access returned %d: %s", res.StatusCode(), apierr.Body(res.Body))
require.Equal(t, new("pending"), res.JSON200.Approval.Status)
+ return res.JSON200.Approval.Id
}
func accessPolicyName(t *testing.T, proj *fixture.Project, policyID uuid.UUID) string {
diff --git a/tests/suites/secretmanager/approvals/secret_change_request_test.go b/tests/suites/secretmanager/approvals/secret_change_request_test.go
index 8e0ad66f8f..c162eabbc3 100644
--- a/tests/suites/secretmanager/approvals/secret_change_request_test.go
+++ b/tests/suites/secretmanager/approvals/secret_change_request_test.go
@@ -354,7 +354,7 @@ func TestSecretApprovalRequest_Review(t *testing.T) {
// Setup
p := newProtectedProject(t)
held := heldRequest(t, p.proj, createSecret(t, p.committer, p.proj, "API_KEY", "value").Body)
- require.Equal(t, http.StatusOK, reviewAs(t, p.reviewer, held.ID, api.Rejected).StatusCode())
+ require.Equal(t, http.StatusOK, reviewAs(t, p.reviewer, held.ID, api.ReviewSecretApprovalRequestJSONBodyStatusRejected).StatusCode())
// Action
res := mergeAs(t, p.committer, held.ID)
@@ -374,7 +374,7 @@ func TestSecretApprovalRequest_Review(t *testing.T) {
held := heldRequest(t, p.proj, createSecret(t, p.committer, p.proj, "API_KEY", "value").Body)
// Action
- res := reviewAs(t, bystander, held.ID, api.Approved)
+ res := reviewAs(t, bystander, held.ID, api.ReviewSecretApprovalRequestJSONBodyStatusApproved)
// Assert
require.Equal(t, http.StatusForbidden, res.StatusCode())
@@ -399,7 +399,7 @@ func TestSecretApprovalRequest_Review(t *testing.T) {
held := heldRequest(t, proj, createSecret(t, committer, proj, "API_KEY", "value").Body)
// Action
- res := reviewAs(t, committer, held.ID, api.Approved)
+ res := reviewAs(t, committer, held.ID, api.ReviewSecretApprovalRequestJSONBodyStatusApproved)
// Assert
require.Equal(t, http.StatusBadRequest, res.StatusCode())
@@ -555,7 +555,7 @@ func TestSecretApprovalRequest_Status(t *testing.T) {
// Action
review, err := p.reviewer.API.ReviewSecretApprovalRequestWithResponse(t.Context(), held.ID,
- api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.Approved})
+ api.ReviewSecretApprovalRequestJSONRequestBody{Status: api.ReviewSecretApprovalRequestJSONBodyStatusApproved})
require.NoError(t, err)
mergeClosed, err := p.committer.API.MergeSecretApprovalRequestWithResponse(t.Context(), held.ID,
api.MergeSecretApprovalRequestJSONRequestBody{})