httpmock patterns are too general (#467)

This commit is contained in:
Adam Leventhal 2023-05-12 13:19:09 -07:00 committed by GitHub
parent 87749a11ee
commit b94123e5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 323 additions and 246 deletions

View File

@ -70,7 +70,7 @@ impl PathTemplate {
.iter()
.map(|c| match c {
Component::Constant(name) => name.clone(),
Component::Parameter(_) => ".*".to_string(),
Component::Parameter(_) => "[^/]*".to_string(),
})
.collect::<String>();
format!("^{}$", inner)

View File

@ -75,7 +75,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::GET)
.path_matches(regex::Regex::new("^/v1/task/.*$").unwrap()),
.path_matches(regex::Regex::new("^/v1/task/[^/]*$").unwrap()),
)
}
@ -189,7 +189,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::GET)
.path_matches(regex::Regex::new("^/v1/tasks/.*/events$").unwrap()),
.path_matches(regex::Regex::new("^/v1/tasks/[^/]*/events$").unwrap()),
)
}
@ -234,7 +234,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::GET)
.path_matches(regex::Regex::new("^/v1/tasks/.*/outputs$").unwrap()),
.path_matches(regex::Regex::new("^/v1/tasks/[^/]*/outputs$").unwrap()),
)
}
@ -275,7 +275,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::GET)
.path_matches(regex::Regex::new("^/v1/tasks/.*/outputs/.*$").unwrap()),
.path_matches(regex::Regex::new("^/v1/tasks/[^/]*/outputs/[^/]*$").unwrap()),
)
}
@ -471,7 +471,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::POST)
.path_matches(regex::Regex::new("^/v1/worker/task/.*/append$").unwrap()),
.path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/append$").unwrap()),
)
}
@ -511,7 +511,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::POST)
.path_matches(regex::Regex::new("^/v1/worker/task/.*/chunk$").unwrap()),
.path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/chunk$").unwrap()),
)
}
@ -556,7 +556,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::POST)
.path_matches(regex::Regex::new("^/v1/worker/task/.*/complete$").unwrap()),
.path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/complete$").unwrap()),
)
}
@ -597,7 +597,7 @@ pub mod operations {
Self(
inner
.method(httpmock::Method::POST)
.path_matches(regex::Regex::new("^/v1/worker/task/.*/output$").unwrap()),
.path_matches(regex::Regex::new("^/v1/worker/task/[^/]*/output$").unwrap()),
)
}

File diff suppressed because it is too large Load Diff

View File

@ -122,9 +122,9 @@ pub mod operations {
impl InstanceIssueCrucibleSnapshotRequestWhen {
pub fn new(inner: httpmock::When) -> Self {
Self(
inner
.method(httpmock::Method::POST)
.path_matches(regex::Regex::new("^/instance/disk/.*/snapshot/.*$").unwrap()),
inner.method(httpmock::Method::POST).path_matches(
regex::Regex::new("^/instance/disk/[^/]*/snapshot/[^/]*$").unwrap(),
),
)
}