Files
openclaw/test/helpers/plugins/web-fetch-provider-contract.ts
Vincent Koc 6eca1949d5 refactor(plugins): tighten web fetch provider boundary (#59646)
* refactor(plugins): tighten web fetch provider boundary

* fix(config): sync fetch secret parity and baseline

* fix(ci): enforce web fetch boundary guard
2026-04-02 20:53:57 +09:00

47 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
pluginRegistrationContractRegistry,
resolveWebFetchProviderContractEntriesForPluginId,
} from "../../../src/plugins/contracts/registry.js";
import { installWebFetchProviderContractSuite } from "../../../src/plugins/contracts/suites.js";
export function describeWebFetchProviderContracts(pluginId: string) {
const providerIds =
pluginRegistrationContractRegistry.find((entry) => entry.pluginId === pluginId)
?.webFetchProviderIds ?? [];
const resolveProviders = () => resolveWebFetchProviderContractEntriesForPluginId(pluginId);
describe(`${pluginId} web fetch provider contract registry load`, () => {
it("loads bundled web fetch providers", () => {
expect(resolveProviders().length).toBeGreaterThan(0);
});
});
for (const providerId of providerIds) {
describe(`${pluginId}:${providerId} web fetch contract`, () => {
installWebFetchProviderContractSuite({
provider: () => {
const entry = resolveProviders().find((provider) => provider.provider.id === providerId);
if (!entry) {
throw new Error(
`web fetch provider contract entry missing for ${pluginId}:${providerId}`,
);
}
return entry.provider;
},
credentialValue: () => {
const entry = resolveProviders().find((provider) => provider.provider.id === providerId);
if (!entry) {
throw new Error(
`web fetch provider contract entry missing for ${pluginId}:${providerId}`,
);
}
return entry.credentialValue;
},
pluginId,
});
});
}
}