#
2ac34dee |
|
22-Feb-2020 |
Kyle Ambroff-Kao <kyle@ambroffkao.com> |
tests/net: HTTP proxy client test With this patch, ProxyTest is implemented and all of the tests in HttpTest are enabled. Adding a transparent proxy server implementation proxy.py. Like testserver.py, this can be provided a socket file descriptor and port via command-line arguments. TestServer was refactored to extract ChildProcess and RandomTCPServerPort, which are now also used by TestProxyServer. ProxyTest starts TestProxyServer and validates that the request is sent to the proxy and is routed to the appropriate endpoint of the downstream server. The template which adds common tests between HttpTest and HttpsTest was changed slightly to just take a BThreadedTestCaller<T>&, which made it simpler to add additional test cases to one suite which are not appropriate to the other. There wasn't much point in keeping that template as a member function so I moved it into HttpTest.cpp as a free function template. Change-Id: Ied32d6e10bb195d111cae7bbcf0e93168118088b Reviewed-on: https://review.haiku-os.org/c/haiku/+/2291 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
0dde5052 |
|
08-Feb-2020 |
Kyle Ambroff-Kao <kyle@ambroffkao.com> |
tests/net: Working integration tests for HTTP client This patch is part 1 of 3 with the goal of having a working integration test harness for BHttpRequest. In this patch the existing test cases were expanded and fixed for HTTP. In followup patches the test harness will be updated to support HTTPS and reverse proxies. Before this patch the tests for BHttpRequest had hard dependencies on the external services httpbin.org and portquiz.net. These tests eventually stopped working because the owner of those services made changes, causing the assertions in these tests to fail. The goal of these patches is to make a test harness that allows for the same kinds of end-to-end integration tests but without any external dependencies. The test suite now includes a Python script called testserver.py which is a HTTP echo server of sorts. When it receives a request, it will echo the request headers and request body back to the client as a text/plain response body. The TestServer class manages the lifecycle of this testserver.py process. Each test case calls Start() on the server to start a new instance, and then it is shut down when the destructor is called. On each invocation a random port is assigned by the kernel in TestServer, and that socket file descriptor is provided to the child testserver.py script. Authorization tests are supported, currently implementing Basic and Digest auth. If the test server receives a request for a path /auth/<auth-scheme>/<expected-username>/<expected-password>, then the appropriate authorization scheme will be employed. For example, if /auth/basic/foo/bar is used as the path, then the server will expect the Authorization header to contain an appropriate Basic auth payload. The tests now perform a bit more validation than before, validating the expected HTTP headers and response body is returned from the server. The following tests are not fixed yet or were removed: * PortTest was removed entirely since I'm not sure of the point of this test, and that functionality seems to be covered by the existing tests anyway. * HTTPS tests are not functional yet, but will be in a followup patch. THis requires updating testserver.py to generate a self-signed TLS cert if --use-tls is provided. * ProxyTest was disabled before this patch, but can be enabled in a followup patch by providing a reverse proxy in the test harness. Change-Id: Ia201ef4583b7636c61e77072a03db936cb0092be Reviewed-on: https://review.haiku-os.org/c/haiku/+/2243 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|