diff --git a/src/components/review/ReviewConfiguration.jsx b/src/components/review/ReviewConfiguration.jsx
index a597759717..78cbb7d95a 100644
--- a/src/components/review/ReviewConfiguration.jsx
+++ b/src/components/review/ReviewConfiguration.jsx
@@ -144,7 +144,7 @@ export const ReviewConfiguration = ({ deviceData, diskSelection, language, local
{_("Account")}
- {accounts.fullName ? `${accounts.fullName} (${accounts.userAccount})` : accounts.userAccount}
+ {accounts.fullName ? `${accounts.fullName} (${accounts.userName})` : accounts.userName}
diff --git a/src/components/users/Accounts.jsx b/src/components/users/Accounts.jsx
index 4602efa83d..d40346dfc5 100644
--- a/src/components/users/Accounts.jsx
+++ b/src/components/users/Accounts.jsx
@@ -38,13 +38,13 @@ const _ = cockpit.gettext;
export function getAccountsState (
fullName = "",
- userAccount = "",
+ userName = "",
password = "",
confirmPassword = "",
) {
return {
fullName,
- userAccount,
+ userName,
password,
confirmPassword,
};
@@ -52,7 +52,7 @@ export function getAccountsState (
export const accountsToDbusUsers = (accounts) => {
return [{
- name: cockpit.variant("s", accounts.userAccount || ""),
+ name: cockpit.variant("s", accounts.userName || ""),
gecos: cockpit.variant("s", accounts.fullName || ""),
password: cockpit.variant("s", accounts.password || ""),
"is-crypted": cockpit.variant("b", false),
@@ -78,12 +78,12 @@ const reservedNames = [
"system",
];
-const isUserAccountWithInvalidCharacters = (userAccount) => {
+const isUserNameWithInvalidCharacters = (userName) => {
return (
- userAccount === "." ||
- userAccount === ".." ||
- userAccount.match(/^[0-9]+$/) ||
- !userAccount.match(/^[A-Za-z0-9._][A-Za-z0-9._-]{0,30}([A-Za-z0-9._-]|\$)?$/)
+ userName === "." ||
+ userName === ".." ||
+ userName.match(/^[0-9]+$/) ||
+ !userName.match(/^[A-Za-z0-9._][A-Za-z0-9._-]{0,30}([A-Za-z0-9._-]|\$)?$/)
);
};
@@ -95,39 +95,39 @@ const CreateAccount = ({
setAccounts,
}) => {
const [fullName, setFullName] = useState(accounts.fullName);
- const [_userAccount, _setUserAccount] = useState(accounts.userAccount);
- const [userAccount, setUserAccount] = useState(accounts.userAccount);
- const [userAccountInvalidHint, setUserAccountInvalidHint] = useState("");
- const [isUserAccountValid, setIsUserAccountValid] = useState(null);
+ const [_userName, _setUserName] = useState(accounts.userName);
+ const [userName, setUserName] = useState(accounts.userName);
+ const [userNameInvalidHint, setUserNameInvalidHint] = useState("");
+ const [isUserNameValid, setIsUserNameValid] = useState(null);
const [password, setPassword] = useState(accounts.password);
const [confirmPassword, setConfirmPassword] = useState(accounts.confirmPassword);
const [isPasswordValid, setIsPasswordValid] = useState(false);
useEffect(() => {
- debounce(300, () => setUserAccount(_userAccount))();
- }, [_userAccount, setUserAccount]);
+ debounce(300, () => setUserName(_userName))();
+ }, [_userName, setUserName]);
useEffect(() => {
- setIsUserValid(isPasswordValid && isUserAccountValid);
- }, [setIsUserValid, isPasswordValid, isUserAccountValid]);
+ setIsUserValid(isPasswordValid && isUserNameValid);
+ }, [setIsUserValid, isPasswordValid, isUserNameValid]);
useEffect(() => {
let valid = true;
- setUserAccountInvalidHint("");
- if (userAccount.length === 0) {
+ setUserNameInvalidHint("");
+ if (userName.length === 0) {
valid = null;
- } else if (userAccount.length > 32) {
+ } else if (userName.length > 32) {
valid = false;
- setUserAccountInvalidHint(_("User names must be shorter than 33 characters"));
- } else if (reservedNames.includes(userAccount)) {
+ setUserNameInvalidHint(_("User names must be shorter than 33 characters"));
+ } else if (reservedNames.includes(userName)) {
valid = false;
- setUserAccountInvalidHint(_("User name must not be a reserved word"));
- } else if (isUserAccountWithInvalidCharacters(userAccount)) {
+ setUserNameInvalidHint(_("User name must not be a reserved word"));
+ } else if (isUserNameWithInvalidCharacters(userName)) {
valid = false;
- setUserAccountInvalidHint(cockpit.format(_("User name may only contain: letters from a-z, digits 0-9, dash $0, period $1, underscore $2"), "-", ".", "_"));
+ setUserNameInvalidHint(cockpit.format(_("User name may only contain: letters from a-z, digits 0-9, dash $0, period $1, underscore $2"), "-", ".", "_"));
}
- setIsUserAccountValid(valid);
- }, [userAccount]);
+ setIsUserNameValid(valid);
+ }, [userName]);
const passphraseForm = (
{
- setAccounts(ac => ({ ...ac, fullName, userAccount, password, confirmPassword }));
- }, [setAccounts, fullName, userAccount, password, confirmPassword]);
+ setAccounts(ac => ({ ...ac, fullName, userName, password, confirmPassword }));
+ }, [setAccounts, fullName, userName, password, confirmPassword]);
- const userAccountValidated = isUserAccountValid === null ? "default" : isUserAccountValid ? "success" : "error";
+ const userNameValidated = isUserNameValid === null ? "default" : isUserNameValid ? "success" : "error";
return (
-
+
_setUserAccount(val)}
- validated={userAccountValidated}
+ id={idPrefix + "-user-name"}
+ value={_userName}
+ onChange={(_event, val) => _setUserName(val)}
+ validated={userNameValidated}
/>
- {userAccountValidated === "error" &&
+ {userNameValidated === "error" &&
-
- {userAccountInvalidHint}
+
+ {userNameInvalidHint}
}
diff --git a/src/components/users/Accounts.scss b/src/components/users/Accounts.scss
index 30e160f029..ad27a615ce 100644
--- a/src/components/users/Accounts.scss
+++ b/src/components/users/Accounts.scss
@@ -9,6 +9,6 @@
align-items: flex-start;
}
-#accounts-create-account-user-account-input-group {
+#accounts-create-account-user-name-input-group {
width: min(39ch, 100%);
}
diff --git a/test/check-users b/test/check-users
index 2cf9d7fca4..87fad8729d 100755
--- a/test/check-users
+++ b/test/check-users
@@ -52,7 +52,7 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
self.assertIn('"password" s "password"', users)
@staticmethod
- def _test_user_account(user, installer, valid, invalid):
+ def _test_user_name(user, installer, valid, invalid):
installer.check_next_disabled(disabled=False)
n_valid = len(valid) - 1
@@ -62,9 +62,9 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
for i in range(max(n_valid, n_invalid)):
i_valid = min(i, n_valid)
i_invalid = min(i, n_invalid)
- user.set_user_account(invalid[i_invalid])
+ user.set_user_name(invalid[i_invalid])
installer.check_next_disabled()
- user.set_user_account(valid[i_valid])
+ user.set_user_name(valid[i_valid])
installer.check_next_disabled(disabled=False)
def testAccessAndValidation(self):
@@ -82,17 +82,17 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
# Fill in valid values
password = "password"
full_name = "Full Tester"
- user_account = "tester"
+ user_name = "tester"
p.set_password(password)
p.set_password_confirm(password)
u.set_full_name(full_name)
- u.set_user_account(user_account)
+ u.set_user_name(user_name)
p.check_password(password)
p.check_password_confirm(password)
u.check_full_name(full_name)
- u.check_user_account(user_account)
+ u.check_user_name(user_name)
i.check_next_disabled(disabled=False)
# Test that you can move forward and going back keeps values
@@ -101,7 +101,7 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
p.check_password(password)
p.check_password_confirm(password)
u.check_full_name(full_name)
- u.check_user_account(user_account)
+ u.check_user_name(user_name)
# Test that moving back and forward keeps values
i.back()
@@ -109,7 +109,7 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
p.check_password(password)
p.check_password_confirm(password)
u.check_full_name(full_name)
- u.check_user_account(user_account)
+ u.check_user_name(user_name)
# Test full name validation
u.set_full_name("")
@@ -118,7 +118,7 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
# Test account validation
# FIXME this should be tested by unit tests?
- invalid_user_accounts = [
+ invalid_user_names = [
"",
# reserved
"root", "system", "daemon", "home",
@@ -132,7 +132,7 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
"tester?",
"longer_than_32_characteeeeeeeeeeeeeeeeeeers",
]
- valid_user_accounts = [
+ valid_user_names = [
"tester-",
"...",
"12.3",
@@ -145,8 +145,8 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
".tester",
"_",
]
- self._test_user_account(u, i, valid_user_accounts, invalid_user_accounts)
- u.set_user_account(user_account)
+ self._test_user_name(u, i, valid_user_names, invalid_user_names)
+ u.set_user_name(user_name)
# Test password validation
# No password set
@@ -185,10 +185,10 @@ class TestUsers(anacondalib.VirtInstallMachineCase):
p.set_password(password)
p.set_password_confirm(password)
u.set_full_name(full_name)
- u.set_user_account(user_account)
+ u.set_user_name(user_name)
r = Review(b)
i.reach(i.steps.REVIEW)
- r.check_account(f"{full_name} ({user_account})")
+ r.check_account(f"{full_name} ({user_name})")
if __name__ == '__main__':
diff --git a/test/helpers/users.py b/test/helpers/users.py
index abd21ac662..b2af000ce3 100644
--- a/test/helpers/users.py
+++ b/test/helpers/users.py
@@ -61,14 +61,14 @@ def __init__(self, browser, machine):
UsersDBus.__init__(self, machine)
@log_step(snapshot_before=True)
- def set_user_account(self, user_account, append=False, value_check=True):
- sel = "#accounts-create-account-user-account"
- self.browser.set_input_text(sel, user_account, append=append, value_check=value_check)
+ def set_user_name(self, user_name, append=False, value_check=True):
+ sel = "#accounts-create-account-user-name"
+ self.browser.set_input_text(sel, user_name, append=append, value_check=value_check)
@log_step(snapshot_before=True)
- def check_user_account(self, user_account):
- sel = "#accounts-create-account-user-account"
- self.browser.wait_val(sel, user_account)
+ def check_user_name(self, user_name):
+ sel = "#accounts-create-account-user-name"
+ self.browser.wait_val(sel, user_name)
@log_step(snapshot_before=True)
def set_full_name(self, full_name, append=False, value_check=True):
@@ -88,7 +88,7 @@ def create_user(browser, machine):
password = "password"
p.set_password(password)
p.set_password_confirm(password)
- u.set_user_account("tester")
+ u.set_user_name("tester")
def dbus_reset_users(machine):