Example #1
0
    def testHelpMessage(self):
        """test the universal --help Option"""
        helper = end_to_end_test_helper.EndToEndTestHelper(
            'not needed', 'not needed')

        if platform.system() in ['Linux']:
            message_help = (
                'Usage: main.py [OPTIONS] COMMAND [ARGS]...\r\n\r\n'
                'Options:\r\n'
                '  --help  Show this message and exit.\r\n\r\n'
                'Commands:\r\n'
                '  sqlite')
            command = 'python {0} --help'.format(helper.MAIN_PATH)
            child = pexpect.spawn(command)
            child.expect_exact(message_help)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
Example #2
0
    def testHelpMessageForSQLitePlugin(self):
        """test the --help option for SQLite"""
        helper = end_to_end_test_helper.EndToEndTestHelper(
            'not needed', 'not needed')

        if platform.system() in ['Linux']:
            message_help = (
                'Usage: main.py sqlite [OPTIONS]\r\n\r\n'
                'Options:\r\n  '
                '--path TEXT       The path to plaso\r\n  '
                '--name TEXT       The plugin name\r\n  '
                '--testfile TEXT   The testfile path\r\n  '
                '--sql / --no-sql  The output example flag for the SQL Query for the '
                'plugin.\r\n  '
                '--help            Show this message and exit.')

            command = 'python {0} sqlite --help'.format(helper.MAIN_PATH)
            child = pexpect.spawn(command)
            child.expect_exact(message_help)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
  def testWrongSQLQueryInput(self):
    """Test easy file generation without errors

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from user
    7.  Error: no such table: user
    8.  Please write your SQL script for the plugin: select * from users;
        select * from users
    9.  Warning: You can only execute one statement at a time.
    10. Please write your SQL script for the plugin: drop table users
    11. Query has to be a single SELECT query.
    12. Please write your SQL script for the plugin ['abort' to continue]:
        select * from users
    13. The SQL query was ok.
    14. Do you want to name the query parse row: Users ? [Y/n]:  Y
    15. Is the column a time event? updatedAt [Y/n]:  Y
    16. Is the column a time event? createdDate [Y/n]: Y
    17. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    18. Does the event Users need customizing? [y/N]: N
    19. Do you want to add another Query? [Y/n]: y
    20. Please write your SQL script for the plugin ['abort' to continue]: abort
    21. Do you want to Generate the files [Y/n]: Y
    """
    if platform.system() in ['Linux']:

      with tempfile.TemporaryDirectory() as tmpdir:
        helper = end_to_end_test_helper.EndToEndTestHelper(tmpdir, 'test')

        path_answer = tmpdir
        expected_path = os.path.join(helper.DIR_PATH,
                                     'ExpectedEasyGenerationFiles')

        command = 'python {0} sqlite'.format(helper.MAIN_PATH)
        child = pexpect.spawn(command)

        child.expect(helper.PATH_QUESTION)
        child.sendline(path_answer)
        child.expect(path_answer)

        child.expect(helper.NAME_QUESTION)
        child.sendline(helper.NAME_ANSWER)
        child.expect(helper.NAME_ANSWER)

        child.expect(helper.TESTFILE_QUESTION)
        child.sendline(helper.TESTFILE_ANSWER)
        child.expect(helper.TESTFILE_ANSWER)

        child.expect(helper.OUTPUT_QUESTION)
        child.sendline(helper.COLUMN_ANSWER_NO)
        child.expect(helper.COLUMN_ANSWER_NO)

        child.expect(helper.SQL_QUESTION)
        child.sendline('select * from user')
        child.expect('select \* from user')
        child.expect('Error\: no such table\: user')

        child.expect(helper.SQL_QUESTION)
        child.sendline('select * from users; select * from users')
        child.expect('select \* from users\; select \* from users')
        child.expect('Warning\: You can only execute one statement at a time\.')

        child.expect(helper.SQL_QUESTION)
        child.sendline('drop table users')
        child.expect('drop table users')
        child.expect('Query has to be a single SELECT query\.')

        child.expect(helper.SQL_QUESTION)
        child.sendline(helper.SQL_ANSWER)
        child.expect(helper.SQL_ANSWER_ESCAPED)
        child.expect(helper.SQL_ANSWER_OK)

        child.expect(helper.NAME_ROW_QUESTION_USERS)
        child.sendline(helper.NAME_ROW_ANSWER_YES)
        child.expect(helper.NAME_ROW_ANSWER_YES)

        child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
        child.sendline(helper.COLUMN_ANSWER_YES)
        child.expect(helper.COLUMN_ANSWER_YES)

        child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
        child.sendline(helper.COLUMN_ANSWER_YES)
        child.expect(helper.COLUMN_ANSWER_YES)

        child.expect(helper.ADDITIONAL_TIMESTAMP)
        child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
        child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

        child.expect(helper.CUSTOM_QUESTION_USERS)
        child.sendline(helper.CUSTOM_ANSWER_NO)
        child.expect(helper.CUSTOM_ANSWER_NO)

        child.expect(helper.ADD_QUESTION)
        child.sendline(helper.ADD_ANSWER_YES)
        child.expect(helper.ADD_ANSWER_YES)

        child.expect(helper.SQL_QUESTION_WITH_ABORT)
        child.sendline('abort')
        child.expect('abort')

        child.expect(helper.GENERATE_QUESTION)
        child.sendline(helper.GENERATE_ANSWER_YES)

        child.expect('create.*{0}'.format(helper.formatter_path))
        child.expect('create.*{0}'.format(helper.parser_path))
        child.expect('create.*{0}'.format(helper.formatter_test_path))
        child.expect('create.*{0}'.format(helper.parser_test_path))
        child.expect('copy.*{0}'.format(helper.test_data_path))
        child.expect('create.*{0}'.format(helper.parsers_init_path))
        child.expect('create.*{0}'.format(helper.formatter_init_path))

        formatter_init = helper.ReadFromFile(helper.formatter_init_path)
        formatter = helper.ReadFromFile(helper.formatter_path)
        formatter_test = helper.ReadFromFile(helper.formatter_test_path)
        parser_init = helper.ReadFromFile(helper.parsers_init_path)
        parser = helper.ReadFromFile(helper.parser_path)
        parser_test = helper.ReadFromFile(helper.parser_test_path)

        expected_formatter_init = helper.ReadFromFile(os.path.join(
            expected_path, 'formatters_init.py'))
        expected_formatter = helper.ReadFromFile(
            os.path.join(expected_path, 'formatters.py'))
        expected_formatter_test = helper.ReadFromFile(os.path.join(
            expected_path, 'formatters_test.py'))
        expected_parser_init = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers_init.py'))
        expected_parser = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers.py'))
        expected_parser_test = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers_test.py'))

        self.assertEqual(formatter_init, expected_formatter_init)
        self.assertEqual(formatter, expected_formatter)
        self.assertEqual(formatter_test, expected_formatter_test)
        self.assertEqual(parser_init, expected_parser_init)
        self.assertEqual(parser, expected_parser)
        self.assertEqual(parser_test, expected_parser_test)
    else:
      raise NotImplementedError("test only implemented for linux platform")
Example #4
0
    def testWrongPath(self):
        """Test easy file generation with using the wrong path

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?:bla bla
    3.  Folder does not exists. Enter correct one: other/wrong
    4.  Folder does not exists. Enter correct one: tmpdir
    5.  What's the name of the plugin?: test
    6.  What's the path to your test file?: [pfad_file]
    7.  Do you want to have a output example for your SQL Query? [Y/n]: n
    8.  Please write your SQL script for the plugin: select * from users
    9.  The SQL query was ok.
    10. Do you want to name the query parse row: Users ? [Y/n]:  Y
    11. Is the column a time event? updatedAt [Y/n]:  Y
    12. Is the column a time event? createdDate [Y/n]: Y
    13. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    14. Does the event Users need customizing? [y/N]: N
    15. Do you want to add another Query? [Y/n]: n
    16. Do you want to Generate the files [Y/n]: Y
    """
        if platform.system() in ['Linux']:

            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(helper.DIR_PATH,
                                             'ExpectedEasyGenerationFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline('bla bla')
                child.expect('bla bla')

                child.expect(helper.PATH_WRONG_QUESTION)
                child.sendline('other/wrong')
                child.expect('other/wrong')

                child.expect(helper.PATH_WRONG_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
Example #5
0
    def testEasyGenerationWithOwnRowName(self):
        """Test easy file generation without errors

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]:  n
    9.  What row does the SQL Query parse?: The User
        11. Row name is not in a valid format. Choose new Name [RowName...]:
        theuser
    11. Row name is not in a valid format. Choose new Name [RowName...]:
        TheUser123
    12. Row name is not in a valid format. Choose new Name [RowName...]: TheUser
    13. Is the column a time event? updatedAt [Y/n]:  Y
    14. Is the column a time event? createdDate [Y/n]: Y
    15. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    16. Does the event The User need customizing? [y/N]: N
    17. Do you want to add another Query? [Y/n]: n
    18. Do you want to Generate the files [Y/n]: Y
    """
        if platform.system() in ['Linux']:

            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(
                    helper.DIR_PATH, 'ExpectedEasyGenerationRowNameFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_NO)
                child.expect(helper.NAME_ROW_ANSWER_NO)

                child.expect(helper.NAME_ROW_QUESTION_QUERY)
                child.sendline('The User')
                child.expect('The User')

                child.expect(helper.NAME_ROW_QUESTION_INVALID)
                child.sendline('theuser')
                child.expect('theuser')

                child.expect(helper.NAME_ROW_QUESTION_INVALID)
                child.sendline('TheUser123')
                child.expect('TheUser123')

                child.expect(helper.NAME_ROW_QUESTION_INVALID)
                child.sendline('TheUser')
                child.expect('TheUser')

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_THEUSER)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
    def testEasyGenerationWithExistingName(self):
        """Test easy file generation without errors

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]:  Y
    9.  Is the column a time event? updatedAt [Y/n]:  Y
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    12. Does the event Users need customizing? [y/N]: N
    13. Do you want to add another Query? [Y/n]: n
    14. Do you want to Generate the files [Y/n]: y
    15.  plasoscaffolder sqlite
    16.  What's the path to the plaso project?: tmpdir
    17. What's the name of the plugin?: test
    18. Plugin exists. Choose new Name: test_plugin
    19.  What's the path to your test file?: test_database/twitter_ios.db
    20. Do you want to have a output example for your SQL Query? [Y/n]: n
    21. Please write your SQL script for the plugin: select * from users
    22. The SQL query was ok.
    23. Do you want to name the query parse row: Users ? [Y/n]: Y
    24. Is the column a time event? updatedAt [Y/n]:  Y
    25. Is the column a time event? createdDate [Y/n]: Y
    26. Enter (additional) timestamp events from the query
        [column-Name,aliasName...] or [abort]: abort
    27. Does the event Users need customizing? [y/N]: N
    28. Do you want to add another Query? [Y/n]: n
    29. Do you want to Generate the files [Y/n]: Y
    """
        if platform.system() in ['Linux']:
            with tempfile.TemporaryDirectory() as tmpdir:

                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')
                path_answer = tmpdir

                expected_path = os.path.join(helper.DIR_PATH,
                                             'ExpectedEasyGenerationFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                helper_second_plugin = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test_plugin')
                expected_path_second_plugin = os.path.join(
                    helper_second_plugin.DIR_PATH, 'ExpectedTwoPluginsFiles')
                command = 'python {0} sqlite'.format(
                    helper_second_plugin.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper_second_plugin.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper_second_plugin.NAME_QUESTION)
                child.sendline(helper_second_plugin.NAME_ANSWER)
                child.expect(helper_second_plugin.NAME_ANSWER)

                child.expect(helper_second_plugin.NAME_QUESTION_EXISTS)
                child.sendline('test_plugin')
                child.expect('test_plugin')

                child.expect(helper_second_plugin.TESTFILE_QUESTION)
                child.sendline(helper_second_plugin.TESTFILE_ANSWER)
                child.expect(helper_second_plugin.TESTFILE_ANSWER)

                child.expect(helper_second_plugin.OUTPUT_QUESTION)
                child.sendline(helper_second_plugin.COLUMN_ANSWER_NO)
                child.expect(helper_second_plugin.COLUMN_ANSWER_NO)

                child.expect(helper_second_plugin.SQL_QUESTION)
                child.sendline(helper_second_plugin.SQL_ANSWER)
                child.expect(helper_second_plugin.SQL_ANSWER_ESCAPED)
                child.expect(helper_second_plugin.SQL_ANSWER_OK)

                child.expect(helper_second_plugin.NAME_ROW_QUESTION_USERS)
                child.sendline(helper_second_plugin.NAME_ROW_ANSWER_YES)
                child.expect(helper_second_plugin.NAME_ROW_ANSWER_YES)

                child.expect(helper_second_plugin.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper_second_plugin.COLUMN_ANSWER_YES)
                child.expect(helper_second_plugin.COLUMN_ANSWER_YES)

                child.expect(helper_second_plugin.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper_second_plugin.COLUMN_ANSWER_YES)
                child.expect(helper_second_plugin.COLUMN_ANSWER_YES)

                child.expect(helper_second_plugin.ADDITIONAL_TIMESTAMP)
                child.sendline(helper_second_plugin.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper_second_plugin.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper_second_plugin.CUSTOM_QUESTION_USERS)
                child.sendline(helper_second_plugin.CUSTOM_ANSWER_NO)
                child.expect(helper_second_plugin.CUSTOM_ANSWER_NO)

                child.expect(helper_second_plugin.ADD_QUESTION)
                child.sendline(helper_second_plugin.ADD_ANSWER_NO)
                child.expect(helper_second_plugin.ADD_ANSWER_NO)

                child.expect(helper_second_plugin.GENERATE_QUESTION)
                child.sendline(helper_second_plugin.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(
                    helper_second_plugin.formatter_path))
                child.expect('create.*{0}'.format(
                    helper_second_plugin.parser_path))
                child.expect('create.*{0}'.format(
                    helper_second_plugin.formatter_test_path))
                child.expect('create.*{0}'.format(
                    helper_second_plugin.parser_test_path))
                child.expect('copy.*{0}'.format(
                    helper_second_plugin.test_data_path))
                child.expect('edit.*{0}'.format(
                    helper_second_plugin.parsers_init_path))
                child.expect('edit.*{0}'.format(
                    helper_second_plugin.formatter_init_path))

                formatter_init_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.formatter_init_path)
                formatter_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.formatter_path)
                formatter_test_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.formatter_test_path)
                parser_init_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.parsers_init_path)
                parser_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.parser_path)
                parser_test_second_plugin = helper_second_plugin.ReadFromFile(
                    helper_second_plugin.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                expected_formatter_first_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin,
                                 'formatters1.py'))
                expected_formatter_test_first_plugin = \
                  helper_second_plugin.ReadFromFile(
                      os.path.join(
                          expected_path_second_plugin, 'formatters_test1.py'))
                expected_parser_first_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin, 'parsers1.py'))
                expected_parser_test_first_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin,
                                 'parsers_test1.py'))

                expected_formatter_init_second_plugin = \
                  helper_second_plugin.ReadFromFile(
                      os.path.join(
                          expected_path_second_plugin, 'formatters_init.py'))
                expected_formatter_second_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin,
                                 'formatters2.py'))
                expected_formatter_test_second_plugin = \
                  helper_second_plugin.ReadFromFile(
                      os.path.join(
                          expected_path_second_plugin, 'formatters_test2.py'))
                expected_parser_init_second_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin,
                                 'parsers_init.py'))
                expected_parser_second_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin, 'parsers2.py'))
                expected_parser_test_second_plugin = helper_second_plugin.ReadFromFile(
                    os.path.join(expected_path_second_plugin,
                                 'parsers_test2.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)

                self.assertEqual(formatter_init_second_plugin,
                                 expected_formatter_init_second_plugin)
                self.assertEqual(formatter_second_plugin,
                                 expected_formatter_second_plugin)
                self.assertEqual(formatter_test_second_plugin,
                                 expected_formatter_test_second_plugin)
                self.assertEqual(parser_init_second_plugin,
                                 expected_parser_init_second_plugin)
                self.assertEqual(parser_second_plugin,
                                 expected_parser_second_plugin)
                self.assertEqual(parser_test_second_plugin,
                                 expected_parser_test_second_plugin)
                self.assertEqual(formatter, expected_formatter_first_plugin)
                self.assertEqual(formatter_test,
                                 expected_formatter_test_first_plugin)
                self.assertEqual(parser, expected_parser_first_plugin)
                self.assertEqual(parser_test,
                                 expected_parser_test_first_plugin)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
Example #7
0
    def testSelectEasyJoin(self):
        """Test file generation with a join query and invalid input

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users join
        statuses
    7.  Please use an alias (AS) for those column names: id updatedAt
    8.  Please write your SQL script for the plugin: select id as userid join
        statuses
    9.  Error: near "join": syntax error
    10. Please write your SQL script for the plugin: select id as userid from
        users join statuses
    11. Error: ambiguous column name: id
    12. Please write your SQL script for the plugin: select users.id as
        userid from users join statuses
    13. The SQL query was ok.
    14. Do you want to name the query parse row: Usersstatuses? [Y/n]:  Y
    15. Is the column a time event? updatedAt [Y/n]:  Y
    16. Is the column a time event? createdDate [Y/n]: Y
    17. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    18. Does the event Users need customizing? [y/N]: N
    19. Do you want to add another Query? [Y/n]: N
    20. Do you want to Generate the files [Y/n]: Y



    """
        if platform.system() in ['Linux']:
            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(helper.DIR_PATH,
                                             'ExpectedWithJoinFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline('select * from users join statuses')
                child.expect('select \* from users join statuses')
                child.expect(
                    'Please use an alias \(AS\) for those column names\: '
                    'id updatedAt')

                child.expect(helper.SQL_QUESTION)
                child.sendline('select id as userid join statuses')
                child.expect('select id as userid join statuses')
                child.expect('Error\: near \"join\"\: syntax error')

                child.expect(helper.SQL_QUESTION)
                child.sendline('select id as userid from users join statuses')
                child.expect('select id as userid from users join statuses')
                child.expect('Error\: ambiguous column name\: id')

                child.expect(helper.SQL_QUESTION)
                child.sendline(
                    'select users.id as user_id , users.updatedAt as updatedAt,'
                    ' createdDate from users join statuses')
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERSSTATUSES)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERSSTATUSES)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)
                child.expect(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
    def testEasyGenerationWithOutputExample(self):
        """Test easy file generation without errors and with an output example

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: [pfad]
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: [pfad_file]
    5.  Do you want to have a output example for your SQL Query? [Y/n]: Y
    6.  Please write your SQL script for the plugin: select id, name,
        createdDate from users
    7.  Your query output could look like this.
        ['id', 'name']
        (5402612, 'BBC Breaking News')
        (13334762, 'GitHub')
        (14388264, 'Tom Pohl')
    8.  Do you want to add this query? [Y/n]: Y
    9.  Do you want to name the query parse row: Users ? [Y/n]:  Y
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    12. Does the event Users need customizing? [y/N]: N
    13. Do you want to add another Query? [Y/n]: n

    """
        if platform.system() in ['Linux']:

            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(
                    helper.DIR_PATH, 'ExpectedEasyGenerationWithOutputFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.OUTPUT_ANSWER_YES)
                child.expect(helper.OUTPUT_ANSWER_YES)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER_ID_NAME)
                child.expect(helper.SQL_ANSWER_ESCAPED_ID_NAME)
                child.expect(helper.OUTPUT_EXAMPLE_FIRST_ROW)
                child.expect(helper.OUTPUT_USERS_ID_NAME_EXAMPLE_HEADER)
                child.expect(helper.OUTPUT_USERS_ID_EXAMPLE_FIRST_ROW)
                child.expect(helper.OUTPUT_USERS_ID_EXAMPLE_SECOND_ROW)
                child.expect(helper.OUTPUT_USERS_ID_EXAMPLE_THIRD_ROW)

                child.expect(helper.OUTPUT_ADD_QUESTION)
                child.sendline(helper.OUTPUT_ADD_ANSWER_YES)
                child.expect(helper.OUTPUT_ADD_ANSWER_YES)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
  def testEasyGenerationWithAbort(self):
    """Test easy file generation without errors and with abort at the end, not
    generating the files.

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]:  Y
    9.  Is the column a time event? updatedAt [Y/n]:  Y
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    12. Does the event Users need customizing? [y/N]: N
    13. Do you want to add another Query? [Y/n]: n
    14. Do you want to Generate the files [Y/n]: n
    """
    if platform.system() in ['Linux']:

      with tempfile.TemporaryDirectory() as tmpdir:
        helper = end_to_end_test_helper.EndToEndTestHelper(tmpdir, 'test')
        path_answer = tmpdir

        command = 'python {0} sqlite'.format(helper.MAIN_PATH)
        child = pexpect.spawn(command)

        child.expect(helper.PATH_QUESTION)
        child.sendline(path_answer)
        child.expect(path_answer)

        child.expect(helper.NAME_QUESTION)
        child.sendline(helper.NAME_ANSWER)
        child.expect(helper.NAME_ANSWER)

        child.expect(helper.TESTFILE_QUESTION)
        child.sendline(helper.TESTFILE_ANSWER)
        child.expect(helper.TESTFILE_ANSWER)

        child.expect(helper.OUTPUT_QUESTION)
        child.sendline(helper.OUTPUT_ANSWER_NO)
        child.expect(helper.OUTPUT_ANSWER_NO)

        child.expect(helper.SQL_QUESTION)
        child.sendline(helper.SQL_ANSWER)
        child.expect(helper.SQL_ANSWER_ESCAPED)
        child.expect(helper.SQL_ANSWER_OK)

        child.expect(helper.NAME_ROW_QUESTION_USERS)
        child.sendline(helper.NAME_ROW_ANSWER_YES)
        child.expect(helper.NAME_ROW_ANSWER_YES)

        child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
        child.sendline(helper.COLUMN_ANSWER_NO)
        child.expect(helper.COLUMN_ANSWER_NO)

        child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
        child.sendline(helper.COLUMN_ANSWER_YES)
        child.expect(helper.COLUMN_ANSWER_YES)

        child.expect(helper.ADDITIONAL_TIMESTAMP)
        child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
        child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

        child.expect(helper.CUSTOM_QUESTION_USERS)
        child.sendline(helper.CUSTOM_ANSWER_NO)
        child.expect(helper.CUSTOM_ANSWER_NO)

        child.expect(helper.ADD_QUESTION)
        child.sendline(helper.ADD_ANSWER_NO)
        child.expect(helper.ADD_ANSWER_NO)

        child.expect(helper.GENERATE_QUESTION)
        child.sendline(helper.GENERATE_ANSWER_NO)
        child.expect('Aborted\!')

        formatter_init = os.path.isfile(helper.formatter_init_path)
        formatter = os.path.isfile(helper.formatter_path)
        formatter_test = os.path.isfile(helper.formatter_test_path)
        parser_init = os.path.isfile(helper.parsers_init_path)
        parser = os.path.isfile(helper.parser_path)
        parser_test = os.path.isfile(helper.parser_test_path)

        self.assertFalse(formatter_init)
        self.assertFalse(formatter)
        self.assertFalse(formatter_test)
        self.assertFalse(parser_init)
        self.assertFalse(parser)
        self.assertFalse(parser_test)
    else:
      raise NotImplementedError("test only implemented for linux platform")
    def testEasyGenerationWithMultipleSelects(self):
        """Test easy file generation without errors with two select queries

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]:  Y
    9.  Is the column a time event? updatedAt [Y/n]:  Y
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    12. Does the event Users need customizing? [y/N]: N
    13. Do you want to add another Query? [Y/n]: Y
    14. Please write your SQL script for the plugin: select * from statuses
    15. The SQL query was ok.
    16. Do you want to name the query parse row: Statuses ? [Y/n]:  Y
    17. Is the column a time event? date [Y/n]:  Y
    18. Is the column a time event? updatedAt [Y/n]: Y
    19. Is the column a time event? includeInProfileTimeline [Y/n]: N
    20. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    21. Does the event Users need customizing? [y/N]: N
    22. Do you want to add another Query? [Y/n]: Y
    23. Please write your SQL script for the plugin ['abort' to continue]: abort
    24. Do you want to Generate the files [Y/n]: Y

    """
        if platform.system() in ['Linux']:

            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(
                    helper.DIR_PATH,
                    'ExpectedEasyGenerationMultipleSelectsFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_YES)
                child.expect(helper.ADD_ANSWER_YES)

                child.expect(helper.SQL_QUESTION_WITH_ABORT)
                child.sendline(helper.SQL_ANSWER_2)
                child.expect(helper.SQL_ANSWER_ESCAPED_2)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_STATUSES)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_PROFILE_TIMELINE)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_STATUSES)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_YES)
                child.expect(helper.ADD_ANSWER_YES)

                child.expect(helper.SQL_QUESTION_WITH_ABORT)
                child.sendline('abort')
                child.expect('abort')

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")
  def testEasyGenerationWithOwnTimeEvent(self):
    """Test easy file generation without errors

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]: Y
    9.  Is the column a time event? updatedAt [Y/n]:  n
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: id that this
    12. Timestamps are not in valid format. Reenter them correctly [name,
        name...]: id, that, this
    13. Timestamps are not in valid format. Reenter them correctly [name,
        name...]:id,that,this
    14. Added: createdDate,id
        Failed: that,this
    15. Do you want to add more timestamps? [y/N]: y
    16. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: name,that
    17. Added: createdDate,id,name
    18. Failed: that,this
    19. Do you want to add more timestamps? [y/N]: n
    20. Does the event Users need customizing? [y/N]: N
    21. Do you want to add another Query? [Y/n]: n
    22. Do you want to Generate the files [Y/n]: Y

    """
    if platform.system() in ['Linux']:
      with tempfile.TemporaryDirectory() as tmpdir:
        helper = end_to_end_test_helper.EndToEndTestHelper(tmpdir, 'test')

        path_answer = tmpdir
        expected_path = os.path.join(helper.DIR_PATH,
                                     'ExpectedEasyGenerationOwnTimestampFiles')

        command = 'python {0} sqlite'.format(helper.MAIN_PATH)
        child = pexpect.spawn(command)

        child.expect(helper.PATH_QUESTION)
        child.sendline(path_answer)
        child.expect(path_answer)

        child.expect(helper.NAME_QUESTION)
        child.sendline(helper.NAME_ANSWER)
        child.expect(helper.NAME_ANSWER)

        child.expect(helper.TESTFILE_QUESTION)
        child.sendline(helper.TESTFILE_ANSWER)
        child.expect(helper.TESTFILE_ANSWER)

        child.expect(helper.OUTPUT_QUESTION)
        child.sendline(helper.COLUMN_ANSWER_NO)
        child.expect(helper.COLUMN_ANSWER_NO)

        child.expect(helper.SQL_QUESTION)
        child.sendline(helper.SQL_ANSWER)
        child.expect(helper.SQL_ANSWER_ESCAPED)
        child.expect(helper.SQL_ANSWER_OK)

        child.expect(helper.NAME_ROW_QUESTION_USERS)
        child.sendline(helper.NAME_ROW_ANSWER_YES)
        child.expect(helper.NAME_ROW_ANSWER_YES)

        child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
        child.sendline(helper.COLUMN_ANSWER_YES)
        child.expect(helper.COLUMN_ANSWER_YES)

        child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
        child.sendline(helper.COLUMN_ANSWER_YES)
        child.expect(helper.COLUMN_ANSWER_YES)

        child.expect(helper.ADDITIONAL_TIMESTAMP)
        child.sendline('id that this')
        child.expect('id that this')

        child.expect(helper.ADDITIONAL_TIMESTAMP_INVALID)
        child.sendline('id, that, this')
        child.expect('id\, that\, this')

        child.expect(helper.ADDITIONAL_TIMESTAMP_INVALID)
        child.sendline('id,that,this')
        child.expect('id\,that\,this')
        child.expect('Added\: createdDate\,id')
        child.expect('Failed\: that\,this')

        child.expect(helper.MORE_TIMESTAMPS_QUESTION)
        child.sendline(helper.MORE_TIMESTAMPS_ANSWER_YES)

        child.expect(helper.ADDITIONAL_TIMESTAMP)
        child.sendline('name,that')
        child.expect('name\,that')
        child.expect('Added\: createdDate\,id\,name')
        child.expect('Failed\: that\,this')

        child.expect(helper.MORE_TIMESTAMPS_QUESTION)
        child.sendline(helper.MORE_TIMESTAMPS_ANSWER_NO)

        child.expect(helper.CUSTOM_QUESTION_USERS)
        child.sendline(helper.CUSTOM_ANSWER_NO)
        child.expect(helper.CUSTOM_ANSWER_NO)

        child.expect(helper.ADD_QUESTION)
        child.sendline(helper.ADD_ANSWER_NO)
        child.expect(helper.ADD_ANSWER_NO)

        child.expect(helper.GENERATE_QUESTION)
        child.sendline(helper.GENERATE_ANSWER_YES)

        child.expect('create.*{0}'.format(helper.formatter_path))
        child.expect('create.*{0}'.format(helper.parser_path))
        child.expect('create.*{0}'.format(helper.formatter_test_path))
        child.expect('create.*{0}'.format(helper.parser_test_path))
        child.expect('copy.*{0}'.format(helper.test_data_path))
        child.expect('create.*{0}'.format(helper.parsers_init_path))
        child.expect('create.*{0}'.format(helper.formatter_init_path))

        formatter_init = helper.ReadFromFile(helper.formatter_init_path)
        formatter = helper.ReadFromFile(helper.formatter_path)
        formatter_test = helper.ReadFromFile(helper.formatter_test_path)
        parser_init = helper.ReadFromFile(helper.parsers_init_path)
        parser = helper.ReadFromFile(helper.parser_path)
        parser_test = helper.ReadFromFile(helper.parser_test_path)

        expected_formatter_init = helper.ReadFromFile(os.path.join(
            expected_path, 'formatters_init.py'))
        expected_formatter = helper.ReadFromFile(
            os.path.join(expected_path, 'formatters.py'))
        expected_formatter_test = helper.ReadFromFile(os.path.join(
            expected_path, 'formatters_test.py'))
        expected_parser_init = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers_init.py'))
        expected_parser = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers.py'))
        expected_parser_test = helper.ReadFromFile(
            os.path.join(expected_path, 'parsers_test.py'))

        self.assertEqual(formatter_init, expected_formatter_init)
        self.assertEqual(formatter, expected_formatter)
        self.assertEqual(formatter_test, expected_formatter_test)
        self.assertEqual(parser_init, expected_parser_init)
        self.assertEqual(parser, expected_parser)
        self.assertEqual(parser_test, expected_parser_test)
    else:
      raise NotImplementedError("test only implemented for linux platform")
Example #12
0
    def testSelectWithSpecialCharacters(self):
        """Test different queries with special characters

    1.  plasoscaffolder sqlite
    2.  What's the path to the plaso project?: tmpdir
    3.  What's the name of the plugin?: test
    4.  What's the path to your test file?: test_database/twitter_ios.db
    5.  Do you want to have a output example for your SQL Query? [Y/n]: n
    6.  Please write your SQL script for the plugin: select users.id as
        “userid” from users join statuses
    7.  Info: Don’t use any characters beside a-z A-Z . ; , *
    8.  Please write your SQL script for the plugin: select hex(id) from users
    9.  Warning: Don’t use any characters beside a-z A-Z . ; , *
    10. Please write your SQL script for the plugin: select [AS].[ID] AS [the
        alias], [AS].name AS “the name” , S.id from users as [AS] join statuses
        as “S”
    11. Warning: Don’t use any characters beside a-z A-Z . ; , *
    12. Please write your SQL script for the plugin: select id as the-id from
        user
    13. Warning: Don’t use any characters beside a-z A-Z . ; , *
    14. Please write your SQL script for the plugin: select somealias.id from
        users as somealias
    15. Warning: Don’t use any alias for a table name
    16. Please write your SQL script for the plugin: select * from users
    17. The SQL query was ok.
    18. Do you want to name the query parse row: Users ? [Y/n]:  Y
    19. Is the column a time event? updatedAt [Y/n]:  Y
    20. Is the column a time event? createdDate [Y/n]: Y
    21. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    22. Does the event Users need customizing? [y/N]: N
    23. Do you want to add another Query? [Y/n]: n
    24. Do you want to Generate the files [Y/n]: Y

    """
        if platform.system() in ['Linux']:

            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                path_answer = tmpdir
                expected_path = os.path.join(helper.DIR_PATH,
                                             'ExpectedEasyGenerationFiles')

                command = 'python {0} sqlite'.format(helper.MAIN_PATH)
                child = pexpect.spawn(command)

                child.expect(helper.PATH_QUESTION)
                child.sendline(path_answer)
                child.expect(path_answer)

                child.expect(helper.NAME_QUESTION)
                child.sendline(helper.NAME_ANSWER)
                child.expect(helper.NAME_ANSWER)

                child.expect(helper.TESTFILE_QUESTION)
                child.sendline(helper.TESTFILE_ANSWER)
                child.expect(helper.TESTFILE_ANSWER)

                child.expect(helper.OUTPUT_QUESTION)
                child.sendline(helper.COLUMN_ANSWER_NO)
                child.expect(helper.COLUMN_ANSWER_NO)

                child.expect(helper.SQL_QUESTION)
                child.sendline(
                    'select users.id as "userid" from users join statuses')
                child.expect(
                    'select users\.id as \"userid\" from users join statuses')
                child.expect('Warning\: Don\'t use any characters beside '
                             'a\-z A\-Z 0\-9 \. \; \, \* \= \_')

                child.expect(helper.SQL_QUESTION)
                child.sendline('select hex(id) from users')
                child.expect('select hex\(id\) from users')
                child.expect('Warning\: Don\'t use any characters beside '
                             'a\-z A\-Z 0\-9 \. \; \, \* \= \_')

                child.expect(helper.SQL_QUESTION)
                child.sendline(
                    'select [AS].[ID] AS [the alias], '
                    '[AS].name AS "the name" , S.id from users as [AS] '
                    'join statuses as "S"')
                child.expect('select \[AS\]\.\[ID\] AS \[the alias\]\, '
                             '\[AS\]\.name AS \"the name\" \, S\.id '
                             'from users as \[AS\] join statuses as \"S\"')
                child.expect('Warning\: Don\'t use any characters beside '
                             'a\-z A\-Z 0\-9 \. \; \, \* \= \_')

                child.expect(helper.SQL_QUESTION)
                child.sendline('select id as the-id from users')
                child.expect('select id as the\-id from users')
                child.expect('Warning\: Don\'t use any characters beside '
                             'a\-z A\-Z 0\-9 \. \; \, \* \= \_')

                child.expect(helper.SQL_QUESTION)
                child.sendline('select somealias.id from users as somealias')
                child.expect('select somealias\.id from users as somealias')
                child.expect('Warning\: Don\'t use any alias for a table name')

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")

        if __name__ == '__main__':
            unittest.main()
    def testGenerateWithOptionAtToolCall(self):
        """Test file generation with additional options calling the tool

    1.  plasoscaffolder sqlite --path tmpdir --name test --testfile
        test_database/twitter_ios.db –-no-sql
    6.  Please write your SQL script for the plugin: select * from users
    7.  The SQL query was ok.
    8.  Do you want to name the query parse row: Users ? [Y/n]:  Y
    9.  Is the column a time event? updatedAt [Y/n]:  Y
    10. Is the column a time event? createdDate [Y/n]: Y
    11. Enter (additional) timestamp events from the query [column-Name,
        aliasName...] or [abort]: abort
    12. Does the event Users need customizing? [y/N]: N
    13. Do you want to add another Query? [Y/n]: n
    14. Do you want to Generate the files [Y/n]: y
    """
        if platform.system() in ['Linux']:
            with tempfile.TemporaryDirectory() as tmpdir:
                helper = end_to_end_test_helper.EndToEndTestHelper(
                    tmpdir, 'test')

                expected_path = os.path.join(helper.DIR_PATH,
                                             'ExpectedEasyGenerationFiles')

                command = (
                    'python {0} sqlite --path {1} --name test --testfile '
                    '{2} --no-sql'.format(helper.MAIN_PATH, tmpdir,
                                          helper.TESTFILE_ANSWER))
                child = pexpect.spawn(command)

                child.expect(helper.SQL_QUESTION)
                child.sendline(helper.SQL_ANSWER)
                child.expect(helper.SQL_ANSWER_ESCAPED)
                child.expect(helper.SQL_ANSWER_OK)

                child.expect(helper.NAME_ROW_QUESTION_USERS)
                child.sendline(helper.NAME_ROW_ANSWER_YES)
                child.expect(helper.NAME_ROW_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_UPDATED_AT)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.COLUMN_QUESTION_CREATED_DATE)
                child.sendline(helper.COLUMN_ANSWER_YES)
                child.expect(helper.COLUMN_ANSWER_YES)

                child.expect(helper.ADDITIONAL_TIMESTAMP)
                child.sendline(helper.ADDITIONAL_TIMESTAMP_ABORT)
                child.expect(helper.ADDITIONAL_TIMESTAMP_ABORT)

                child.expect(helper.CUSTOM_QUESTION_USERS)
                child.sendline(helper.CUSTOM_ANSWER_NO)
                child.expect(helper.CUSTOM_ANSWER_NO)

                child.expect(helper.ADD_QUESTION)
                child.sendline(helper.ADD_ANSWER_NO)
                child.expect(helper.ADD_ANSWER_NO)

                child.expect(helper.GENERATE_QUESTION)
                child.sendline(helper.GENERATE_ANSWER_YES)

                child.expect('create.*{0}'.format(helper.formatter_path))
                child.expect('create.*{0}'.format(helper.parser_path))
                child.expect('create.*{0}'.format(helper.formatter_test_path))
                child.expect('create.*{0}'.format(helper.parser_test_path))
                child.expect('copy.*{0}'.format(helper.test_data_path))
                child.expect('create.*{0}'.format(helper.parsers_init_path))
                child.expect('create.*{0}'.format(helper.formatter_init_path))

                formatter_init = helper.ReadFromFile(
                    helper.formatter_init_path)
                formatter = helper.ReadFromFile(helper.formatter_path)
                formatter_test = helper.ReadFromFile(
                    helper.formatter_test_path)
                parser_init = helper.ReadFromFile(helper.parsers_init_path)
                parser = helper.ReadFromFile(helper.parser_path)
                parser_test = helper.ReadFromFile(helper.parser_test_path)

                expected_formatter_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_init.py'))
                expected_formatter = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters.py'))
                expected_formatter_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'formatters_test.py'))
                expected_parser_init = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_init.py'))
                expected_parser = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers.py'))
                expected_parser_test = helper.ReadFromFile(
                    os.path.join(expected_path, 'parsers_test.py'))

                self.assertEqual(formatter_init, expected_formatter_init)
                self.assertEqual(formatter, expected_formatter)
                self.assertEqual(formatter_test, expected_formatter_test)
                self.assertEqual(parser_init, expected_parser_init)
                self.assertEqual(parser, expected_parser)
                self.assertEqual(parser_test, expected_parser_test)
        else:
            raise NotImplementedError(
                "test only implemented for linux platform")