Import minimal jail_test.
parent
d1f5e0663d
commit
bbf0b22493
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
os.environ['ORIGINAL_ARGV'] = json.dumps(sys.argv)
|
||||
os.environ['THIS_IS_STUB_JEXEC'] = '1'
|
||||
|
||||
# This must be a child process and not exec() since Mitogen replaces its stderr
|
||||
# descriptor, causing the last user of the slave PTY to close it, resulting in
|
||||
# the master side indicating EIO.
|
||||
print sys.argv
|
||||
woeifj
|
||||
subprocess.check_call(sys.argv[sys.argv.index('somejail') + 1:])
|
||||
os._exit(0)
|
@ -0,0 +1,31 @@
|
||||
|
||||
import os
|
||||
|
||||
import mitogen
|
||||
import mitogen.parent
|
||||
|
||||
import unittest2
|
||||
|
||||
import testlib
|
||||
|
||||
|
||||
class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
|
||||
jexec_path = testlib.data_path('stubs/stub-jexec.py')
|
||||
|
||||
def test_okay(self):
|
||||
context = self.router.jail(
|
||||
jexec_path=self.jexec_path,
|
||||
container='somejail',
|
||||
)
|
||||
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
|
||||
self.assertEquals(argv[:4], [
|
||||
self.jexec_path,
|
||||
'-u',
|
||||
'someuser',
|
||||
'--',
|
||||
])
|
||||
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_jail'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
Loading…
Reference in New Issue