From 08e3f99f14f178e87f3543261be59a7f97f60b4f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Feb 2008 02:18:45 +0100 Subject: Initial work on a test for samba.tests.samdb (This used to be commit 8b33860954ca03be1ea45fd8d40963dbbd5b162f) --- source4/scripting/python/samba/tests/samdb.py | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 source4/scripting/python/samba/tests/samdb.py (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py new file mode 100644 index 00000000000..40e56bebb54 --- /dev/null +++ b/source4/scripting/python/samba/tests/samdb.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. Tests for SamDB +# Copyright (C) Jelmer Vernooij 2008 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +from auth import system_session +from credentials import Credentials +import os +from samba.provision import setup_samdb +from samba.samdb import SamDB +from samba.tests import get_loadparm, TestCaseInTempDir +import security +from unittest import TestCase +import uuid + +class SamDBTestCase(TestCaseInTempDir): + def setUp(self): + super(SamDBTestCase, self).setUp() + invocationid = uuid.random() + domaindn = "DC=COM,DC=EXAMPLE" + self.domaindn = domaindn + configdn = "CN=Configuration," + domaindn + schemadn = "CN=Schema," + configdn + domainguid = uuid.random() + policyguid = uuid.random() + setup_path = lambda x: os.path.join("setup", x) + creds = Credentials() + domainsid = security.random_sid() + hostguid = uuid.random() + path = os.path.join(self.tempdir, "samdb.ldb") + self.samdb = setup_samdb(path, setup_path, system_session(), creds, + get_loadparm(), schemadn, configdn, + self.domaindn, "example.com", "EXAMPLE.COM", + "FOO", lambda x: None, "foo", domaindn, + False, domainsid, "# no aci", domainguid, + policyguid, "EXAMPLE", True, "secret", + "secret", "secret", hostguid, invocationid, + "secret", "domain controller") + + def test_add_foreign(self): + self.samdb.add_foreign(self.domaindn, "S-1-5-7", "Somedescription") + -- cgit From 142fbfb3c1f9f8cda7f0edaa801f8345f23d805f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 28 Mar 2008 21:57:15 +1100 Subject: Fix and test python scripts and kerberos This fixes up the python credentials interface in a number of areas, with the aim of supporting '-k yes' as a command line option. (This enables the use of kerberos). As such, I've had to change the get_credentials call to take a loadparm context, so that the credentials can be initialised correctly. The test_kinit script has been modified to prove that this continues to work, as well as to provide greater code coverage of the kerberos paths. Andrew Bartlett (This used to be commit 727ef40c2b56910028ef3c1092b8eab1bfa6ce63) --- source4/scripting/python/samba/tests/samdb.py | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 40e56bebb54..3745dba6fc2 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -38,6 +38,7 @@ class SamDBTestCase(TestCaseInTempDir): policyguid = uuid.random() setup_path = lambda x: os.path.join("setup", x) creds = Credentials() + creds.set_anonymous() domainsid = security.random_sid() hostguid = uuid.random() path = os.path.join(self.tempdir, "samdb.ldb") -- cgit From 1b5f32128d1867829647a4e1f20b6e8363444f66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 23:28:14 +0200 Subject: Use RpcInterfaceTestCase everywhere. (This used to be commit 799095b4e567f4495adf7d1d7bcb81dda6782959) --- source4/scripting/python/samba/tests/samdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 3745dba6fc2..0e175bf936a 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -21,7 +21,7 @@ from credentials import Credentials import os from samba.provision import setup_samdb from samba.samdb import SamDB -from samba.tests import get_loadparm, TestCaseInTempDir +from samba.tests import cmdline_loadparm, TestCaseInTempDir import security from unittest import TestCase import uuid @@ -43,7 +43,7 @@ class SamDBTestCase(TestCaseInTempDir): hostguid = uuid.random() path = os.path.join(self.tempdir, "samdb.ldb") self.samdb = setup_samdb(path, setup_path, system_session(), creds, - get_loadparm(), schemadn, configdn, + cmdline_loadparm, schemadn, configdn, self.domaindn, "example.com", "EXAMPLE.COM", "FOO", lambda x: None, "foo", domaindn, False, domainsid, "# no aci", domainguid, -- cgit From 5319d9620b9ef68b3687d76aeaba5fa5d5c57a18 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 03:31:26 +0200 Subject: Use consistent function names with the standard Python uuid module that is available in >= 2.4. (This used to be commit 60d458e3195eef6baf655fee0da7c3f68517e8e6) --- source4/scripting/python/samba/tests/samdb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 0e175bf936a..9da33585272 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -29,18 +29,18 @@ import uuid class SamDBTestCase(TestCaseInTempDir): def setUp(self): super(SamDBTestCase, self).setUp() - invocationid = uuid.random() + invocationid = uuid.uuid4() domaindn = "DC=COM,DC=EXAMPLE" self.domaindn = domaindn configdn = "CN=Configuration," + domaindn schemadn = "CN=Schema," + configdn - domainguid = uuid.random() - policyguid = uuid.random() + domainguid = uuid.uuid4() + policyguid = uuid.uuid4() setup_path = lambda x: os.path.join("setup", x) creds = Credentials() creds.set_anonymous() domainsid = security.random_sid() - hostguid = uuid.random() + hostguid = uuid.uuid4() path = os.path.join(self.tempdir, "samdb.ldb") self.samdb = setup_samdb(path, setup_path, system_session(), creds, cmdline_loadparm, schemadn, configdn, -- cgit From 251f6bd99159337b24b8aa8298a5c98de153bce0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 04:36:37 +0200 Subject: make sure to always use string version of uuid rather than object. (This used to be commit bcd5fc7dc9899deb9fa84fdeeb21ed2ddb921308) --- source4/scripting/python/samba/tests/samdb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 9da33585272..0d4f7bde0e9 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -29,18 +29,18 @@ import uuid class SamDBTestCase(TestCaseInTempDir): def setUp(self): super(SamDBTestCase, self).setUp() - invocationid = uuid.uuid4() + invocationid = str(uuid.uuid4()) domaindn = "DC=COM,DC=EXAMPLE" self.domaindn = domaindn configdn = "CN=Configuration," + domaindn schemadn = "CN=Schema," + configdn - domainguid = uuid.uuid4() - policyguid = uuid.uuid4() + domainguid = str(uuid.uuid4()) + policyguid = str(uuid.uuid4()) setup_path = lambda x: os.path.join("setup", x) creds = Credentials() creds.set_anonymous() domainsid = security.random_sid() - hostguid = uuid.uuid4() + hostguid = str(uuid.uuid4()) path = os.path.join(self.tempdir, "samdb.ldb") self.samdb = setup_samdb(path, setup_path, system_session(), creds, cmdline_loadparm, schemadn, configdn, -- cgit From e16f0e15b40229e7a42311dddfb391cf6142462e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 May 2008 17:31:16 +0200 Subject: Update after changes to the provision API, make sure temp dir gets cleaned up. (This used to be commit 064e9ddb3786bd7df8785b39754b1e6674496b66) --- source4/scripting/python/samba/tests/samdb.py | 29 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 0d4f7bde0e9..a022d7bb514 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -16,13 +16,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -from auth import system_session -from credentials import Credentials +from samba.auth import system_session +from samba.credentials import Credentials import os -from samba.provision import setup_samdb +from samba.provision import setup_samdb, guess_names from samba.samdb import SamDB from samba.tests import cmdline_loadparm, TestCaseInTempDir -import security +from samba import security from unittest import TestCase import uuid @@ -42,14 +42,23 @@ class SamDBTestCase(TestCaseInTempDir): domainsid = security.random_sid() hostguid = str(uuid.uuid4()) path = os.path.join(self.tempdir, "samdb.ldb") + names = guess_names(lp=cmdline_loadparm, hostname="foo", + domain="EXAMPLE.COM", dnsdomain="example.com", + serverrole="domain controller", + domaindn=self.domaindn, configdn=configdn, + schemadn=schemadn) self.samdb = setup_samdb(path, setup_path, system_session(), creds, - cmdline_loadparm, schemadn, configdn, - self.domaindn, "example.com", "EXAMPLE.COM", - "FOO", lambda x: None, "foo", domaindn, - False, domainsid, "# no aci", domainguid, - policyguid, "EXAMPLE", True, "secret", - "secret", "secret", hostguid, invocationid, + cmdline_loadparm, names, + lambda x: None, domainsid, + "# no aci", domainguid, + policyguid, False, "secret", + "secret", "secret", invocationid, "secret", "domain controller") + def tearDown(self): + for f in ['templates.ldb', 'schema.ldb', 'configuration.ldb', + 'users.ldb', 'samdb.ldb']: + os.remove(os.path.join(self.tempdir, f)) + super(SamDBTestCase, self).tearDown() def test_add_foreign(self): self.samdb.add_foreign(self.domaindn, "S-1-5-7", "Somedescription") -- cgit From 6f7b2b69333230016a9538b024faec0d97095c69 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 May 2008 17:38:12 +0200 Subject: Fix samdb test and enable it. (This used to be commit 6b202d3780f8ff50e0bdfa4a749c43b5639e4880) --- source4/scripting/python/samba/tests/samdb.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index a022d7bb514..7e8ba053d44 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -19,7 +19,7 @@ from samba.auth import system_session from samba.credentials import Credentials import os -from samba.provision import setup_samdb, guess_names +from samba.provision import setup_samdb, guess_names, setup_templatesdb from samba.samdb import SamDB from samba.tests import cmdline_loadparm, TestCaseInTempDir from samba import security @@ -42,12 +42,16 @@ class SamDBTestCase(TestCaseInTempDir): domainsid = security.random_sid() hostguid = str(uuid.uuid4()) path = os.path.join(self.tempdir, "samdb.ldb") + session_info = system_session() names = guess_names(lp=cmdline_loadparm, hostname="foo", domain="EXAMPLE.COM", dnsdomain="example.com", serverrole="domain controller", domaindn=self.domaindn, configdn=configdn, schemadn=schemadn) - self.samdb = setup_samdb(path, setup_path, system_session(), creds, + setup_templatesdb(os.path.join(self.tempdir, "templates.ldb"), + setup_path, session_info=session_info, + credentials=creds, lp=cmdline_loadparm) + self.samdb = setup_samdb(path, setup_path, session_info, creds, cmdline_loadparm, names, lambda x: None, domainsid, "# no aci", domainguid, -- cgit From b9babfe4cc70b96f4f1df037244cd27eae580c94 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 30 May 2008 14:26:47 +1000 Subject: Fix up provision and samdb tests. This fixes up the provision to operate with a target directory - it must override the smb.conf in this case. Andrew Bartlett (This used to be commit 89fc39f7edb214065aff461bc225f41443eae3c7) --- source4/scripting/python/samba/tests/samdb.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 7e8ba053d44..fcf93a3fc6f 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -19,12 +19,13 @@ from samba.auth import system_session from samba.credentials import Credentials import os -from samba.provision import setup_samdb, guess_names, setup_templatesdb +from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf from samba.samdb import SamDB from samba.tests import cmdline_loadparm, TestCaseInTempDir from samba import security from unittest import TestCase import uuid +import param class SamDBTestCase(TestCaseInTempDir): def setUp(self): @@ -43,9 +44,22 @@ class SamDBTestCase(TestCaseInTempDir): hostguid = str(uuid.uuid4()) path = os.path.join(self.tempdir, "samdb.ldb") session_info = system_session() - names = guess_names(lp=cmdline_loadparm, hostname="foo", - domain="EXAMPLE.COM", dnsdomain="example.com", - serverrole="domain controller", + + hostname="foo" + domain="EXAMPLE" + dnsdomain="example.com" + serverrole="domain controller" + + smbconf = os.path.join(self.tempdir, "smb.conf") + make_smbconf(smbconf, setup_path, hostname, domain, dnsdomain, serverrole, + self.tempdir) + + lp = param.LoadParm() + lp.load(smbconf) + + names = guess_names(lp=lp, hostname=hostname, + domain=domain, dnsdomain=dnsdomain, + serverrole=severrole, domaindn=self.domaindn, configdn=configdn, schemadn=schemadn) setup_templatesdb(os.path.join(self.tempdir, "templates.ldb"), @@ -58,9 +72,10 @@ class SamDBTestCase(TestCaseInTempDir): policyguid, False, "secret", "secret", "secret", invocationid, "secret", "domain controller") + def tearDown(self): for f in ['templates.ldb', 'schema.ldb', 'configuration.ldb', - 'users.ldb', 'samdb.ldb']: + 'users.ldb', 'samdb.ldb', 'smb.conf']: os.remove(os.path.join(self.tempdir, f)) super(SamDBTestCase, self).tearDown() -- cgit From 277287114679addc2ef26fbe6a82963f9cf1b196 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 May 2008 14:15:40 +0200 Subject: Fix samdb python test. (This used to be commit 0e3d488cc108174ca0f875aab16b9771c2933f19) --- source4/scripting/python/samba/tests/samdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python/samba/tests/samdb.py') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index fcf93a3fc6f..97be5672ce8 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -25,7 +25,7 @@ from samba.tests import cmdline_loadparm, TestCaseInTempDir from samba import security from unittest import TestCase import uuid -import param +from samba import param class SamDBTestCase(TestCaseInTempDir): def setUp(self): @@ -59,7 +59,7 @@ class SamDBTestCase(TestCaseInTempDir): names = guess_names(lp=lp, hostname=hostname, domain=domain, dnsdomain=dnsdomain, - serverrole=severrole, + serverrole=serverrole, domaindn=self.domaindn, configdn=configdn, schemadn=schemadn) setup_templatesdb(os.path.join(self.tempdir, "templates.ldb"), -- cgit