Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGIHandlerTests.test_server fails #61

Open
mtelka opened this issue Jun 21, 2024 · 0 comments
Open

CGIHandlerTests.test_server fails #61

mtelka opened this issue Jun 21, 2024 · 0 comments

Comments

@mtelka
Copy link

mtelka commented Jun 21, 2024

I run tests from 0.4.3.3 sdist and I noticed that the CGIHandlerTests.test_server test fails:

_________________________ CGIHandlerTests.test_server __________________________

self = <tests.test_cgi.CGIHandlerTests testMethod=test_server>

    def test_server(self):
        """
        Tests the CGI request handler
        """
        # Move the parent directory of "cgi-bin"
        old_dir = os.getcwd()
        try:
            # Setup server
            os.chdir(os.path.dirname(__file__))
            server = HTTPServer(("localhost", 0), CGIHTTPRequestHandler)

            # Serve in a thread
            thread = threading.Thread(target=server.serve_forever)
            thread.daemon = True
            thread.start()

            # Find its port
            port = server.socket.getsockname()[1]

            # Make the client
            client = ServerProxy(
                "http://localhost:{0}/cgi-bin/cgi_server.py".format(port)
            )

            # Check call
            for _ in range(2):
                rand1, rand2 = random.random(), random.random()
>               result = client.add(rand1, rand2)

tests/test_cgi.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
jsonrpclib/jsonrpc.py:762: in __call__
    return self.__send(self.__name, args)
jsonrpclib/jsonrpc.py:630: in _request
    response = self._run_request(request)
jsonrpclib/jsonrpc.py:671: in _run_request
    response = self.__transport.request(
/usr/lib/python3.9/xmlrpc/client.py:1166: in request
    return self.single_request(host, handler, request_body, verbose)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <jsonrpclib.jsonrpc.Transport object at 0x7fffada053a0>
host = 'localhost:38126', handler = '/cgi-bin/cgi_server.py'
request_body = '{"id": "3c57af18-8ddf-4fe8-b806-c666da09eca6", "method": "add", "params": [0.577582497388735, 0.22951816939657754], "jsonrpc": "2.0"}'
verbose = 0

    def single_request(self, host, handler, request_body, verbose=0):
        """
        Send a complete request, and parse the response.

        From xmlrpclib in Python 2.7

        :param host: Target host.
        :param handler: Target RPC handler.
        :param request_body: JSON-RPC request body.
        :param verbose: Debugging flag.
        :return: Parsed response.
        """
        connection = self.make_connection(host)
        try:
            self.send_request(connection, handler, request_body, verbose)
            self.send_content(connection, request_body)

            response = connection.getresponse()
            if response.status == 200:
                self.verbose = verbose
                return self.parse_response(response)
        except:
            # All unexpected errors leave connection in
            # a strange state, so we clear it.
            self.close()
            raise

        # Discard any response data and raise exception
        if response.getheader("content-length", 0):
            response.read()
>       raise TransportError(
            host + handler, response.status, response.reason, response.msg
        )
E       jsonrpclib.jsonrpc.TransportError: ('localhost:38126/cgi-bin/cgi_server.py', 403, "CGI script is not executable ('/cgi-bin/cgi_server.py')", <http.client.HTTPMessage object at 0x7fffadb15220>)

jsonrpclib/jsonrpc.py:362: TransportError
----------------------------- Captured stderr call -----------------------------
127.0.0.1 - - [21/Jun/2024 22:17:09] code 403, message CGI script is not executable ('/cgi-bin/cgi_server.py')
127.0.0.1 - - [21/Jun/2024 22:17:09] "POST /cgi-bin/cgi_server.py HTTP/1.1" 403 -

To workaround the issue I had to do chmod +x jsonrpclib-pelix-0.4.3.3/tests/cgi-bin/cgi_server.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant