Files
curl-impersonate/tests
lwthiker 82bca6dab7 Handle curl_easy_reset() calls when impersonating (#44)
curl_easy_reset() may be used by an application to reset the options on
a curl handle. If an app has the CURL_IMPERSONATE env var defined, then
the impersonation options are automatically set in curl_easy_init() but
will be cleared in a call to curl_easy_reset(). The desired behavior is
for the impersonation options to be retained (as they are "transparent"
to the user), which this commit takes care of.

Note that this only has an effect when libcurl-impersonate is loaded and
the CURL_IMPERSONATE env var is set. Otherwise the regular behavior of
resetting all the handle options is retained.

Test that the unique TLS signature of curl-impersonate is preserved
after a call to curl_easy_reset() when libcurl-impersonate is loaded.
For this purpose change the 'minicurl' testing util to support multiple
URLs and launch it with 2 different URLs when testing the TLS signature.
2022-05-18 11:43:46 +03:00
..
2022-03-04 17:31:32 +02:00

The tests verify that curl-impersonate has the same network signature as that of the supported browsers. They do not test curl's functionality itself.

Running the tests

The tests assume that you've built both curl-impersonate-chrome and curl-impersonate-ff docker images before (see Building from source).

To run the tests, build with:

docker build -t curl-impersonate-tests tests/

then run with:

docker run --rm curl-impersonate-tests

This simply runs pytest in the container. You can pass additional flags to pytest such as --log-cli-level DEBUG.

How the tests work

For each supported browser, the following tests are performed:

  • A packet capture is started while curl-impersonate is run with the relevant wrapper script. The Client Hello message is extracted from the capture and compared against the known signature of the browser.
  • curl-impersonate is run, connecting to a local nghttpd server (a simple HTTP/2 server). The HTTP/2 pseudo-headers and headers are extracted from the output log of nghttpd and compared to the known headers of the browser.

What's missing

The following tests are still missing:

  • Test that curl-impersonate sends the same HTTP/2 SETTINGS as the browser.