mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 10:56:09 +03:00
[FIX] Send multiple request cookies
This commit is contained in:
parent
d348679d9b
commit
7e36855113
@ -9,6 +9,11 @@ HTTP/1.0 200
|
||||
GET http://localhost:8000/cookies/assert-that-cookie1-is-not-in-session
|
||||
HTTP/1.0 200
|
||||
|
||||
GET http://localhost:8000/cookies/set-multiple-request-cookies
|
||||
[Cookies]
|
||||
user1: Bob
|
||||
user2: Bill
|
||||
HTTP/1.0 200
|
||||
|
||||
|
||||
# Session Cookie
|
||||
@ -54,3 +59,5 @@ cookie "LSID[Path]" equals "/accounts"
|
||||
cookie "LSID[Secure]" exists
|
||||
cookie "LSID[HttpOnly]" exists
|
||||
cookie "LSID[SameSite]" not exists
|
||||
|
||||
|
||||
|
@ -7,6 +7,12 @@ def set_request_cookie1_value1():
|
||||
assert request.cookies['cookie1'] == 'valueA'
|
||||
return ''
|
||||
|
||||
@app.route("/cookies/set-multiple-request-cookies")
|
||||
def set_multiple_request_cookies():
|
||||
assert request.cookies['user1'] == 'Bob'
|
||||
assert request.cookies['user2'] == 'Bill'
|
||||
return ''
|
||||
|
||||
|
||||
@app.route("/cookies/set-session-cookie2-valueA")
|
||||
def set_session_cookie2_valuea():
|
||||
|
@ -324,9 +324,12 @@ impl Client {
|
||||
/// set request cookies
|
||||
///
|
||||
fn set_cookies(&mut self, cookies: &[RequestCookie]) {
|
||||
for cookie in cookies {
|
||||
self.handle.cookie(cookie.to_string().as_str()).unwrap();
|
||||
}
|
||||
let s = cookies
|
||||
.iter()
|
||||
.map(|c| c.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("; ");
|
||||
self.handle.cookie(s.as_str()).unwrap();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -620,14 +620,34 @@ fn test_cookie() {
|
||||
let response = client.execute(&request, 0).unwrap();
|
||||
assert_eq!(response.status, 200);
|
||||
assert!(response.body.is_empty());
|
||||
}
|
||||
|
||||
// For the time-being setting a cookie on a request
|
||||
// update the cookie store as well
|
||||
// The same cookie does not need to be set explicitly on further requests
|
||||
// let request = default_get_request("http://localhost:8000/cookies/set-request-cookie1-valueA".to_string());
|
||||
// let response = client.execute(&request, 0).unwrap();
|
||||
// assert_eq!(response.status, 200);
|
||||
// assert!(response.body.is_empty());
|
||||
#[test]
|
||||
fn test_multiple_request_cookies() {
|
||||
let mut client = default_client();
|
||||
let request = Request {
|
||||
method: Method::Get,
|
||||
url: "http://localhost:8000/cookies/set-multiple-request-cookies".to_string(),
|
||||
headers: vec![],
|
||||
querystring: vec![],
|
||||
form: vec![],
|
||||
multipart: vec![],
|
||||
cookies: vec![
|
||||
RequestCookie {
|
||||
name: "user1".to_string(),
|
||||
value: "Bob".to_string(),
|
||||
},
|
||||
RequestCookie {
|
||||
name: "user2".to_string(),
|
||||
value: "Bill".to_string(),
|
||||
},
|
||||
],
|
||||
body: vec![],
|
||||
content_type: None,
|
||||
};
|
||||
let response = client.execute(&request, 0).unwrap();
|
||||
assert_eq!(response.status, 200);
|
||||
assert!(response.body.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user