juju overrides http.DefaultTransport in general and specifically for tests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Triaged
|
Low
|
Unassigned |
Bug Description
Ideally http.NewClient should return a constructed Transport so that we can make suitable changes, such as not caching the proxy settings and creating a TLS config. Due to the way tests are setup in juju/juju (I believe), NewClient must use a default http client when validating hostnames, or many unit tests will fail.
The primary culprit is in the TestDataSuite: https:/
Unfortunately some of this is used in the JujuConnSuite as well as provisioner tests and difficult to replace.
Instead we should have more mocking of unit tests and use the httptest package more in environs/
Once the TestDataSuite can be removed, we should update http.NewClient accordingly and stop changing the DefaultTransport.
Also investigate whether http.OutgoingAc cessAllowed and installHTTPDialShim are really needed.