summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-06-02 12:24:43 +0200
committerGünther Deschner <gd@samba.org>2009-06-04 10:30:44 +0200
commitc49f6b7bc6b7a958123a7821ade1648875d8419e (patch)
tree6f100ccfdb8279abf75c037aec28b2280a7d7b67 /lib
parent911624567ab464b8570c1580dae055a5fdc5587a (diff)
downloadsamba-c49f6b7bc6b7a958123a7821ade1648875d8419e.tar.gz
samba-c49f6b7bc6b7a958123a7821ade1648875d8419e.tar.bz2
samba-c49f6b7bc6b7a958123a7821ade1648875d8419e.zip
nss_wrapper: refactor test_nwrap_membership_user() in testsuite.
Guenther
Diffstat (limited to 'lib')
-rw-r--r--lib/nss_wrapper/testsuite.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/nss_wrapper/testsuite.c b/lib/nss_wrapper/testsuite.c
index d63e7363ca..a98c141e3e 100644
--- a/lib/nss_wrapper/testsuite.c
+++ b/lib/nss_wrapper/testsuite.c
@@ -297,6 +297,28 @@ static bool test_nwrap_getgrouplist(struct torture_context *tctx,
return true;
}
+static bool test_nwrap_membership_user(struct torture_context *tctx,
+ const struct passwd *pwd)
+{
+ int num_user_groups = 0;
+ gid_t *user_groups = NULL;
+ int g;
+
+ torture_assert(tctx, test_nwrap_getgrouplist(tctx,
+ pwd->pw_name,
+ pwd->pw_gid,
+ &user_groups,
+ &num_user_groups),
+ "failed to test getgrouplist");
+
+ for (g=0; g < num_user_groups; g++) {
+ torture_assert(tctx, test_nwrap_getgrgid(tctx, user_groups[g]),
+ "failed to find the group the user is a member of");
+ }
+
+ return true;
+}
+
static bool test_nwrap_membership(struct torture_context *tctx)
{
const char *old_pwd = getenv("NSS_WRAPPER_PASSWD");
@@ -315,21 +337,9 @@ static bool test_nwrap_membership(struct torture_context *tctx)
for (i=0; i < num_pwd; i++) {
- int num_user_groups = 0;
- gid_t *user_groups = NULL;
- int g;
+ torture_assert(tctx, test_nwrap_membership_user(tctx, &pwd[i]),
+ "failde to test membership for user");
- torture_assert(tctx, test_nwrap_getgrouplist(tctx,
- pwd[i].pw_name,
- pwd[i].pw_gid,
- &user_groups,
- &num_user_groups),
- "failed to test getgrouplist");
-
- for (g=0; g < num_user_groups; g++) {
- torture_assert(tctx, test_nwrap_getgrgid(tctx, user_groups[g]),
- "failed to find the group the user is a member of");
- }
}
return true;