274 |
274 |
return "Executing command '%s' failed" % cmd
|
275 |
275 |
|
276 |
276 |
|
277 |
|
class TestRunRemoteCommand(unittest.TestCase):
|
|
277 |
class TestRunRestrictedCmd(unittest.TestCase):
|
278 |
278 |
def setUp(self):
|
279 |
279 |
self.tmpdir = tempfile.mkdtemp()
|
280 |
280 |
|
... | ... | |
286 |
286 |
sleep_fn = testutils.CallCounter(_SleepForRemoteCommand)
|
287 |
287 |
self.assertFalse(os.path.exists(lockfile))
|
288 |
288 |
self.assertRaises(backend.RPCFail,
|
289 |
|
backend.RunRemoteCommand, "test",
|
|
289 |
backend.RunRestrictedCmd, "test",
|
290 |
290 |
_lock_timeout=NotImplemented,
|
291 |
291 |
_lock_file=lockfile,
|
292 |
292 |
_path=NotImplemented,
|
... | ... | |
302 |
302 |
|
303 |
303 |
result = False
|
304 |
304 |
try:
|
305 |
|
backend.RunRemoteCommand("test22717",
|
|
305 |
backend.RunRestrictedCmd("test22717",
|
306 |
306 |
_lock_timeout=0.1,
|
307 |
307 |
_lock_file=lockfile,
|
308 |
308 |
_path=NotImplemented,
|
... | ... | |
341 |
341 |
prepare_fn = testutils.CallCounter(self._PrepareRaisingException)
|
342 |
342 |
|
343 |
343 |
try:
|
344 |
|
backend.RunRemoteCommand("test23122",
|
|
344 |
backend.RunRestrictedCmd("test23122",
|
345 |
345 |
_lock_timeout=1.0, _lock_file=lockfile,
|
346 |
346 |
_path=NotImplemented, _runcmd_fn=NotImplemented,
|
347 |
347 |
_sleep_fn=sleep_fn, _prepare_fn=prepare_fn,
|
... | ... | |
366 |
366 |
prepare_fn = testutils.CallCounter(self._PrepareFails)
|
367 |
367 |
|
368 |
368 |
try:
|
369 |
|
backend.RunRemoteCommand("test29327",
|
|
369 |
backend.RunRestrictedCmd("test29327",
|
370 |
370 |
_lock_timeout=1.0, _lock_file=lockfile,
|
371 |
371 |
_path=NotImplemented, _runcmd_fn=NotImplemented,
|
372 |
372 |
_sleep_fn=sleep_fn, _prepare_fn=prepare_fn,
|
... | ... | |
417 |
417 |
runcmd_fn = testutils.CallCounter(fn)
|
418 |
418 |
|
419 |
419 |
try:
|
420 |
|
backend.RunRemoteCommand("test3079",
|
|
420 |
backend.RunRestrictedCmd("test3079",
|
421 |
421 |
_lock_timeout=1.0, _lock_file=lockfile,
|
422 |
422 |
_path=self.tmpdir, _runcmd_fn=runcmd_fn,
|
423 |
423 |
_sleep_fn=sleep_fn, _prepare_fn=prepare_fn,
|
... | ... | |
454 |
454 |
prepare_fn = testutils.CallCounter(self._SuccessfulPrepare)
|
455 |
455 |
runcmd_fn = testutils.CallCounter(fn)
|
456 |
456 |
|
457 |
|
result = backend.RunRemoteCommand("test5667",
|
|
457 |
result = backend.RunRestrictedCmd("test5667",
|
458 |
458 |
_lock_timeout=1.0, _lock_file=lockfile,
|
459 |
459 |
_path=self.tmpdir, _runcmd_fn=runcmd_fn,
|
460 |
460 |
_sleep_fn=sleep_fn,
|
... | ... | |
468 |
468 |
|
469 |
469 |
def testCommandsDisabled(self):
|
470 |
470 |
try:
|
471 |
|
backend.RunRemoteCommand("test",
|
|
471 |
backend.RunRestrictedCmd("test",
|
472 |
472 |
_lock_timeout=NotImplemented,
|
473 |
473 |
_lock_file=NotImplemented,
|
474 |
474 |
_path=NotImplemented,
|