summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-03-09 14:32:55 +0100
committerMichael Adam <obnox@samba.org>2012-03-14 19:39:18 +0100
commita85d86129a8ff4e0ca5874fe9a858a81d5627043 (patch)
tree4a6a7f18c62eaed51f5fbdcc1f3961b271c3af43 /source4
parente625a319e25acb66a772493914f33aad43c09322 (diff)
downloadsamba-a85d86129a8ff4e0ca5874fe9a858a81d5627043.tar.gz
samba-a85d86129a8ff4e0ca5874fe9a858a81d5627043.tar.bz2
samba-a85d86129a8ff4e0ca5874fe9a858a81d5627043.zip
s4:selftest: add a new test for "samba-tool user list"
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/tests/samba_tool/user.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/tests/samba_tool/user.py b/source4/scripting/python/samba/tests/samba_tool/user.py
index 3e00ed3cf4..3861a001df 100644
--- a/source4/scripting/python/samba/tests/samba_tool/user.py
+++ b/source4/scripting/python/samba/tests/samba_tool/user.py
@@ -19,7 +19,10 @@ import os
import time
import ldb
from samba.tests.samba_tool.base import SambaToolCmdTest
-from samba import nttime2unix
+from samba import (
+ nttime2unix,
+ dsdb
+ )
class UserCmdTestCase(SambaToolCmdTest):
"""Tests for samba-tool user subcommands"""
@@ -174,6 +177,29 @@ class UserCmdTestCase(SambaToolCmdTest):
self.assertWithin(expires, twodays, 5, "Ensure account expires is within 5 seconds of the expected time")
+ def test_list(self):
+ (result, out, err) = self.runsubcmd("user", "list",
+ "-H", "ldap://%s" % os.environ["DC_SERVER"],
+ "-U%s%%%s" % (os.environ["DC_USERNAME"],
+ os.environ["DC_PASSWORD"]))
+ self.assertCmdSuccess(result, "Error runing list")
+
+ search_filter = ("(&(objectClass=user)(userAccountControl:%s:=%u))" %
+ (ldb.OID_COMPARATOR_AND, dsdb.UF_NORMAL_ACCOUNT))
+
+ userlist = self.samdb.search(base=self.samdb.domain_dn(),
+ scope=ldb.SCOPE_SUBTREE,
+ expression=search_filter,
+ attrs=["samaccountname"])
+
+ self.assertTrue(len(userlist) > 0, "no users found in samdb")
+
+ for userobj in userlist:
+ name = userobj.get("samaccountname", idx=0)
+ found = self.assertMatch(out, name,
+ "user '%s' not found" % name)
+
+
def _randomUser(self, base={}):
"""create a user with random attribute values, you can specify base attributes"""
user = {