8aaf18e08a
For #8495: it is arguably useful to not show the length of the password in public spaces. It is possible to press TAB or BS to cancel the asterisks, but this is not very discoverable. Let's make it discoverable by showing a message (in gray). The message is "erased" after the first character is entered.
27 lines
670 B
C
27 lines
670 B
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#include "ask-password-api.h"
|
|
#include "strv.h"
|
|
#include "tests.h"
|
|
|
|
static void test_ask_password(void) {
|
|
int r;
|
|
_cleanup_strv_free_ char **ret = NULL;
|
|
|
|
r = ask_password_tty(-1, "hello?", "da key", 0, ASK_PASSWORD_CONSOLE_COLOR, NULL, &ret);
|
|
if (r == -ECANCELED)
|
|
assert_se(ret == NULL);
|
|
else {
|
|
assert_se(r >= 0);
|
|
assert_se(strv_length(ret) == 1);
|
|
log_info("Got \"%s\"", *ret);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
test_setup_logging(LOG_DEBUG);
|
|
|
|
test_ask_password();
|
|
return EXIT_SUCCESS;
|
|
}
|