2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2016-01-26 15:02:31 +01:00
|
|
|
|
|
|
|
#include "ask-password-api.h"
|
2018-10-24 12:34:04 +02:00
|
|
|
#include "strv.h"
|
2020-02-06 09:32:16 +01:00
|
|
|
#include "tests.h"
|
2016-01-26 15:02:31 +01:00
|
|
|
|
2020-02-06 09:32:16 +01:00
|
|
|
static void test_ask_password(void) {
|
2016-01-26 15:02:31 +01:00
|
|
|
int r;
|
2018-10-24 12:34:04 +02:00
|
|
|
_cleanup_strv_free_ char **ret = NULL;
|
2016-01-26 15:02:31 +01:00
|
|
|
|
2020-02-06 09:50:35 +01:00
|
|
|
r = ask_password_tty(-1, "hello?", "da key", 0, ASK_PASSWORD_CONSOLE_COLOR, NULL, &ret);
|
2020-02-06 09:32:16 +01:00
|
|
|
if (r == -ECANCELED)
|
|
|
|
assert_se(ret == NULL);
|
|
|
|
else {
|
|
|
|
assert_se(r >= 0);
|
|
|
|
assert_se(strv_length(ret) == 1);
|
|
|
|
log_info("Got \"%s\"", *ret);
|
|
|
|
}
|
2016-01-26 15:02:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2020-02-06 09:32:16 +01:00
|
|
|
test_setup_logging(LOG_DEBUG);
|
2016-01-26 15:02:31 +01:00
|
|
|
|
2020-02-06 09:32:16 +01:00
|
|
|
test_ask_password();
|
2019-05-24 21:09:07 +02:00
|
|
|
return EXIT_SUCCESS;
|
2016-01-26 15:02:31 +01:00
|
|
|
}
|