mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-04 02:04:06 +00:00
Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { getRegistryPresentation } from "./presentation";
|
|
|
|
describe("Registry presentation configuration", () => {
|
|
const urlWithCredentials = new URL("https://registry.test");
|
|
urlWithCredentials.username = "user";
|
|
urlWithCredentials.password = "pass";
|
|
|
|
it("uses the configured Registry and media origins", () => {
|
|
expect(
|
|
getRegistryPresentation(
|
|
"https://registry.private.test/keys",
|
|
"https://assets.private.test/media/",
|
|
),
|
|
).toEqual({
|
|
keyUrl: "https://registry.private.test/keys",
|
|
imageOrigins: [
|
|
"https://registry.private.test",
|
|
"https://assets.private.test",
|
|
],
|
|
});
|
|
});
|
|
|
|
it("does not guess a Registry environment when configuration is missing", () => {
|
|
expect(getRegistryPresentation()).toEqual({
|
|
keyUrl: undefined,
|
|
imageOrigins: [],
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
"javascript:alert(1)",
|
|
urlWithCredentials.href,
|
|
"https://registry.test; img-src *",
|
|
"invalid",
|
|
])("rejects unsafe configuration: %s", (value) => {
|
|
expect(getRegistryPresentation(value, value)).toEqual({
|
|
keyUrl: undefined,
|
|
imageOrigins: [],
|
|
});
|
|
});
|
|
});
|