Exemplo n.º 1
0
 def test_state_powershell(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers(
         'ps', os.getuid(), os.getgid(), '/tmp', 'print 1',
         {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, '$env:ENV_PARAM="VALUE"')
     self.assertEqual(suffix, '.ps1')
Exemplo n.º 2
0
 def test_state_ruby(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers(
         'ruby', os.getuid(), os.getgid(), '/tmp',
         '#!/usr/bin/ruby\nprint 1', {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, 'ENV["ENV_PARAM"]="VALUE"')
     self.assertEqual(suffix, '.rb')
Exemplo n.º 3
0
 def test_state_python(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers(
         'python', os.getuid(), os.getgid(), '/tmp',
         '#!/usr/bin/python\nprint 1', {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, '"ENV_PARAM": "VALUE"')
     self.assertEqual(suffix, '.py')
Exemplo n.º 4
0
 def test_state_powershell(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers('ps',
                                                os.getuid(),
                                                os.getgid(),
                                                '/tmp',
                                                'print 1',
                                                {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, '$env:ENV_PARAM="VALUE"')
     self.assertEqual(suffix, '.ps1')
Exemplo n.º 5
0
 def test_state_ruby(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers('ruby',
                                                os.getuid(),
                                                os.getgid(),
                                                '/tmp',
                                                '#!/usr/bin/ruby\nprint 1',
                                                {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, 'ENV["ENV_PARAM"]="VALUE"')
     self.assertEqual(suffix, '.rb')
Exemplo n.º 6
0
 def test_state_python(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers('python',
                                                os.getuid(),
                                                os.getgid(),
                                                '/tmp',
                                                '#!/usr/bin/python\nprint 1',
                                                {'ENV_PARAM': 'VALUE'})
     self.assertContains(command, '"ENV_PARAM": "VALUE"')
     self.assertEqual(suffix, '.py')
Exemplo n.º 7
0
 def test_state_bash(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers(
         'bash', os.getuid(), os.getgid(), '/tmp', '#!/bin/bash\necho 1', {
             'ENV_PARAM': 'VALUE',
             'INV-PARAM': 'some value',
             'LIST_VAL': ["1", "2"]
         })
     self.assertContains(command, 'ENV_PARAM="VALUE"')
     self.assertContains(command, 'LIST_VAL[0]="1"')
     self.assertContains(command, 'LIST_VAL[1]="2"')
     self.assertContainsNot(command, 'INV-PARAM=')
     self.assertEqual(suffix, '.sh')
Exemplo n.º 8
0
 def test_state_bash(self):
     s_man = StateManager()
     command, suffix, env = s_man.set_state_handlers('bash',
                                                os.getuid(),
                                                os.getgid(),
                                                '/tmp',
                                                '#!/bin/bash\necho 1',
                                                {'ENV_PARAM': 'VALUE',
                                                 'INV-PARAM': 'some value',
                                                 'LIST_VAL': ["1", "2"]
                                                 })
     self.assertContains(command, 'ENV_PARAM="VALUE"')
     self.assertContains(command, 'LIST_VAL[0]="1"')
     self.assertContains(command, 'LIST_VAL[1]="2"')
     self.assertContainsNot(command, 'INV-PARAM=')
     self.assertEqual(suffix, '.sh')
Exemplo n.º 9
0
 def __init__(self, as_user, work_dir=cloudrunner.TMP_DIR):
     self.state_manager = StateManager()
     self.as_user = as_user
     self.session_cwd = os.path.join(work_dir, uuid.uuid4().hex)
     os.makedirs(self.session_cwd)
     self.executor = Executor(as_user)