compress request body online test

This commit is contained in:
zuisong 2025-01-22 22:04:04 +08:00
parent 9b26a31415
commit 70ad491c81
No known key found for this signature in database
GPG Key ID: A617F31AFE6F5E8D

View File

@ -19,6 +19,7 @@ use indoc::indoc;
use predicates::function::function;
use predicates::str::contains;
use reqwest::header::HeaderValue;
use serde_json::Value;
use tempfile::{tempdir, NamedTempFile, TempDir};
pub trait RequestExt {
@ -779,6 +780,25 @@ fn successful_digest_auth() {
.stdout(contains("HTTP/1.1 200 OK"));
}
#[cfg(feature = "online-tests")]
#[test]
fn compress_request_body_online() {
get_command()
.arg("https://postman-echo.com/post")
.args(["-xx", "--body", &format!("a={}", "1".repeat(1000))])
.assert()
.stdout(function(|body: &str| {
let json: Value = serde_json::from_str(body).unwrap();
assert_eq!(json["json"]["a"], Value::String("1".repeat(1000)));
if let Some(request_body_length) = json["headers"]["content-length"].as_str() {
let length: i32 = request_body_length.parse().unwrap();
assert!(length < 1000)
}
true
}));
}
#[cfg(feature = "online-tests")]
#[test]
fn unsuccessful_digest_auth() {