hstspreload
hstspreload copied to clipboard
Fix tests that rely on behavior of external domains
Some of the test cases in redirects_test.go and domain_test.go rely on the behavior of external domains. For some of these tests, that behavior has changed and the tests are no longer passing.
Preferably, the tests would be hermetic and not connect to any external sites. If that's not possible, I'd prefer restricting it to domains where we have some reasonable assurance that it will keep behaving the way we expect for a test (e.g. badssl.com).
(See also issue #75)
I drafted a fix for this a while back! I'll go dust it off.
That sounds incredibly useful, even if it's only partially complete.
Here's the part I was able to dig up: https://github.com/chromium/hstspreload/commit/d4e2a716118657f22f6efc64420fc5202d39e4d2
The idea was to have a JSON file mapping URLs to http.DumpResponse() values, and ideally a "record" mode to add missing URLs to the cache while running the test. It's not super-idiomatic Go, bu I was unable to find an idiomatic Go testing mechanism for this (at the time) and this idea seemed simplest to implement and understand.
I have to apologize for the state of the code, though. It's even more incomplete than I remember, and I don't have time to work on it right now. It should give you a rough idea how how to hook up a custom transport for testing, though.