Respect allow insecure host in publish (#8440)

This commit is contained in:
konsti 2024-10-22 13:36:18 +02:00 committed by GitHub
parent 614013ed58
commit e7ae0f50d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 38 additions and 30 deletions

View file

@ -350,16 +350,6 @@ enum Security {
}
impl BaseClient {
/// The underlying [`ClientWithMiddleware`] for secure requests.
pub fn client(&self) -> ClientWithMiddleware {
self.client.clone()
}
/// The underlying [`Client`] without middleware.
pub fn raw_client(&self) -> Client {
self.raw_client.clone()
}
/// Selects the appropriate client based on the host's trustworthiness.
pub fn for_host(&self, url: &Url) -> &ClientWithMiddleware {
if self

View file

@ -8,8 +8,9 @@ use hyper::service::service_fn;
use hyper::{Request, Response};
use hyper_util::rt::TokioIo;
use insta::{assert_json_snapshot, assert_snapshot, with_settings};
use std::str::FromStr;
use tokio::net::TcpListener;
use url::Url;
use uv_cache::Cache;
use uv_client::LineHaul;
use uv_client::RegistryClientBuilder;
@ -53,11 +54,12 @@ async fn test_user_agent_has_version() -> Result<()> {
let client = RegistryClientBuilder::new(cache).build();
// Send request to our dummy server
let url = Url::from_str(&format!("http://{addr}"))?;
let res = client
.cached_client()
.uncached()
.client()
.get(format!("http://{addr}"))
.for_host(&url)
.get(url)
.send()
.await?;
@ -149,11 +151,12 @@ async fn test_user_agent_has_linehaul() -> Result<()> {
let client = builder.build();
// Send request to our dummy server
let url = Url::from_str(&format!("http://{addr}"))?;
let res = client
.cached_client()
.uncached()
.client()
.get(format!("http://{addr}"))
.for_host(&url)
.get(url)
.send()
.await?;