diff options
author | Sumit Bose <sbose@redhat.com> | 2015-03-24 15:35:01 +0100 |
---|---|---|
committer | Sumit Bose <sbose@redhat.com> | 2015-05-08 09:14:15 +0200 |
commit | 55b7fdd837a780ab0f71cbfaa2403f4626993922 (patch) | |
tree | 292be2e43b783569cbe956b6bc564111473d0035 /src/tests | |
parent | 932c3e22e3c59a9c33f30dcc09e6bef257e14320 (diff) | |
download | sssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.tar.gz sssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.tar.xz sssd-55b7fdd837a780ab0f71cbfaa2403f4626993922.zip |
sysdb: add sysdb_cache_password_ex()
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/sysdb-tests.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 1623ae9f3..82bb97151 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -1809,6 +1809,57 @@ START_TEST (test_sysdb_cache_password) } END_TEST +START_TEST (test_sysdb_cache_password_ex) +{ + struct sysdb_test_ctx *test_ctx; + struct test_data *data; + int ret; + struct ldb_result *res; + const char *attrs[] = { SYSDB_CACHEDPWD_TYPE, SYSDB_CACHEDPWD_FA2_LEN, + NULL }; + int val; + + /* Setup */ + ret = setup_sysdb_tests(&test_ctx); + fail_unless(ret == EOK, "Could not set up the test"); + + data = talloc_zero(test_ctx, struct test_data); + data->ctx = test_ctx; + data->ev = test_ctx->ev; + data->username = talloc_asprintf(data, "testuser%d", _i); + + ret = sysdb_get_user_attr(test_ctx, test_ctx->domain, data->username, + attrs, &res); + fail_unless(ret == EOK, "sysdb_get_user_attr request failed [%d].", ret); + + val = ldb_msg_find_attr_as_int(res->msgs[0], SYSDB_CACHEDPWD_TYPE, 0); + fail_unless(val == SSS_AUTHTOK_TYPE_PASSWORD, + "Unexptected authtok type, found [%d], expected [%d].", + val, SSS_AUTHTOK_TYPE_PASSWORD); + + ret = sysdb_cache_password_ex(test_ctx->domain, data->username, + data->username, SSS_AUTHTOK_TYPE_2FA, 12); + + fail_unless(ret == EOK, "sysdb_cache_password request failed [%d].", ret); + + ret = sysdb_get_user_attr(test_ctx, test_ctx->domain, data->username, + attrs, &res); + fail_unless(ret == EOK, "sysdb_get_user_attr request failed [%d].", ret); + + val = ldb_msg_find_attr_as_int(res->msgs[0], SYSDB_CACHEDPWD_TYPE, 0); + fail_unless(val == SSS_AUTHTOK_TYPE_2FA, + "Unexptected authtok type, found [%d], expected [%d].", + val, SSS_AUTHTOK_TYPE_2FA); + + val = ldb_msg_find_attr_as_int(res->msgs[0], SYSDB_CACHEDPWD_FA2_LEN, 0); + fail_unless(val == 12, + "Unexptected second factor lenght, found [%d], expected [%d].", + val, 12); + + talloc_free(test_ctx); +} +END_TEST + static void cached_authentication_without_expiration(const char *username, const char *password, int expected_result) @@ -6260,6 +6311,8 @@ Suite *create_sysdb_suite(void) 27010, 27011); tcase_add_loop_test(tc_sysdb, test_sysdb_cached_authentication, 27010, 27011); + tcase_add_loop_test(tc_sysdb, test_sysdb_cache_password_ex, 27010, 27011); + /* ASQ search test */ tcase_add_loop_test(tc_sysdb, test_sysdb_prepare_asq_test_user, 28011, 28020); tcase_add_test(tc_sysdb, test_sysdb_asq_search); |