Lines
100 %
Functions
Branches
//! The request head is read without the form: ids survive bad forms, `:stream` is validated.
use super::*;
#[tokio::test]
async fn string_id_is_echoed() {
assert_eq!(
handle_form_smoke("(:id \"req-1\" :form (+ 1 2))").await,
"(:id \"req-1\" :value 3)"
);
}
async fn reader_error_in_the_form_keeps_the_id() {
let response = handle_form_smoke("(:id 17 :form (+ 1 #u8(999)))").await;
assert!(
response.starts_with("(:id 17 :error (:code parse"),
"{response}"
async fn reader_error_keeps_a_string_id() {
let response = handle_form_smoke("(:id \"a\" :form #u8(x))").await;
assert!(response.starts_with("(:id \"a\" :error"), "{response}");
async fn more_than_one_form_keeps_the_id() {
let response = handle_form_smoke("(:id 5 :form 1 2)").await;
assert!(response.starts_with("(:id 5 :error"), "{response}");
async fn missing_form_keeps_the_id() {
let response = handle_form_smoke("(:id 6 :form)").await;
assert!(response.starts_with("(:id 6 :error"), "{response}");
async fn headless_frame_answers_id_zero() {
let response = handle_form_smoke("(:form 1)").await;
response.starts_with("(:id 0 :error (:code args"),
async fn absent_and_explicit_zero_stream_evaluate() {
handle_form_smoke("(:id 1 :stream 0 :form (+ 1 2))").await,
"(:id 1 :value 3)"
async fn bare_session_refuses_a_non_zero_stream_with_the_id() {
for stream in ["1", "4294967295"] {
let response = handle_form_smoke(&format!("(:id 9 :stream {stream} :form 1)")).await;
response,
format!(
"(:id 9 :error (:code parse :message \"stream {stream} needs a multiplexed connection\"))"
)
async fn invalid_streams_answer_id_zero_without_a_stream() {
for stream in ["-1", "4294967296", "1/2", "\"3\"", "abc"] {
response
.starts_with("(:id 0 :error (:code parse :message \"invalid value for key :stream"),
"{stream}: {response}"
assert!(!response.contains(":stream 9"), "{response}");
async fn control_frames_with_bad_operands_answer_id_zero() {
for frame in ["(:interrupt -1)", "(:close 4294967296)", "(:interrupt x)"] {
let response = handle_form_smoke(frame).await;
response.starts_with("(:id 0 :error (:code parse :message \"invalid value for key"),
"{frame}: {response}"
async fn bare_session_refuses_control_frames() {
let response = handle_form_smoke("(:interrupt 1)").await;
response.starts_with("(:id 0 :error (:code parse"),