]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
8a1baa3a | 2 | |
8a1baa3a | 3 | #include "ask-password-api.h" |
c7b7d74e | 4 | #include "strv.h" |
72c08a47 | 5 | #include "tests.h" |
8a1baa3a | 6 | |
4f7452a8 | 7 | TEST(ask_password) { |
c7b7d74e | 8 | _cleanup_strv_free_ char **ret = NULL; |
d08fd4c3 LP |
9 | int r; |
10 | ||
11 | static const AskPasswordRequest req = { | |
72068d9d | 12 | .tty_fd = -EBADF, |
d08fd4c3 LP |
13 | .message = "hello?", |
14 | .keyring = "da key", | |
c4a02a52 | 15 | .until = USEC_INFINITY, |
d66894a7 | 16 | .hup_fd = -EBADF, |
d08fd4c3 | 17 | }; |
8a1baa3a | 18 | |
c4a02a52 | 19 | r = ask_password_tty(&req, /* flags= */ ASK_PASSWORD_CONSOLE_COLOR, &ret); |
72c08a47 | 20 | if (r == -ECANCELED) |
f9d273e6 | 21 | ASSERT_NULL(ret); |
72c08a47 | 22 | else { |
f9d273e6 | 23 | ASSERT_OK(r); |
72c08a47 ZJS |
24 | assert_se(strv_length(ret) == 1); |
25 | log_info("Got \"%s\"", *ret); | |
26 | } | |
8a1baa3a ZJS |
27 | } |
28 | ||
4f7452a8 | 29 | DEFINE_TEST_MAIN(LOG_DEBUG); |