mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-30 23:34:27 +00:00
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { adaptRegionsOverviewToThreatMap } from "./threat-map.adapter";
|
|
import type { RegionsOverviewResponse } from "./types";
|
|
|
|
function buildRegionsResponse(
|
|
rows: Array<{ providerType: string; region: string }>,
|
|
): RegionsOverviewResponse {
|
|
return {
|
|
data: rows.map(({ providerType, region }, index) => ({
|
|
type: "regions-overview",
|
|
id: `region-${index}`,
|
|
attributes: {
|
|
provider_type: providerType,
|
|
region,
|
|
total: 10,
|
|
fail: 4,
|
|
muted: 0,
|
|
pass: 6,
|
|
},
|
|
})),
|
|
meta: { version: "v1" },
|
|
};
|
|
}
|
|
|
|
describe("adaptRegionsOverviewToThreatMap", () => {
|
|
it("maps okta regions to a global location", () => {
|
|
const response = buildRegionsResponse([
|
|
{ providerType: "okta", region: "global" },
|
|
]);
|
|
|
|
const result = adaptRegionsOverviewToThreatMap(response);
|
|
|
|
expect(result.locations).toHaveLength(1);
|
|
expect(result.locations[0]).toMatchObject({
|
|
providerType: "okta",
|
|
region: "global",
|
|
name: "Okta - Global",
|
|
totalFindings: 10,
|
|
failFindings: 4,
|
|
});
|
|
expect(result.regions).toEqual(["global"]);
|
|
});
|
|
|
|
it("maps googleworkspace regions to a global location", () => {
|
|
const response = buildRegionsResponse([
|
|
{ providerType: "googleworkspace", region: "global" },
|
|
]);
|
|
|
|
const result = adaptRegionsOverviewToThreatMap(response);
|
|
|
|
expect(result.locations).toHaveLength(1);
|
|
expect(result.locations[0]).toMatchObject({
|
|
providerType: "googleworkspace",
|
|
region: "global",
|
|
name: "Google Workspace - Global",
|
|
totalFindings: 10,
|
|
failFindings: 4,
|
|
});
|
|
expect(result.regions).toEqual(["global"]);
|
|
});
|
|
});
|