mattp5657 commented on code in PR #4302:
URL: https://github.com/apache/iggy/pull/4302#discussion_r4116482966
##########
core/connectors/sources/http_source/src/lib.rs:
##########
@@ -1352,7 +1355,7 @@ mod tests {
),
(
"max_body_size_bytes",
- r#"{"listen_addr": "0.0.0.0:9090", "max_body_size_bytes":
67108865}"#,
+ r#"{"listen_addr": "0.0.0.0:9090", "max_body_size_bytes":
64000001}"#,
Review Comment:
Should this reference the constant rather than being hardcoded?
##########
core/connectors/sources/http_source/src/server.rs:
##########
@@ -1577,6 +1582,41 @@ mod tests {
close(&mut source).await;
}
+ #[tokio::test]
+ async fn
given_empty_body_when_posted_to_secret_path_should_answer_bad_request() {
+ let mut source = open(1, config(free_port(), free_port(),
&[ENDPOINT_ONE])).await;
+
+ let response = post_signed(&base_url(&source), ENDPOINT_ONE, "").await;
+
+ assert_eq!(response.status(), StatusCode::BAD_REQUEST);
+ let body: serde_json::Value = response
+ .json()
+ .await
+ .expect("the refusal must carry this API's json");
+ assert_eq!(body["error"], "empty body");
+ assert_eq!(
+ source.shared.sender.len(),
+ 0,
+ "an empty body queued is a batch the runtime NACKs on every replay"
+ );
+ close(&mut source).await;
+ }
+
+ #[tokio::test]
Review Comment:
Should we test this accepts a 1 byte message as well?
##########
core/connectors/sources/http_source/src/server.rs:
##########
@@ -1577,6 +1582,41 @@ mod tests {
close(&mut source).await;
}
+ #[tokio::test]
+ async fn
given_empty_body_when_posted_to_secret_path_should_answer_bad_request() {
+ let mut source = open(1, config(free_port(), free_port(),
&[ENDPOINT_ONE])).await;
+
+ let response = post_signed(&base_url(&source), ENDPOINT_ONE, "").await;
+
+ assert_eq!(response.status(), StatusCode::BAD_REQUEST);
+ let body: serde_json::Value = response
+ .json()
+ .await
+ .expect("the refusal must carry this API's json");
+ assert_eq!(body["error"], "empty body");
+ assert_eq!(
+ source.shared.sender.len(),
+ 0,
+ "an empty body queued is a batch the runtime NACKs on every replay"
+ );
+ close(&mut source).await;
+ }
+
+ #[tokio::test]
+ async fn
given_empty_body_when_posted_to_named_path_should_answer_bad_request() {
+ let mut source = open(1, config(free_port(), free_port(), &[])).await;
+
+ let response = client()
+ .post(format!("{}/topics/github", base_url(&source)))
+ .send()
+ .await
+ .expect("the request must reach the listener");
+
+ assert_eq!(response.status(), StatusCode::BAD_REQUEST);
+ assert_eq!(source.shared.sender.len(), 0);
+ close(&mut source).await;
+ }
+
#[tokio::test]
async fn
given_oversized_body_when_posted_should_answer_payload_too_large() {
Review Comment:
Should we test this accepts a payload at `max_body_size_bytes` returning a
200?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]