Skip to content

Commit 488ead9

Browse files
committed
test(providers): pad exact-bound body without a format width
MAX_TOKEN_RESPONSE_BYTES exceeds u16::MAX, the largest format width, so the padded fixture panicked. Pad with repeat_n as before. Signed-off-by: Shiju <shiju@nvidia.com>
1 parent e61e60a commit 488ead9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎crates/openshell-core/src/oauth.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,12 @@ mod tests {
769769
assert_eq!(failure.upstream_status(), Some(503));
770770
}
771771

772-
let token = r#"{"access_token":"access-token"}"#;
773-
let body = format!("{token:<width$}", width = MAX_TOKEN_RESPONSE_BYTES);
772+
// Pad to the exact bound. A format width cannot exceed u16::MAX.
773+
let mut body = r#"{"access_token":"access-token"}"#.to_string();
774+
body.extend(std::iter::repeat_n(
775+
' ',
776+
MAX_TOKEN_RESPONSE_BYTES - body.len(),
777+
));
774778
let (endpoint, server) = token_endpoint_once("200 OK", &body).await;
775779
post_oauth_token_grant(&test_client(), &endpoint, &empty_grant_params(), None)
776780
.await

0 commit comments

Comments
 (0)