Wizard: Add users to on-prem mapper

this adds users to on-prem mapper.
This commit is contained in:
Michal Gold 2025-02-03 12:44:59 +02:00 committed by Klara Simickova
parent 2c414fb089
commit 3cd3aa0176
2 changed files with 26 additions and 0 deletions

View file

@ -82,6 +82,8 @@ export type CustomizationsOnPrem = {
export type UserOnPrem = {
name: string;
key: string;
password: string;
groups: string[];
};
export type GroupOnPrem = {
@ -100,6 +102,8 @@ export const mapOnPremToHosted = (
const users = blueprint.customizations?.user?.map((u) => ({
name: u.name,
ssh_key: u.key,
groups: u.groups,
isAdministrator: u.groups?.includes('wheel') || false,
}));
const user_keys = blueprint.customizations?.ssh_key?.map((k) => ({
name: k.user,
@ -228,6 +232,9 @@ export const mapHostedToOnPrem = (
return {
name: u.name,
key: u.ssh_key || '',
groups: u.groups || [],
password: '',
isAdministrator: u.groups?.includes('wheel') || false,
};
});
}

View file

@ -147,6 +147,12 @@ fips = true
user = "root"
key = "PUBLIC SSH KEY"
[[customizations.user]]
name = "admin"
password = "$6$CHO2$3rN8eviE2t50lmVyBYihTgVRHcaecmeCk31L..."
key = "ssh-rsa d"
groups = ["widget", "users", "wheel"]
[customizations.services]
enabled = ["sshd", "cockpit.socket", "httpd"]
disabled = ["postfix", "telnetd"]
@ -363,6 +369,19 @@ describe('Import modal', () => {
// Users
await clickNext();
await screen.findByRole('heading', { name: /Users/ });
const userName = screen.getByRole('textbox', {
name: /blueprint user name/i,
});
expect(userName).toHaveValue('admin');
const sshKey = await screen.findByRole('textbox', {
name: /public SSH key/i,
});
expect(sshKey).toHaveValue('ssh-rsa d');
const adminCheckBox = screen.getByRole('checkbox', {
name: /administrator/i,
});
expect(adminCheckBox).toBeChecked();
// Timezone
await clickNext();