From f3fd2d9457920b3da3e0ce6c1c6ee77be6849c65 Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Wed, 13 Feb 2019 14:34:06 +1300 Subject: [PATCH] s2 decrpc samr: Add tests for QueryDomainInfo Add tests for the number of domain users, groups and aliases returned by QueryDomainInfo. These tests revealed that the existing code was not checking the returned elements to ensure they were part of the domain. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- python/samba/tests/dcerpc/sam.py | 55 ++++++++++++++++++++ selftest/knownfail.d/dom_general_information | 1 + 2 files changed, 56 insertions(+) create mode 100644 selftest/knownfail.d/dom_general_information diff --git a/python/samba/tests/dcerpc/sam.py b/python/samba/tests/dcerpc/sam.py index ab710861383e..4d787214b1d6 100644 --- a/python/samba/tests/dcerpc/sam.py +++ b/python/samba/tests/dcerpc/sam.py @@ -20,6 +20,7 @@ """Tests for samba.dcerpc.sam.""" from samba.dcerpc import samr, security, lsa +from samba.dcerpc.samr import DomainGeneralInformation from samba.tests import RpcInterfaceTestCase from samba.tests import env_loadparm, delete_force @@ -748,3 +749,57 @@ class SamrTests(RpcInterfaceTestCase): check_results(expected, actual) self.delete_dns(dns) + + def test_DomGeneralInformation_num_users(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain users and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainUsers( + self.domain_handle, 0, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainUsers( + self.domain_handle, resume_handle, 0, max_size) + count += num_entries + + self.assertEquals(count, info.num_users) + + def test_DomGeneralInformation_num_groups(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain groups and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainGroups( + self.domain_handle, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainGroups( + self.domain_handle, resume_handle, max_size) + count += num_entries + + self.assertEquals(count, info.num_groups) + + def test_DomGeneralInformation_num_aliases(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain aliases and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainAliases( + self.domain_handle, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainAliases( + self.domain_handle, resume_handle, max_size) + count += num_entries + + self.assertEquals(count, info.num_aliases) diff --git a/selftest/knownfail.d/dom_general_information b/selftest/knownfail.d/dom_general_information new file mode 100644 index 000000000000..6891e22faa2b --- /dev/null +++ b/selftest/knownfail.d/dom_general_information @@ -0,0 +1 @@ +^samba.tests.dcerpc.sam.samba.tests.dcerpc.sam.SamrTests.test_DomGeneralInformation_num_aliases -- 2.34.1