diff options
| author | Pavel Březina <pbrezina@redhat.com> | 2017-01-17 14:11:58 +0100 |
|---|---|---|
| committer | Jakub Hrozek <jhrozek@redhat.com> | 2017-02-08 11:05:42 +0100 |
| commit | 4df7aec645f87342f3a5146062abcb15f71f4fd9 (patch) | |
| tree | 2ab8d7c56c0ef8c3b57452bc244f224e47a082d9 /src/tests/cmocka | |
| parent | 9492b3b26ac0b1898f836094074a9d8b38916e13 (diff) | |
| download | sssd-4df7aec645f87342f3a5146062abcb15f71f4fd9.tar.gz sssd-4df7aec645f87342f3a5146062abcb15f71f4fd9.tar.xz sssd-4df7aec645f87342f3a5146062abcb15f71f4fd9.zip | |
cache_req: move dp request to plugin
This will allow to use cache req even for object that do not use
account request such as hosts.
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/tests/cmocka')
| -rw-r--r-- | src/tests/cmocka/common_mock_resp_dp.c | 31 | ||||
| -rw-r--r-- | src/tests/cmocka/test_responder_cache_req.c | 28 |
2 files changed, 40 insertions, 19 deletions
diff --git a/src/tests/cmocka/common_mock_resp_dp.c b/src/tests/cmocka/common_mock_resp_dp.c index 0b6870346..cbdb65d74 100644 --- a/src/tests/cmocka/common_mock_resp_dp.c +++ b/src/tests/cmocka/common_mock_resp_dp.c @@ -61,16 +61,37 @@ sss_dp_get_account_recv(TALLOC_CTX *mem_ctx, return test_request_recv(req); } +errno_t +sss_dp_req_recv(TALLOC_CTX *mem_ctx, + struct tevent_req *req, + dbus_uint16_t *dp_err, + dbus_uint32_t *dp_ret, + char **err_msg) +{ + acct_cb_t cb; + + *dp_err = sss_mock_type(dbus_uint16_t); + *dp_ret = sss_mock_type(dbus_uint32_t); + *err_msg = sss_mock_ptr_type(char *); + + cb = sss_mock_ptr_type(acct_cb_t); + if (cb) { + (cb)(sss_mock_ptr_type(void *)); + } + + return test_request_recv(req); +} + void mock_account_recv(uint16_t dp_err, uint32_t dp_ret, char *msg, acct_cb_t acct_cb, void *pvt) { - will_return(sss_dp_get_account_recv, dp_err); - will_return(sss_dp_get_account_recv, dp_ret); - will_return(sss_dp_get_account_recv, msg); + will_return(sss_dp_req_recv, dp_err); + will_return(sss_dp_req_recv, dp_ret); + will_return(sss_dp_req_recv, msg); - will_return(sss_dp_get_account_recv, acct_cb); + will_return(sss_dp_req_recv, acct_cb); if (acct_cb) { - will_return(sss_dp_get_account_recv, pvt); + will_return(sss_dp_req_recv, pvt); } } diff --git a/src/tests/cmocka/test_responder_cache_req.c b/src/tests/cmocka/test_responder_cache_req.c index d4e54cd47..94a902c03 100644 --- a/src/tests/cmocka/test_responder_cache_req.c +++ b/src/tests/cmocka/test_responder_cache_req.c @@ -530,7 +530,7 @@ void test_user_by_name_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(users[0].short_name, NULL, ERR_OK); /* Test. */ @@ -547,7 +547,7 @@ void test_user_by_name_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(users[0].short_name, NULL, ERR_OK); /* Test. */ @@ -749,7 +749,7 @@ void test_user_by_upn_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND); /* Test. */ @@ -766,7 +766,7 @@ void test_user_by_upn_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND); /* Test. */ @@ -904,7 +904,7 @@ void test_user_by_id_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_user_by_id(test_ctx, NULL, 0, ERR_OK); @@ -920,7 +920,7 @@ void test_user_by_id_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_user_by_id(test_ctx, NULL, 0, ENOENT); @@ -1045,7 +1045,7 @@ void test_group_by_name_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(groups[0].short_name, NULL, ERR_OK); /* Test. */ @@ -1062,7 +1062,7 @@ void test_group_by_name_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); mock_parse_inp(groups[0].short_name, NULL, ERR_OK); /* Test. */ @@ -1261,7 +1261,7 @@ void test_group_by_id_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_group_by_id(test_ctx, NULL, 0, ERR_OK); @@ -1277,7 +1277,7 @@ void test_group_by_id_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_group_by_id(test_ctx, NULL, 0, ENOENT); @@ -1912,7 +1912,7 @@ void test_object_by_sid_user_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_object_by_sid(test_ctx, NULL, users[0].sid, attrs, 0, ERR_OK); @@ -1929,7 +1929,7 @@ void test_object_by_sid_user_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_object_by_sid(test_ctx, NULL, users[0].sid, attrs, 0, ENOENT); @@ -2068,7 +2068,7 @@ void test_object_by_sid_group_multiple_domains_found(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_object_by_sid(test_ctx, NULL, groups[0].sid, attrs, 0, ERR_OK); @@ -2085,7 +2085,7 @@ void test_object_by_sid_group_multiple_domains_notfound(void **state) /* Mock values. */ will_return_always(__wrap_sss_dp_get_account_send, test_ctx); - will_return_always(sss_dp_get_account_recv, 0); + will_return_always(sss_dp_req_recv, 0); /* Test. */ run_object_by_sid(test_ctx, NULL, groups[0].sid, attrs, 0, ENOENT); |
