more mock

This commit is contained in:
Fang-Pen Lin
2025-11-13 09:21:54 -08:00
parent 1a18096ac8
commit 873deff71b
+11 -3
View File
@@ -1,11 +1,15 @@
import nock from "nock"; 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") nock("https://api.cloudflare.com:443")
.get("/client/v4/accounts/MOCK_ACCOUNT_ID") .get("/client/v4/accounts/MOCK_ACCOUNT_ID")
.reply(200, { .reply(200, {
result: { result: {
id: "A2A6347F-88B5-442D-9798-95E408BC7701", id: CLOUDFLARE_ACCOUNT_ID,
name: "Mock Account", name: "Mock Account",
type: "standard", type: "standard",
settings: { settings: {
@@ -53,7 +57,7 @@ export const mockThirdPartyApiCalls = () => {
}, },
owner: { id: null, type: "user", email: null }, owner: { id: null, type: "user", email: null },
account: { account: {
id: "A2A6347F-88B5-442D-9798-95E408BC7701", id: CLOUDFLARE_ACCOUNT_ID,
name: "Mock Account" name: "Mock Account"
}, },
tenant: { id: null, name: null }, tenant: { id: null, name: null },
@@ -85,3 +89,7 @@ export const mockThirdPartyApiCalls = () => {
messages: [] messages: []
}); });
}; };
export const mockThirdPartyApiCalls = () => {
mockCloudflare();
};