1dedfbb334
Resolves: upstream#3588 - sssd_nss consumes more memory until restarted or machine swaps Resolves: failure in glibc tests https://sourceware.org/bugzilla/show_bug.cgi?id=22530 Resolves: upstream#3451 - When sssd is configured with id_provider proxy and auth_provider ldap, login fails if the LDAP server is not allowing anonymous binds Resolves: upstream#3285 - SSSD needs restart after incorrect clock is corrected with AD Resolves: upstream#3586 - Give a more detailed debug and system-log message if krb5_init_context() failed Resolves: rhbz#1431153 - SSSD ships a drop-in configuration snippet in /etc/systemd/system Backport few upstream features from 1.16.1
172 lines
6.3 KiB
Diff
172 lines
6.3 KiB
Diff
From 0e73859e68b8dc348c2ee1e00a45646d9ac2c63c Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
|
|
Date: Mon, 13 Nov 2017 16:15:21 +0100
|
|
Subject: [PATCH 55/79] TESTS: Order list of entries in some lists
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Some tests started to fail because we depended on specific
|
|
order of users in groups or messages in ldb results to be
|
|
returned and that order changed.
|
|
|
|
This patch adds a simple helper functions into these tests
|
|
that order the entries before comparison with expected results.
|
|
more deterministic.
|
|
|
|
Resolves:
|
|
https://pagure.io/SSSD/sssd/issue/3563
|
|
|
|
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
|
|
---
|
|
src/tests/cmocka/test_nss_srv.c | 22 +++++++++++++++++++
|
|
src/tests/cmocka/test_sysdb_views.c | 42 ++++++++++++++++++++++++++++++++-----
|
|
2 files changed, 59 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
|
|
index 6aa726153183b5a871a75d398727ea7132358ca6..21bd80fb7f6562f6a31452bac6a26c109fef4cb1 100644
|
|
--- a/src/tests/cmocka/test_nss_srv.c
|
|
+++ b/src/tests/cmocka/test_nss_srv.c
|
|
@@ -585,6 +585,25 @@ static errno_t delete_group(struct nss_test_ctx *ctx,
|
|
return ret;
|
|
}
|
|
|
|
+static int cmp_func(const void *a, const void *b)
|
|
+{
|
|
+ char *str1 = *(char **)discard_const(a);
|
|
+ char *str2 = *(char **)discard_const(b);
|
|
+
|
|
+ return strcmp(str1, str2);
|
|
+}
|
|
+
|
|
+static void order_string_array(char **_list, int size)
|
|
+{
|
|
+ if (size < 2 || _list == NULL || *_list == NULL) {
|
|
+ /* Nothing to do */
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ qsort(_list, size, sizeof(char *), cmp_func);
|
|
+ return;
|
|
+}
|
|
+
|
|
static void assert_groups_equal(struct group *expected,
|
|
struct group *gr, const int nmem)
|
|
{
|
|
@@ -594,6 +613,9 @@ static void assert_groups_equal(struct group *expected,
|
|
assert_string_equal(gr->gr_name, expected->gr_name);
|
|
assert_string_equal(gr->gr_passwd, expected->gr_passwd);
|
|
|
|
+ order_string_array(gr->gr_mem, nmem);
|
|
+ order_string_array(expected->gr_mem, nmem);
|
|
+
|
|
for (i = 0; i < nmem; i++) {
|
|
assert_string_equal(gr->gr_mem[i], expected->gr_mem[i]);
|
|
}
|
|
diff --git a/src/tests/cmocka/test_sysdb_views.c b/src/tests/cmocka/test_sysdb_views.c
|
|
index 0378254b4440b29c3182faf2adde8c3db8a4ce97..dd3eb50f9310ff925734dcf51a669d08a638aefd 100644
|
|
--- a/src/tests/cmocka/test_sysdb_views.c
|
|
+++ b/src/tests/cmocka/test_sysdb_views.c
|
|
@@ -22,6 +22,7 @@
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
+#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <stddef.h>
|
|
#include <setjmp.h>
|
|
@@ -612,6 +613,31 @@ static int test_enum_users_setup(void **state)
|
|
return 0;
|
|
}
|
|
|
|
+static int cmp_func(const void *a, const void *b)
|
|
+{
|
|
+ const char *str1;
|
|
+ const char *str2;
|
|
+ struct ldb_message *msg1 = *(struct ldb_message **)discard_const(a);
|
|
+ struct ldb_message *msg2 = *(struct ldb_message **)discard_const(b);
|
|
+
|
|
+ str1 = ldb_msg_find_attr_as_string(msg1, SYSDB_NAME, NULL);
|
|
+ str2 = ldb_msg_find_attr_as_string(msg2, SYSDB_NAME, NULL);
|
|
+
|
|
+ return strcmp(str1, str2);
|
|
+}
|
|
+
|
|
+/* Make the order of ldb results deterministic */
|
|
+static void order_ldb_res_msgs(struct ldb_result *res)
|
|
+{
|
|
+ if (res == NULL || res->count < 2) {
|
|
+ /* Nothing to do */
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ qsort(res->msgs, res->count, sizeof(struct ldb_message *), cmp_func);
|
|
+ return;
|
|
+}
|
|
+
|
|
static void assert_user_attrs(struct ldb_message *msg,
|
|
struct sss_domain_info *dom,
|
|
const char *shortname,
|
|
@@ -660,8 +686,9 @@ static void check_enumpwent(int ret, struct sss_domain_info *dom,
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, N_ELEMENTS(users)-1);
|
|
|
|
- assert_user_attrs(res->msgs[0], dom, "barney", views);
|
|
- assert_user_attrs(res->msgs[1], dom, "alice", views);
|
|
+ order_ldb_res_msgs(res);
|
|
+ assert_user_attrs(res->msgs[0], dom, "alice", views);
|
|
+ assert_user_attrs(res->msgs[1], dom, "barney", views);
|
|
assert_user_attrs(res->msgs[2], dom, "bob", views);
|
|
}
|
|
|
|
@@ -703,6 +730,7 @@ static void test_sysdb_enumpwent_filter(void **state)
|
|
ret = sysdb_enumpwent_filter(test_ctx, test_ctx->domain, "b*", 0, &res);
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, 2);
|
|
+ order_ldb_res_msgs(res);
|
|
assert_user_attrs(res->msgs[0], test_ctx->domain, "barney", false);
|
|
assert_user_attrs(res->msgs[1], test_ctx->domain, "bob", false);
|
|
|
|
@@ -749,6 +777,7 @@ static void test_sysdb_enumpwent_filter_views(void **state)
|
|
"b*", NULL, &res);
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, 2);
|
|
+ order_ldb_res_msgs(res);
|
|
assert_user_attrs(res->msgs[0], test_ctx->domain, "barney", true);
|
|
assert_user_attrs(res->msgs[1], test_ctx->domain, "bob", true);
|
|
|
|
@@ -896,10 +925,11 @@ static void check_enumgrent(int ret, struct sss_domain_info *dom,
|
|
{
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, N_ELEMENTS(groups)-1);
|
|
- assert_group_attrs(res->msgs[0], dom, "three",
|
|
- views ? TEST_GID_OVERRIDE_BASE + 2 : 0);
|
|
- assert_group_attrs(res->msgs[1], dom, "one",
|
|
+ order_ldb_res_msgs(res);
|
|
+ assert_group_attrs(res->msgs[0], dom, "one",
|
|
views ? TEST_GID_OVERRIDE_BASE : 0);
|
|
+ assert_group_attrs(res->msgs[1], dom, "three",
|
|
+ views ? TEST_GID_OVERRIDE_BASE + 2 : 0);
|
|
assert_group_attrs(res->msgs[2], dom, "two",
|
|
views ? TEST_GID_OVERRIDE_BASE + 1 : 0);
|
|
}
|
|
@@ -942,6 +972,7 @@ static void test_sysdb_enumgrent_filter(void **state)
|
|
ret = sysdb_enumgrent_filter(test_ctx, test_ctx->domain, "t*", 0, &res);
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, 2);
|
|
+ order_ldb_res_msgs(res);
|
|
assert_group_attrs(res->msgs[0], test_ctx->domain, "three", 0);
|
|
assert_group_attrs(res->msgs[1], test_ctx->domain, "two", 0);
|
|
|
|
@@ -988,6 +1019,7 @@ static void test_sysdb_enumgrent_filter_views(void **state)
|
|
"t*", NULL, &res);
|
|
assert_int_equal(ret, EOK);
|
|
assert_int_equal(res->count, 2);
|
|
+ order_ldb_res_msgs(res);
|
|
assert_group_attrs(res->msgs[0], test_ctx->domain,
|
|
"three", TEST_GID_OVERRIDE_BASE + 2);
|
|
assert_group_attrs(res->msgs[1], test_ctx->domain, "two",
|
|
--
|
|
2.15.1
|
|
|