summaryrefslogtreecommitdiff
path: root/source4/torture/winbind
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2010-01-13 16:02:00 +0100
committerKai Blin <kai@samba.org>2010-01-14 15:18:35 +0100
commite95c04f0f19a6e00251f9eceb94c519a0f91b308 (patch)
tree0d0bfe0e05de4e25caff62de2d7b7ae49ca422e5 /source4/torture/winbind
parent932d4a874bb79ad76b95b43491b223d766ab4196 (diff)
downloadsamba-e95c04f0f19a6e00251f9eceb94c519a0f91b308.tar.gz
samba-e95c04f0f19a6e00251f9eceb94c519a0f91b308.tar.bz2
samba-e95c04f0f19a6e00251f9eceb94c519a0f91b308.zip
s3 selftest: Fix WINBINDD_LIST_GROUPS test
If there's no groups in the database, there are no entries in extra_data. This caused WINBINDD_LIST_GROUPS test to fail. Use the fact that WINBINDD_LIST_GROUPS now reports the number of groups in data.num_entries to identify the "no groups" case.
Diffstat (limited to 'source4/torture/winbind')
-rw-r--r--source4/torture/winbind/struct_based.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index a80f1fa187..d15bd6b807 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -635,7 +635,8 @@ static bool torture_winbind_struct_list_users(struct torture_context *torture)
return true;
}
-static bool get_group_list(struct torture_context *torture, char ***groups)
+static bool get_group_list(struct torture_context *torture, int *num_entries,
+ char ***groups)
{
struct winbindd_request req;
struct winbindd_response rep;
@@ -648,8 +649,17 @@ static bool get_group_list(struct torture_context *torture, char ***groups)
ZERO_STRUCT(rep);
DO_STRUCT_REQ_REP(WINBINDD_LIST_GROUPS, &req, &rep);
-
extra_data = (char *)rep.extra_data.data;
+
+ *num_entries = rep.data.num_entries;
+
+ if (*num_entries == 0) {
+ torture_assert(torture, extra_data == NULL,
+ "extra data is null for >0 reported entries\n");
+ *groups = NULL;
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL extra data");
for(count = 0;
@@ -663,6 +673,9 @@ static bool get_group_list(struct torture_context *torture, char ***groups)
SAFE_FREE(rep.extra_data.data);
+ torture_assert_int_equal(torture, *num_entries, count,
+ "Wrong number of group entries reported.");
+
*groups = g;
return true;
}
@@ -675,11 +688,9 @@ static bool torture_winbind_struct_list_groups(struct torture_context *torture)
torture_comment(torture, "Running WINBINDD_LIST_GROUPS (struct based)\n");
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &count, &groups);
torture_assert(torture, ok, "failed to get group list");
- for (count = 0; groups[count]; count++) { }
-
torture_comment(torture, "got %d groups\n", count);
return true;
@@ -945,7 +956,7 @@ static bool name_is_in_list(const char *name, const char **list)
{
uint32_t count;
- for (count = 0; list[count]; count++) {
+ for (count = 0; list && list[count]; count++) {
if (strequal(name, list[count])) {
return true;
}
@@ -964,7 +975,7 @@ static bool torture_winbind_struct_lookup_name_sid(struct torture_context *tortu
bool strict = torture_setting_bool(torture, "strict mode", false);
char **users;
char **groups;
- uint32_t count;
+ uint32_t count, num_groups;
bool ok;
torture_comment(torture, "Running WINBINDD_LOOKUP_NAME_SID (struct based)\n");
@@ -973,9 +984,11 @@ static bool torture_winbind_struct_lookup_name_sid(struct torture_context *tortu
torture_assert(torture, ok, "failed to retrieve list of users");
lookup_name_sid_list(torture, users);
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &num_groups, &groups);
torture_assert(torture, ok, "failed to retrieve list of groups");
- lookup_name_sid_list(torture, groups);
+ if (num_groups > 0) {
+ lookup_name_sid_list(torture, groups);
+ }
ZERO_STRUCT(req);
ZERO_STRUCT(rep);