コード例 #1
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_help_command(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'help\r\n')
        plugin_test.command()

        self.assertEqual(test_client.recv(2), b'. ')
        help = test_client.recv(1024).decode()
        self.assertEqual("options:\t" in help, True)
        self.assertEqual("options:\t\t" in help, False)
        self.assertEqual("help:" in help, True)
        self.assertEqual("echo:" in help, True)
        self.assertEqual("quit:" in help, True)
        self.assertEqual("__init__:" in help, False)

        self.assertEqual("basic list of options available to user" in help, True)
        self.assertEqual("detailed description of options" in help, True)
        self.assertEqual("prompt to echo back typing" in help, True)
        self.assertEqual("close telnet connection to server" in help, True)

        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': 'command', 'user_input': 'help'}})

        test_server.close()
        test_client.close()
コード例 #2
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_get_entry(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': '', 'user_input': ''}})

        test_server.close()
        test_client.close()
コード例 #3
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_multiple_quit(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)
        plugin_test.start()

        test_client.send(b'test_username\r\n')
        test_client.send(b'test_password\r\n')
        test_client.send(b'quit;quit;quit\r\n')

        test_client.close()
コード例 #4
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_password(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'test_password\r\n')
        plugin_test.password()

        self.assertEqual(test_client.recv(1024), b'Password: '******'test': {'input_type': 'password', 'user_input': 'test_password'}})

        test_server.close()
        test_client.close()
コード例 #5
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_echo_no_arguments(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'echo\r\n')
        test_client.send(b'test test\r\n')
        plugin_test.command()

        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': 'echo', 'user_input': 'test test'}})

        test_server.close()
        test_client.close()
コード例 #6
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_locked_command(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'__class__\r\n')
        plugin_test.command()

        self.assertEqual(test_client.recv(2), b'. ')
        self.assertEqual(test_client.recv(1024), b'%unrecognized command - type options for a list\r\n')
        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': 'command', 'user_input': '__class__'}})

        test_server.close()
        test_client.close()
コード例 #7
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_quit_command(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'quit\r\n')
        plugin_test.command()

        self.assertEqual(test_client.recv(2), b'. ')
        self.assertEqual(test_client.recv(1024), b'\nGoodbye\n')

        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': 'command', 'user_input': 'quit'}})

        test_server.close()
        test_client.close()
コード例 #8
0
ファイル: telnettests.py プロジェクト: RECCE7/recce7
    def test_options_command(self):
        test_client, test_server = setup_test_sockets(8023)
        plugin_test = TelnetPlugin(test_server, setup_test_config(8023, 'telnet', 'TelnetPlugin'), None)

        test_client.send(b'options\r\n')
        plugin_test.command()

        self.assertEqual(test_client.recv(2), b'. ')
        options = test_client.recv(1024).decode()
        self.assertEqual("options\t\t" in options, True)
        self.assertEqual("help\t\t" in options, True)
        self.assertEqual("echo\t\t" in options, True)
        self.assertEqual("quit\t\t" in options, True)
        self.assertEqual("__init__\t\t" in options, False)
        self.assertEqual(plugin_test.get_entry(), {'test': {'input_type': 'command', 'user_input': 'options'}})

        test_server.close()
        test_client.close()