diff --git a/crates/trusted-server-core/src/request_signing/endpoints.rs b/crates/trusted-server-core/src/request_signing/endpoints.rs index 032a6fc5..1db457f4 100644 --- a/crates/trusted-server-core/src/request_signing/endpoints.rs +++ b/crates/trusted-server-core/src/request_signing/endpoints.rs @@ -48,7 +48,7 @@ pub fn handle_trusted_server_discovery( Ok(Response::from_status(200) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&json)) + .with_body(json)) } #[derive(Debug, Deserialize, Serialize)] @@ -118,7 +118,7 @@ pub fn handle_verify_signature( Ok(Response::from_status(200) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&response_json)) + .with_body(response_json)) } #[derive(Debug, Deserialize, Serialize)] @@ -199,7 +199,7 @@ pub fn handle_rotate_key( Ok(Response::from_status(200) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&response_json)) + .with_body(response_json)) } Err(e) => { let response = RotateKeyResponse { @@ -220,7 +220,7 @@ pub fn handle_rotate_key( Ok(Response::from_status(500) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&response_json)) + .with_body(response_json)) } } } @@ -305,7 +305,7 @@ pub fn handle_deactivate_key( Ok(Response::from_status(200) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&response_json)) + .with_body(response_json)) } Err(e) => { let response = DeactivateKeyResponse { @@ -329,7 +329,7 @@ pub fn handle_deactivate_key( Ok(Response::from_status(500) .with_content_type(fastly::mime::APPLICATION_JSON) - .with_body_text_plain(&response_json)) + .with_body(response_json)) } } } @@ -366,6 +366,11 @@ mod tests { let mut resp = handle_verify_signature(&settings, req).expect("should handle verification request"); assert_eq!(resp.get_status(), StatusCode::OK); + assert_eq!( + resp.get_content_type(), + Some(fastly::mime::APPLICATION_JSON), + "should return application/json content type" + ); // Parse response let resp_body = resp.take_body_str(); @@ -403,6 +408,11 @@ mod tests { let mut resp = handle_verify_signature(&settings, req).expect("should handle verification request"); assert_eq!(resp.get_status(), StatusCode::OK); + assert_eq!( + resp.get_content_type(), + Some(fastly::mime::APPLICATION_JSON), + "should return application/json content type" + ); // Parse response let resp_body = resp.take_body_str(); @@ -584,6 +594,11 @@ mod tests { match result { Ok(mut resp) => { assert_eq!(resp.get_status(), StatusCode::OK); + assert_eq!( + resp.get_content_type(), + Some(fastly::mime::APPLICATION_JSON), + "should return application/json content type" + ); let body = resp.take_body_str(); // Parse the discovery document