Skip to content

Commit 610fd4d

Browse files
81reaplovasoa
andauthored
fix(render) :: test a page made only of header components (#1432)
A page with only header components (ie :: `status_code` and `cookie`) never opens a body. Adds a test for this. Co-authored-by: Ophir LOJKINE <contact@ophir.dev>
1 parent bc164d6 commit 610fd4d

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
select 'status_code' as component, 204 as status;
2+
select 'cookie' as component, 'session' as name, 'abc123' as value;

tests/cookies/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::common::req_path;
2+
use actix_web::http::StatusCode;
23
use actix_web::http::header::SET_COOKIE;
34

45
async fn set_cookie_header(path: &str) -> String {
@@ -30,6 +31,15 @@ async fn zero_turns_off_a_cookie_protection() {
3031
assert!(header.contains("Path=/admin"), "{header}");
3132
}
3233

34+
#[actix_web::test]
35+
async fn a_page_made_only_of_header_components_still_sends_them() {
36+
let resp = req_path("/tests/cookies/header_only_response.sql")
37+
.await
38+
.unwrap();
39+
assert_eq!(resp.status(), StatusCode::NO_CONTENT);
40+
assert!(resp.headers().contains_key(SET_COOKIE));
41+
}
42+
3343
#[actix_web::test]
3444
async fn a_log_row_does_not_end_the_header_phase() {
3545
let header = set_cookie_header("/tests/cookies/log_before_cookie.sql").await;

0 commit comments

Comments
 (0)