diff --git a/backend/src/mock-third-party-api-calls.ts b/backend/src/mock-third-party-api-calls.ts index 521fc77bb..97805f3f4 100644 --- a/backend/src/mock-third-party-api-calls.ts +++ b/backend/src/mock-third-party-api-calls.ts @@ -1,11 +1,15 @@ import nock from "nock"; -export const mockThirdPartyApiCalls = () => { +const CLOUDFLARE_ACCOUNT_ID = "A2A6347F-88B5-442D-9798-95E408BC7701"; + +// We mock the Cloudflare account API calls to let adding app connection much easier in BDD tests. +// It's mainly for the DNS provider validation in ACME challenge validation. +const mockCloudflare = () => { nock("https://api.cloudflare.com:443") .get("/client/v4/accounts/MOCK_ACCOUNT_ID") .reply(200, { result: { - id: "A2A6347F-88B5-442D-9798-95E408BC7701", + id: CLOUDFLARE_ACCOUNT_ID, name: "Mock Account", type: "standard", settings: { @@ -53,7 +57,7 @@ export const mockThirdPartyApiCalls = () => { }, owner: { id: null, type: "user", email: null }, account: { - id: "A2A6347F-88B5-442D-9798-95E408BC7701", + id: CLOUDFLARE_ACCOUNT_ID, name: "Mock Account" }, tenant: { id: null, name: null }, @@ -85,3 +89,7 @@ export const mockThirdPartyApiCalls = () => { messages: [] }); }; + +export const mockThirdPartyApiCalls = () => { + mockCloudflare(); +};