s4-lsarpc: Restrict LookupSids3 to crypto connections only.
[Samba/gebeck_regimport.git] / source3 / stf / smbcontrol.py
blob30c331819c76712e05a66f8ec4c17a7b6f6f6832
1 #!/usr/bin/python
3 # Test for smbcontrol command line argument handling.
6 import comfychair
8 class NoArgs(comfychair.TestCase):
9 """Test no arguments produces usage message."""
10 def runtest(self):
11 out = self.runcmd("smbcontrol", expectedResult = 1)
12 self.assert_re_match("Usage: smbcontrol", out[1])
14 class OneArg(comfychair.TestCase):
15 """Test single argument produces usage message."""
16 def runtest(self):
17 out = self.runcmd("smbcontrol foo", expectedResult = 1)
18 self.assert_re_match("Usage: smbcontrol", out[1])
20 class SmbdDest(comfychair.TestCase):
21 """Test the broadcast destination 'smbd'."""
22 def runtest(self):
23 out = self.runcmd("smbcontrol smbd noop")
25 class NmbdDest(comfychair.TestCase):
26 """Test the destination 'nmbd'."""
27 def runtest(self):
28 # We need a way to start/stop/whatever nmbd
29 raise comfychair.NotRunError, "not implemented"
31 class PidDest(comfychair.TestCase):
32 """Test a pid number destination'."""
33 def runtest(self):
34 out = self.runcmd("smbcontrol 1234 noop")
36 class SelfDest(comfychair.TestCase):
37 """Test the destination 'self'."""
38 def runtest(self):
39 out = self.runcmd("smbcontrol self noop")
41 class WinbinddDest(comfychair.TestCase):
42 """Test the destination 'winbindd'."""
43 def runtest(self):
44 # We need a way to start/stop/whatever winbindd
45 raise comfychair.NotRunError, "not implemented"
47 class BadDest(comfychair.TestCase):
48 """Test a bad destination."""
49 def runtest(self):
50 out = self.runcmd("smbcontrol foo noop", expectedResult = 1)
52 class BadCmd(comfychair.TestCase):
53 """Test a bad command."""
54 def runtest(self):
55 out = self.runcmd("smbcontrol self spottyfoot", expectedResult = 1)
56 self.assert_re_match("smbcontrol: unknown command", out[1]);
58 class NoArgCmdTest(comfychair.TestCase):
59 """A test class that tests a command with no argument."""
60 def runtest(self):
61 self.require_root()
62 out = self.runcmd("smbcontrol self %s" % self.cmd)
63 out = self.runcmd("smbcontrol self %s spottyfoot" % self.cmd,
64 expectedResult = 1)
66 class ForceElection(NoArgCmdTest):
67 """Test a force-election message."""
68 def setup(self):
69 self.cmd = "force-election"
71 class SamSync(NoArgCmdTest):
72 """Test a samsync message."""
73 def setup(self):
74 self.cmd = "samsync"
76 class SamRepl(NoArgCmdTest):
77 """Test a samrepl message."""
78 def setup(self):
79 self.cmd = "samrepl"
81 class DmallocChanged(NoArgCmdTest):
82 """Test a dmalloc-changed message."""
83 def setup(self):
84 self.cmd = "dmalloc-log-changed"
86 class DmallocMark(NoArgCmdTest):
87 """Test a dmalloc-mark message."""
88 def setup(self):
89 self.cmd = "dmalloc-mark"
91 class Shutdown(NoArgCmdTest):
92 """Test a shutdown message."""
93 def setup(self):
94 self.cmd = "shutdown"
96 class Ping(NoArgCmdTest):
97 """Test a ping message."""
98 def setup(self):
99 self.cmd = "ping"
101 class Debuglevel(NoArgCmdTest):
102 """Test a debuglevel message."""
103 def setup(self):
104 self.cmd = "debuglevel"
106 class OneArgCmdTest(comfychair.TestCase):
107 """A test class that tests a command with one argument."""
108 def runtest(self):
109 self.require_root()
110 out = self.runcmd("smbcontrol self %s spottyfoot" % self.cmd)
111 out = self.runcmd("smbcontrol self %s" % self.cmd, expectedResult = 1)
113 class DrvUpgrade(OneArgCmdTest):
114 """Test driver upgrade message."""
115 def setup(self):
116 self.cmd = "drvupgrade"
118 class CloseShare(OneArgCmdTest):
119 """Test close share message."""
120 def setup(self):
121 self.cmd = "close-share"
123 class Debug(OneArgCmdTest):
124 """Test a debug message."""
125 def setup(self):
126 self.cmd = "debug"
128 class PrintNotify(comfychair.TestCase):
129 """Test print notification commands."""
130 def runtest(self):
132 # No subcommand
134 out = self.runcmd("smbcontrol self printnotify", expectedResult = 1)
135 self.assert_re_match("Must specify subcommand", out[1]);
137 # Invalid subcommand name
139 out = self.runcmd("smbcontrol self printnotify spottyfoot",
140 expectedResult = 1)
141 self.assert_re_match("Invalid subcommand", out[1]);
143 # Queue commands
145 for cmd in ["queuepause", "queueresume"]:
147 out = self.runcmd("smbcontrol self printnotify %s" % cmd,
148 expectedResult = 1)
149 self.assert_re_match("Usage:", out[1])
151 out = self.runcmd("smbcontrol self printnotify %s spottyfoot"
152 % cmd)
154 # Job commands
156 for cmd in ["jobpause", "jobresume", "jobdelete"]:
158 out = self.runcmd("smbcontrol self printnotify %s" % cmd,
159 expectedResult = 1)
160 self.assert_re_match("Usage:", out[1])
162 out = self.runcmd("smbcontrol self printnotify %s spottyfoot"
163 % cmd, expectedResult = 1)
164 self.assert_re_match("Usage:", out[1])
166 out = self.runcmd("smbcontrol self printnotify %s spottyfoot 123"
167 % cmd)
169 # Printer properties
171 out = self.runcmd("smbcontrol self printnotify printer",
172 expectedResult = 1)
173 self.assert_re_match("Usage", out[1])
175 out = self.runcmd("smbcontrol self printnotify printer spottyfoot",
176 expectedResult = 1)
177 self.assert_re_match("Usage", out[1])
179 for cmd in ["comment", "port", "driver"]:
181 out = self.runcmd("smbcontrol self printnotify printer spottyfoot "
182 "%s" % cmd, expectedResult = 1)
183 self.assert_re_match("Usage", out[1])
185 out = self.runcmd("smbcontrol self printnotify printer spottyfoot "
186 "%s value" % cmd)
188 class Profile(comfychair.TestCase):
189 """Test setting the profiling level."""
190 def runtest(self):
191 self.require_root()
192 out = self.runcmd("smbcontrol self profile", expectedResult = 1)
193 self.assert_re_match("Usage", out[1])
195 out = self.runcmd("smbcontrol self profile spottyfoot",
196 expectedResult = 1)
197 self.assert_re_match("Unknown", out[1])
199 for cmd in ["off", "count", "on", "flush"]:
200 out = self.runcmd("smbcontrol self profile %s" % cmd)
202 class ProfileLevel(comfychair.TestCase):
203 """Test requesting the current profiling level."""
204 def runtest(self):
205 self.require_root()
206 out = self.runcmd("smbcontrol self profilelevel spottyfoot",
207 expectedResult = 1)
208 self.assert_re_match("Usage", out[1])
210 out = self.runcmd("smbcontrol self profilelevel")
212 class TimeoutArg(comfychair.TestCase):
213 """Test the --timeout argument."""
214 def runtest(self):
215 out = self.runcmd("smbcontrol --timeout 5 self noop")
216 out = self.runcmd("smbcontrol --timeout spottyfoot self noop",
217 expectedResult = 1)
219 class ConfigFileArg(comfychair.TestCase):
220 """Test the --configfile argument."""
221 def runtest(self):
222 out = self.runcmd("smbcontrol --configfile /dev/null self noop")
224 class BogusArg(comfychair.TestCase):
225 """Test a bogus command line argument."""
226 def runtest(self):
227 out = self.runcmd("smbcontrol --bogus self noop", expectedResult = 1)
229 tests = [NoArgs, OneArg, SmbdDest, NmbdDest, WinbinddDest, PidDest,
230 SelfDest, BadDest, BadCmd, Debug, ForceElection, SamSync,
231 SamRepl, DmallocMark, DmallocChanged, Shutdown, DrvUpgrade,
232 CloseShare, Ping, Debuglevel, PrintNotify, Profile, ProfileLevel,
233 TimeoutArg, ConfigFileArg, BogusArg]
235 # Handle execution of this file as a main program
237 if __name__ == '__main__':
238 comfychair.main(tests)