1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Lumir Balhar <lbalhar@redhat.com> 2017
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from samba
import ldb
, Ldb
20 from samba
.tdb_util
import tdb_copy
24 class TDBUtilTests(samba
.tests
.TestCaseInTempDir
):
26 def test_tdb_copy(self
):
27 src_ldb_file
= os
.path
.join(self
.tempdir
, "source.ldb")
28 dst_ldb_file
= os
.path
.join(self
.tempdir
, "destination.ldb")
30 # Create LDB source file with some content
31 src_ldb
= Ldb(src_ldb_file
)
32 src_ldb
.add({"dn": "f=dc", "b": "bla"})
34 # Copy source file to destination file and check return status
35 self
.assertIsNone(tdb_copy(src_ldb_file
, dst_ldb_file
))
37 # Load copied file as LDB object
38 dst_ldb
= Ldb(dst_ldb_file
)
40 # Copmare contents of files
42 src_ldb
.searchone(basedn
=ldb
.Dn(src_ldb
, "f=dc"), attribute
="b"),
43 dst_ldb
.searchone(basedn
=ldb
.Dn(dst_ldb
, "f=dc"), attribute
="b")
49 os
.unlink(src_ldb_file
)
50 os
.unlink(dst_ldb_file
)