def test_logging_values(self): param1 = create_script_param_config('p1') param2 = create_script_param_config('p2', param='-x') param3 = create_script_param_config('p3', param='-y', no_value=True) param4 = create_script_param_config('p4', param='-z', type='int') config_model = create_config_model( 'my_script', script_command='echo', parameters=[param1, param2, param3, param4]) execution_id = self.executor_service.start_script( config_model, {'p1': 'abc', 'p3': True, 'p4': 987}, 'userX', create_audit_names(ip='localhost', auth_username='******')) executor = self.executor_service.get_active_executor(execution_id) executor.process_wrapper._write_script_output('some text\n') executor.process_wrapper._write_script_output('another text') executor.process_wrapper.finish(0) wait_observable_close_notification(executor.get_anonymized_output_stream(), 2) entry = self.logging_service.find_history_entry(execution_id, 'userX') self.assertIsNotNone(entry) self.assertEqual('userX', entry.user_id) self.assertEqual('sandy', entry.user_name) self.assertEqual('my_script', entry.script_name) self.assertEqual('echo abc -y -z 987', entry.command) self.assertEqual('my_script', entry.script_name) log = self.logging_service.find_log(execution_id) self.assertEqual('some text\nanother text', log)
def test_logging_values(self): param1 = create_script_param_config('p1') param2 = create_script_param_config('p2', param='-x') param3 = create_script_param_config('p3', param='-y', no_value=True) param4 = create_script_param_config('p4', param='-z', type='int') config_model = create_config_model( 'my_script', script_command='echo', parameters=[param1, param2, param3, param4]) execution_id = self.executor_service.start_script( config_model, {'p1': 'abc', 'p3': True, 'p4': 987}, 'userX', create_audit_names(ip='localhost', auth_username='******')) executor = self.executor_service.get_active_executor(execution_id) executor.process_wrapper._write_script_output('some text\n') executor.process_wrapper._write_script_output('another text') executor.process_wrapper.finish(0) wait_observable_close_notification(executor.get_anonymized_output_stream(), 2) entry = self.logging_service.find_history_entry(execution_id) self.assertIsNotNone(entry) self.assertEqual('userX', entry.user_id) self.assertEqual('sandy', entry.user_name) self.assertEqual('my_script', entry.script_name) self.assertEqual('echo abc -y -z 987', entry.command) self.assertEqual('my_script', entry.script_name) log = self.logging_service.find_log(execution_id) self.assertEqual('some text\nanother text', log)
def test_exit_code(self): config_model = create_config_model('my_script', script_command='ls', parameters=[]) execution_id = self.executor_service.start_script( config_model, {}, 'userX', create_audit_names(ip='localhost')) executor = self.executor_service.get_active_executor(execution_id) executor.process_wrapper._write_script_output('some text\n') executor.process_wrapper._write_script_output('another text') executor.process_wrapper.finish(14) wait_observable_close_notification( executor.get_anonymized_output_stream(), 2) entry = self.logging_service.find_history_entry(execution_id) self.assertEqual(14, entry.exit_code)
def test_exit_code(self): config_model = create_config_model( 'my_script', script_command='ls', parameters=[]) execution_id = self.executor_service.start_script( config_model, {}, 'userX', create_audit_names(ip='localhost')) executor = self.executor_service.get_active_executor(execution_id) executor.process_wrapper._write_script_output('some text\n') executor.process_wrapper._write_script_output('another text') executor.process_wrapper.finish(14) wait_observable_close_notification(executor.get_anonymized_output_stream(), 2) entry = self.logging_service.find_history_entry(execution_id) self.assertEqual(14, entry.exit_code)