mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-08 12:24:45 +00:00
feat(ui): complete Registry provider onboarding for Private Cloud (#12494)
Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
This commit is contained in:
1 parent
974f4251dd
commit
2198ba2d84
144 files changed
+16218
-311
No files matched your search
@@ -68,6 +68,11 @@ vi.mock("@/lib", () => ({
|
||||
description:
|
||||
"Allows configuring Lighthouse AI, including its provider credentials, default model and business context",
|
||||
},
|
||||
{
|
||||
field: "manage_registry",
|
||||
label: "Manage Registry",
|
||||
description: "Allows managing tenant Registry credentials and artifacts",
|
||||
},
|
||||
{
|
||||
field: "manage_billing",
|
||||
label: "Manage Billing",
|
||||
@@ -147,9 +152,25 @@ describe("AddRoleForm", () => {
|
||||
// Then
|
||||
expect(screen.queryByText("Manage Alerts")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Manage Lighthouse AI")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Manage Registry")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Manage Billing")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("submits manage_registry when granted in Prowler Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
render(<AddRoleForm groups={[]} />);
|
||||
|
||||
// When
|
||||
await user.type(screen.getByPlaceholderText("Enter role name"), "New role");
|
||||
await user.click(screen.getByRole("checkbox", { name: "Manage Registry" }));
|
||||
await user.click(screen.getByRole("button", { name: "Add Role" }));
|
||||
|
||||
// Then
|
||||
expect(submittedFormData().get("manage_registry")).toBe("true");
|
||||
});
|
||||
|
||||
it("submits manage_lighthouse_ai_configuration when granted in Prowler Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
@@ -193,6 +214,7 @@ describe("AddRoleForm", () => {
|
||||
expect(submittedFormData().has("manage_lighthouse_ai_configuration")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(submittedFormData().has("manage_registry")).toBe(false);
|
||||
});
|
||||
|
||||
it("navigates back to roles when cancel is clicked", async () => {
|
||||
|
||||
@@ -28,6 +28,7 @@ export const AddRoleForm = ({ groups }: { groups: RoleGroupOption[] }) => {
|
||||
manage_billing: false,
|
||||
manage_alerts: false,
|
||||
manage_lighthouse_ai_configuration: false,
|
||||
manage_registry: false,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -56,6 +57,7 @@ export const AddRoleForm = ({ groups }: { groups: RoleGroupOption[] }) => {
|
||||
"manage_lighthouse_ai_configuration",
|
||||
String(values.manage_lighthouse_ai_configuration),
|
||||
);
|
||||
formData.append("manage_registry", String(values.manage_registry));
|
||||
}
|
||||
|
||||
if (values.groups && values.groups.length > 0) {
|
||||
|
||||
@@ -68,6 +68,11 @@ vi.mock("@/lib", () => ({
|
||||
description:
|
||||
"Allows configuring Lighthouse AI, including its provider credentials, default model and business context",
|
||||
},
|
||||
{
|
||||
field: "manage_registry",
|
||||
label: "Manage Registry",
|
||||
description: "Allows managing tenant Registry credentials and artifacts",
|
||||
},
|
||||
{
|
||||
field: "manage_billing",
|
||||
label: "Manage Billing",
|
||||
@@ -97,9 +102,11 @@ beforeAll(() => {
|
||||
|
||||
const roleData = ({
|
||||
manageProviders = false,
|
||||
manageRegistry = false,
|
||||
unlimitedVisibility = false,
|
||||
}: {
|
||||
manageProviders?: boolean;
|
||||
manageRegistry?: boolean;
|
||||
unlimitedVisibility?: boolean;
|
||||
} = {}) => ({
|
||||
data: {
|
||||
@@ -109,6 +116,7 @@ const roleData = ({
|
||||
manage_account: false,
|
||||
manage_providers: manageProviders,
|
||||
manage_integrations: false,
|
||||
manage_registry: manageRegistry,
|
||||
manage_scans: false,
|
||||
unlimited_visibility: unlimitedVisibility,
|
||||
groups: [],
|
||||
@@ -139,6 +147,19 @@ describe("EditRoleForm", () => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("retains manage_registry when updating a role in Prowler Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
renderEditRoleForm({ manageRegistry: true });
|
||||
|
||||
// When
|
||||
await user.click(screen.getByRole("button", { name: "Update Role" }));
|
||||
|
||||
// Then
|
||||
expect(submittedFormData().get("manage_registry")).toBe("true");
|
||||
});
|
||||
|
||||
it("submits manage_lighthouse_ai_configuration when granted in Prowler Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
@@ -186,6 +207,7 @@ describe("EditRoleForm", () => {
|
||||
expect(submittedFormData().has("manage_lighthouse_ai_configuration")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(submittedFormData().has("manage_registry")).toBe(false);
|
||||
});
|
||||
|
||||
it("shows the subtle Unlimited Visibility description inside Visibility", () => {
|
||||
|
||||
@@ -35,6 +35,9 @@ export const EditRoleForm = ({
|
||||
|
||||
const defaultValues: DefaultValues<RoleFormValues> = {
|
||||
...roleData.data.attributes,
|
||||
...(isCloudEnvironment && {
|
||||
manage_registry: roleData.data.attributes.manage_registry ?? false,
|
||||
}),
|
||||
groups:
|
||||
roleData.data.relationships?.provider_groups?.data.map((g) => g.id) || [],
|
||||
};
|
||||
@@ -62,6 +65,7 @@ export const EditRoleForm = ({
|
||||
updatedFields.manage_alerts = values.manage_alerts;
|
||||
updatedFields.manage_lighthouse_ai_configuration =
|
||||
values.manage_lighthouse_ai_configuration;
|
||||
updatedFields.manage_registry = values.manage_registry;
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user