Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,35 @@
|
||||
use super::*;
|
||||
|
||||
pub(super) fn check(port: u16) {
|
||||
let headers = "Origin: https://fixture.test\r\nContent-Type: application/json\r\nX-Test: request-value\r\nCookie: theme=light\r\nX-Forwarded-For: 203.0.113.9\r\n";
|
||||
let path = "/demo/account/admin/metadata/metadata";
|
||||
let mut previous = None;
|
||||
for _ in 0..2 {
|
||||
let (status, head, body) = request_head(port, "POST", path, "fixture.test", headers, "{}");
|
||||
assert_eq!(status, 200, "{body}");
|
||||
let value = serde_json::from_str::<serde_json::Value>(&body).unwrap()["data"].clone();
|
||||
assert_eq!(value["method"], "POST");
|
||||
assert_eq!(value["path"], path);
|
||||
assert_eq!(value["address"], "127.0.0.1");
|
||||
assert_eq!(value["header"], "request-value");
|
||||
assert_eq!(value["cookie"], "light");
|
||||
let id = value["request_id"].as_str().unwrap().to_owned();
|
||||
assert!(head.contains(&format!("x-request-id: {id}")));
|
||||
assert!(head.contains("set-cookie: theme=dark; Path=/; SameSite=Lax; Secure; HttpOnly"));
|
||||
assert!(head.contains(
|
||||
"set-cookie: strict=yes; Path=/; SameSite=Strict; Max-Age=60; Secure; HttpOnly"
|
||||
));
|
||||
assert_ne!(previous.as_ref(), Some(&id));
|
||||
previous = Some(id);
|
||||
}
|
||||
let (status, head, _) = request_head(
|
||||
port,
|
||||
"POST",
|
||||
"/demo/account/admin/metadata/metadata_fail",
|
||||
"fixture.test",
|
||||
headers,
|
||||
"{}",
|
||||
);
|
||||
assert_eq!(status, 409);
|
||||
assert!(!head.contains("x-request-id:") && !head.contains("set-cookie:"));
|
||||
}
|
||||
Reference in new issue
Block a user