コード例 #1
0
ファイル: httptests.py プロジェクト: jnels124/recce7
    def test_fake_501(self):
        """
        Test a bad http command
        If a command comes through that has no do_<command>
        defined it should be treated like a 501 and still
        be written to the database
        """

        test_client, test_server = setup_test_sockets(8083)

        plugin_test = HTTPPlugin(test_server, setup_test_config(8083, 'http', 'HTTPPlugin'), None)

        test_client.send(b'TEST / HTTP/1.1\r\n'
                         b'Connection: close\r\n'
                         b'\r\n')

        plugin_test.handle_one_request()
        plugin_test.format_data()
        entry = plugin_test.get_entry()

        self.assertEqual(entry, {'test':
                                 {'command': 'TEST',
                                  'path': '/',
                                  'headers': 'Connection: close\n\n',
                                  'body': ''}})

        plugin_test.shutdown()
        test_client.close()
コード例 #2
0
ファイル: httptests.py プロジェクト: jnels124/recce7
    def test_real_501(self):
        """
        Test a PUT command
        PUT, OPTIONS, DELETE, TRACE, and CONNECT should all have the same behavior.
        These commands send back a 501 error stating that the commands
        are not supported.
        """

        test_client, test_server = setup_test_sockets(8083)

        plugin_test = HTTPPlugin(test_server, setup_test_config(8083, 'http', 'HTTPPlugin'), None)

        test_client.send(b'PUT / HTTP/1.1\r\n'
                         b'Connection: close\r\n'
                         b'\r\n')

        plugin_test.handle_one_request()
        plugin_test.format_data()
        entry = plugin_test.get_entry()

        self.assertEqual(entry, {'test':
                                 {'command': 'PUT',
                                  'path': '/',
                                  'headers': 'Connection: close\n\n',
                                  'body': ''}})

        plugin_test.shutdown()
        test_client.close()