c07e32a24f8abe1bcefa9cfbca0cec9dc426b19c
[rusty/samba.git] / source4 / scripting / python / samba / tests / blackbox / ndrdump.py
1 #!/usr/bin/python
2 # Blackbox tests for ndrdump
3 # Copyright (C) 2008 Andrew Tridgell <tridge@samba.org>
4 # Copyright (C) 2008 Andrew Bartlett <abartlet@samba.org>
5 # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
6 # based on test_smbclient.sh
7
8 """Blackbox tests for ndrdump."""
9
10 import os
11 from samba.tests import BlackboxTestCase
12
13 for p in [ "../../../../../source4/librpc/tests", "../../../../../librpc/tests"]:
14     data_path_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), p))
15     print data_path_dir
16     if os.path.exists(data_path_dir):
17         break
18
19
20 class NdrDumpTests(BlackboxTestCase):
21     """Blackbox tests for ndrdump."""
22
23     def data_path(self, name):
24         return os.path.join(data_path_dir, name)
25
26     def test_ndrdump_with_in(self):
27         self.check_run("ndrdump samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat")))
28
29     def test_ndrdump_with_out(self):
30         self.check_run("ndrdump samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-out.dat")))
31
32     def test_ndrdump_context_file(self):
33         self.check_run("ndrdump --context-file %s samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-in.dat"), self.data_path("samr-CreateUser-out.dat")))
34
35     def test_ndrdump_with_validate(self):
36         self.check_run("ndrdump --validate samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat")))