diff options
author | Sumit Bose <sbose@redhat.com> | 2014-10-09 21:05:34 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-10-14 18:29:11 +0200 |
commit | 0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47e (patch) | |
tree | fb81c6e36a8565cf5d9d311036e6395c6a0f84d1 /src/tests | |
parent | 229c292143dcd4120acb022682b5b7d0aca622dd (diff) | |
download | sssd-0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47e.tar.gz sssd-0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47e.tar.xz sssd-0d01e4f6cc21d8ca0e4fafe59c7cbfa1459fa47e.zip |
sss_nss_idmap: add sss_nss_getorigbyname()
This patch adds an interface to the new SSS_NSS_GETORIGBYNAME request of
the nss responder to libsss_nss_idmap.
The main use case for this new call is to replace sss_nss_getsidbyname()
in the extdom plugin on the FreeIPA server to get more information about
the given object than just the SID which is not available with the
default POSIX interfaces.
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/cmocka/sss_nss_idmap-tests.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/tests/cmocka/sss_nss_idmap-tests.c b/src/tests/cmocka/sss_nss_idmap-tests.c index 034f3a1ec..4141a3279 100644 --- a/src/tests/cmocka/sss_nss_idmap-tests.c +++ b/src/tests/cmocka/sss_nss_idmap-tests.c @@ -46,6 +46,9 @@ uint8_t buf1[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x uint8_t buf2[] = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00}; uint8_t buf3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00}; uint8_t buf4[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 'x'}; + +uint8_t buf_orig1[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 'k', 'e', 'y', 0x00, 'v', 'a', 'l', 'u', 'e', 0x00}; + enum nss_status sss_nss_make_request(enum sss_cli_command cmd, struct sss_cli_req_data *rd, uint8_t **repbuf, size_t *replen, @@ -68,7 +71,8 @@ enum nss_status sss_nss_make_request(enum sss_cli_command cmd, return d->nss_status; } -void test_getsidbyname(void **state) { +void test_getsidbyname(void **state) +{ int ret; char *sid = NULL; size_t c; @@ -111,11 +115,31 @@ void test_getsidbyname(void **state) { } } +void test_getorigbyname(void **state) +{ + int ret; + struct sss_nss_kv *kv_list; + enum sss_id_type type; + struct sss_nss_make_request_test_data d = {buf_orig1, sizeof(buf_orig1), 0, NSS_STATUS_SUCCESS}; + + will_return(sss_nss_make_request, &d); + ret = sss_nss_getorigbyname("test", &kv_list, &type); + assert_int_equal(ret, EOK); + assert_int_equal(type, SSS_ID_TYPE_UID); + assert_string_equal(kv_list[0].key, "key"); + assert_string_equal(kv_list[0].value, "value"); + assert_null(kv_list[1].key); + assert_null(kv_list[1].value); + + sss_nss_free_kv(kv_list); +} + int main(int argc, const char *argv[]) { const UnitTest tests[] = { unit_test(test_getsidbyname), + unit_test(test_getorigbyname), }; return run_tests(tests); |