Re: [Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
On 07/07/2015 03:47 PM, Sumit Bose wrote: On Tue, May 26, 2015 at 02:47:02PM +0300, Alexander Bokovoy wrote: On Tue, 26 May 2015, Sumit Bose wrote: On Tue, May 26, 2015 at 01:24:30PM +0200, Petr Vobornik wrote: On 05/26/2015 01:21 PM, Sumit Bose wrote: Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit So it has been acked? And we can push it? I have to admit that I'm not sure, there were just to many related tickets. Alexander, do you remember seeing this patch? If not, I think it would be good if someone can review it. Since it is only a unit-test, it is not urgent. I've seen this patch and I thought I've acked it by the time... New version rebased on one-way trust patches is attached. bye, Sumit -- / Alexander Bokovoy ACK. Pushed to master: 7b524e783515a16102aeffdb69fa9ed5fca07c1b -- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
Re: [Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
On Tue, May 26, 2015 at 02:47:02PM +0300, Alexander Bokovoy wrote: On Tue, 26 May 2015, Sumit Bose wrote: On Tue, May 26, 2015 at 01:24:30PM +0200, Petr Vobornik wrote: On 05/26/2015 01:21 PM, Sumit Bose wrote: Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit So it has been acked? And we can push it? I have to admit that I'm not sure, there were just to many related tickets. Alexander, do you remember seeing this patch? If not, I think it would be good if someone can review it. Since it is only a unit-test, it is not urgent. I've seen this patch and I thought I've acked it by the time... New version rebased on one-way trust patches is attached. bye, Sumit -- / Alexander Bokovoy From 5b5c9250416bf1e55a453c5430ac6be914054aa9 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 26 Feb 2015 14:08:06 +0100 Subject: [PATCH 144/148] extdom: add unit-test for get_user_grouplist() --- .../ipa-extdom-extop/ipa_extdom.h |2 + .../ipa-extdom-extop/ipa_extdom_cmocka_tests.c | 41 + .../ipa-extdom-extop/ipa_extdom_common.c |4 +- .../ipa-extdom-extop/test_data/group | 1000 4 files changed, 1045 insertions(+), 2 deletions(-) diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h index 65dd43ea35726db6231386a0fcbba9be1bd71412..a77711977186b702caafa2729dc13090c6031791 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h @@ -185,6 +185,8 @@ int getgrnam_r_wrapper(size_t buf_max, const char *name, struct group *grp, char **_buf, size_t *_buf_len); int getgrgid_r_wrapper(size_t buf_max, gid_t gid, struct group *grp, char **_buf, size_t *_buf_len); +int get_user_grouplist(const char *name, gid_t gid, + size_t *_ngroups, gid_t **_groups); int pack_ber_sid(const char *sid, struct berval **berval); int pack_ber_name(const char *domain_name, const char *name, struct berval **berval); diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c index 42d588d08a96f8a26345f85aade9523e05f6f56e..ec553fe62c27738f258defc267fe761c72157df0 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c @@ -213,6 +213,46 @@ void test_getgrgid_r_wrapper(void **state) free(buf); } +void test_get_user_grouplist(void **state) +{ +int ret; +size_t ngroups; +gid_t *groups; +size_t c; + +/* This is a bit odd behaviour of getgrouplist() it does not check if the + * user exists, only if memberships of the user can be found. */ +ret = get_user_grouplist(non_exisiting_user, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 1); +assert_int_equal(groups[0], 23456); +free(groups); + +ret = get_user_grouplist(member0001, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 3); +assert_int_equal(groups[0], 23456); +assert_int_equal(groups[1], 1); +assert_int_equal(groups[2], 2); +free(groups); + +ret = get_user_grouplist(member0003, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 2); +assert_int_equal(groups[0], 23456); +assert_int_equal(groups[1], 2); +free(groups); + +ret = get_user_grouplist(user_big, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 1001); +assert_int_equal(groups[0], 23456); +for (c = 1; c ngroups; c++) { +assert_int_equal(groups[c], 2 + c); +} +free(groups); +} + struct test_data { struct extdom_req *req; struct ipa_extdom_ctx *ctx; @@ -398,6 +438,7 @@ int main(int argc, const char *argv[]) unit_test(test_getpwuid_r_wrapper), unit_test(test_getgrnam_r_wrapper), unit_test(test_getgrgid_r_wrapper), +unit_test(test_get_user_grouplist), unit_test_setup_teardown(test_set_err_msg, extdom_req_setup, extdom_req_teardown), unit_test_setup_teardown(test_encode, diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c index b2e690471cd045154454a26aa6756c2628bbc262..f5905c78e5f6eb635fcd0acf0afeda3bdb3b9baa 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c @@ -400,8 +400,8 @@ int check_request(struct
[Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit From 724258fc3eff2872cf95a5401f25b8134233ee68 Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Thu, 26 Feb 2015 14:08:06 +0100 Subject: [PATCH] extdom: add unit-test for get_user_grouplist() --- .../ipa-extdom-extop/ipa_extdom.h |2 + .../ipa-extdom-extop/ipa_extdom_cmocka_tests.c | 41 + .../ipa-extdom-extop/ipa_extdom_common.c |4 +- .../ipa-extdom-extop/test_data/group | 1000 4 files changed, 1045 insertions(+), 2 deletions(-) diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h index 65dd43ea35726db6231386a0fcbba9be1bd71412..a77711977186b702caafa2729dc13090c6031791 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom.h @@ -185,6 +185,8 @@ int getgrnam_r_wrapper(size_t buf_max, const char *name, struct group *grp, char **_buf, size_t *_buf_len); int getgrgid_r_wrapper(size_t buf_max, gid_t gid, struct group *grp, char **_buf, size_t *_buf_len); +int get_user_grouplist(const char *name, gid_t gid, + size_t *_ngroups, gid_t **_groups); int pack_ber_sid(const char *sid, struct berval **berval); int pack_ber_name(const char *domain_name, const char *name, struct berval **berval); diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c index 42d588d08a96f8a26345f85aade9523e05f6f56e..ec553fe62c27738f258defc267fe761c72157df0 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_cmocka_tests.c @@ -213,6 +213,46 @@ void test_getgrgid_r_wrapper(void **state) free(buf); } +void test_get_user_grouplist(void **state) +{ +int ret; +size_t ngroups; +gid_t *groups; +size_t c; + +/* This is a bit odd behaviour of getgrouplist() it does not check if the + * user exists, only if memberships of the user can be found. */ +ret = get_user_grouplist(non_exisiting_user, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 1); +assert_int_equal(groups[0], 23456); +free(groups); + +ret = get_user_grouplist(member0001, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 3); +assert_int_equal(groups[0], 23456); +assert_int_equal(groups[1], 1); +assert_int_equal(groups[2], 2); +free(groups); + +ret = get_user_grouplist(member0003, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 2); +assert_int_equal(groups[0], 23456); +assert_int_equal(groups[1], 2); +free(groups); + +ret = get_user_grouplist(user_big, 23456, ngroups, groups); +assert_int_equal(ret, LDAP_SUCCESS); +assert_int_equal(ngroups, 1001); +assert_int_equal(groups[0], 23456); +for (c = 1; c ngroups; c++) { +assert_int_equal(groups[c], 2 + c); +} +free(groups); +} + struct test_data { struct extdom_req *req; struct ipa_extdom_ctx *ctx; @@ -398,6 +438,7 @@ int main(int argc, const char *argv[]) unit_test(test_getpwuid_r_wrapper), unit_test(test_getgrnam_r_wrapper), unit_test(test_getgrgid_r_wrapper), +unit_test(test_get_user_grouplist), unit_test_setup_teardown(test_set_err_msg, extdom_req_setup, extdom_req_teardown), unit_test_setup_teardown(test_encode, diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c index b2e690471cd045154454a26aa6756c2628bbc262..f5905c78e5f6eb635fcd0acf0afeda3bdb3b9baa 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c +++ b/daemons/ipa-slapi-plugins/ipa-extdom-extop/ipa_extdom_common.c @@ -400,8 +400,8 @@ int check_request(struct extdom_req *req, enum extdom_version version) return LDAP_SUCCESS; } -static int get_user_grouplist(const char *name, gid_t gid, - size_t *_ngroups, gid_t **_groups ) +int get_user_grouplist(const char *name, gid_t gid, + size_t *_ngroups, gid_t **_groups) { int ret; int ngroups; diff --git a/daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/group b/daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/group index 8d1b012871b21cc9d5ffdba2168f35ef3e8a5f81..8394789f9ab89cda928af7a3e2b03de1f2a98395 100644 --- a/daemons/ipa-slapi-plugins/ipa-extdom-extop/test_data/group +++
Re: [Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
On 05/26/2015 01:21 PM, Sumit Bose wrote: Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit So it has been acked? And we can push it? -- Petr Vobornik -- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
Re: [Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
On Tue, 26 May 2015, Sumit Bose wrote: On Tue, May 26, 2015 at 01:24:30PM +0200, Petr Vobornik wrote: On 05/26/2015 01:21 PM, Sumit Bose wrote: Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit So it has been acked? And we can push it? I have to admit that I'm not sure, there were just to many related tickets. Alexander, do you remember seeing this patch? If not, I think it would be good if someone can review it. Since it is only a unit-test, it is not urgent. I've seen this patch and I thought I've acked it by the time... -- / Alexander Bokovoy -- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
Re: [Freeipa-devel] [PATCH 144] extdom: add unit-test for get_user_grouplist()
On Tue, May 26, 2015 at 01:24:30PM +0200, Petr Vobornik wrote: On 05/26/2015 01:21 PM, Sumit Bose wrote: Hi, this tests should have gone together with c1114ef82516002de08e004a930b5ba4a1791b25 but got lost somehow during the bugzilla processing. bye, Sumit So it has been acked? And we can push it? I have to admit that I'm not sure, there were just to many related tickets. Alexander, do you remember seeing this patch? If not, I think it would be good if someone can review it. Since it is only a unit-test, it is not urgent. bye, Sumit -- Petr Vobornik -- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code