]>
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 = { | |
12 | .message = "hello?", | |
13 | .keyring = "da key", | |
14 | }; | |
8a1baa3a | 15 | |
d08fd4c3 | 16 | r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ ASK_PASSWORD_CONSOLE_COLOR, /* flag_file= */ NULL, &ret); |
72c08a47 | 17 | if (r == -ECANCELED) |
f9d273e6 | 18 | ASSERT_NULL(ret); |
72c08a47 | 19 | else { |
f9d273e6 | 20 | ASSERT_OK(r); |
72c08a47 ZJS |
21 | assert_se(strv_length(ret) == 1); |
22 | log_info("Got \"%s\"", *ret); | |
23 | } | |
8a1baa3a ZJS |
24 | } |
25 | ||
4f7452a8 | 26 | DEFINE_TEST_MAIN(LOG_DEBUG); |