diff --git a/web/src/assets/styles/app.scss b/web/src/assets/styles/app.scss index 334c79d8ea..c1ca3baa64 100644 --- a/web/src/assets/styles/app.scss +++ b/web/src/assets/styles/app.scss @@ -97,9 +97,3 @@ button.remove-link:hover { --pf-v5-c-notification-drawer__list-item--before--BackgroundColor: none; } } - -form#rootAuthMethods { - .pf-v5-c-file-upload__file-select { - display: none; - } -} diff --git a/web/src/components/users/RootAuthMethodsPage.test.tsx b/web/src/components/users/RootAuthMethodsPage.test.tsx index 649e4cfd36..2d9694989e 100644 --- a/web/src/components/users/RootAuthMethodsPage.test.tsx +++ b/web/src/components/users/RootAuthMethodsPage.test.tsx @@ -33,17 +33,12 @@ jest.mock("~/queries/users", () => ({ })); describe("RootAuthMethodsPage", () => { - it("allows setting a root authentication method", async () => { + it("allows setting a root password", async () => { const { user } = installerRender(); - const passwordInput = screen.getByLabelText("Password"); - const sshKeyTextarea = screen.getByLabelText("SSH public key"); + const passwordInput = screen.getByLabelText("Password for root user"); const acceptButton = screen.getByRole("button", { name: "Accept" }); - // There must be an upload button too (behavior not covered here); - screen.getByRole("button", { name: "upload" }); - - // The Accept button must be enable only when at least one authentication - // method is defined + // The Accept button must be enable only when password has some value expect(acceptButton).toHaveAttribute("disabled"); await user.type(passwordInput, "s3cr3t"); @@ -52,32 +47,9 @@ describe("RootAuthMethodsPage", () => { await user.clear(passwordInput); expect(acceptButton).toHaveAttribute("disabled"); - await user.type(sshKeyTextarea, "FAKE SSH KEY"); - expect(acceptButton).not.toHaveAttribute("disabled"); - - await user.clear(sshKeyTextarea); - expect(acceptButton).toHaveAttribute("disabled"); - - await user.type(passwordInput, "s3cr3t"); - await user.type(sshKeyTextarea, "FAKE SSH KEY"); - expect(acceptButton).not.toHaveAttribute("disabled"); - - // Request setting defined root method when Accept button is clicked - await user.click(acceptButton); - expect(mockRootUserMutation.mutateAsync).toHaveBeenCalledWith({ - password: "s3cr3t", - encryptedPassword: false, - sshkey: "FAKE SSH KEY", - }); - - await user.clear(passwordInput); - await user.click(acceptButton); - expect(mockRootUserMutation.mutateAsync).toHaveBeenCalledWith({ - sshkey: "FAKE SSH KEY", - }); - - await user.clear(sshKeyTextarea); await user.type(passwordInput, "t0ps3cr3t"); + + // Request setting root password when Accept button is clicked await user.click(acceptButton); expect(mockRootUserMutation.mutateAsync).toHaveBeenCalledWith({ password: "t0ps3cr3t", diff --git a/web/src/components/users/RootAuthMethodsPage.tsx b/web/src/components/users/RootAuthMethodsPage.tsx index 4449502c44..f4a826a896 100644 --- a/web/src/components/users/RootAuthMethodsPage.tsx +++ b/web/src/components/users/RootAuthMethodsPage.tsx @@ -21,21 +21,11 @@ */ import React, { useRef, useState } from "react"; -import { - Button, - FileUpload, - Flex, - Form, - FormGroup, - FormHelperText, - HelperText, - HelperTextItem, -} from "@patternfly/react-core"; +import { Flex, Form, FormGroup } from "@patternfly/react-core"; import { useLocation, useNavigate } from "react-router-dom"; import { Center } from "~/components/layout"; import { Page, PasswordInput } from "~/components/core"; import { useRootUserMutation } from "~/queries/users"; -import { RootUserChanges } from "~/types/users"; import { ROOT as PATHS } from "~/routes/paths"; import { isEmpty } from "~/utils"; import { _ } from "~/i18n"; @@ -55,45 +45,18 @@ function RootAuthMethodsPage() { const location = useLocation(); const setRootUser = useRootUserMutation(); const [password, setPassword] = useState(""); - const [sshKey, setSSHKey] = useState(""); - const [isUploading, setIsUploading] = useState(false); - const startUploading = () => setIsUploading(true); - const stopUploading = () => setIsUploading(false); - const clearKey = () => setSSHKey(""); - - const isFormValid = !isEmpty(password) || !isEmpty(sshKey); - const uploadFile = () => document.getElementById("sshKey-browse-button").click(); + const isFormValid = !isEmpty(password); const accept = async (e: React.SyntheticEvent) => { e.preventDefault(); + if (isEmpty(password)) return; - const data: Partial = {}; - - if (!isEmpty(password)) { - data.password = password; - data.encryptedPassword = false; - } - - if (!isEmpty(sshKey)) { - data.sshkey = sshKey; - } - - if (isEmpty(data)) return; - - await setRootUser.mutateAsync(data); + await setRootUser.mutateAsync({ password, encryptedPassword: false }); navigate(location.state?.from || PATHS.root, { replace: true }); }; - // TRANSLATORS: %s will be replaced by a link with the text "upload". - const [sshKeyStartHelperText, sshKeyEndHelperText] = _( - "Write, paste, drop, or %s a SSH public key file in the above textarea.", - ).split("%s"); - // TRANSLATORS: this "upload" is a commanding verb, in the %s place of - // "Write, paste, drop, or %s a SSH public key file in the above textarea." - const uploadLinkText = _("upload"); - return ( @@ -102,58 +65,30 @@ function RootAuthMethodsPage() { headerLevel="h2" title={_("Setup root user authentication")} description={ -

- {_( - "You must define at least one authentication method for the root user. You can still edit them anytime before the installation.", - )} -

+ +

+ {_("Provide a password to ensure administrative access to the system.")} +

+

+ {_( + "You can change it or select another authentication method in the 'Users' section before installing.", + )} +

+
} pfCardProps={{ isCompact: false }} pfCardBodyProps={{ isFilled: true }} >
- - - setPassword(value)} - /> - - - setSSHKey(value)} - onTextChange={(_, value) => setSSHKey(value)} - onReadStarted={startUploading} - onReadFinished={stopUploading} - onClearClick={clearKey} - /> - - - - {sshKeyStartHelperText} - - {sshKeyEndHelperText} - - - - - + + setPassword(value)} + /> +