Skip to content

Commit 5556a5f

Browse files
committed
cookie
1 parent 2a0e165 commit 5556a5f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

atcoder-problems-backend/tests/test_server_e2e_problem_list.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use actix_web::{cookie::Cookie, http::StatusCode, test};
22
use atcoder_problems_backend::server::middleware::github_auth::{
33
GithubAuthentication, GithubClient, GithubToken,
44
};
5-
use reqwest::header::SET_COOKIE;
65
use serde_json::{json, Value};
76

87
pub mod utils;
@@ -38,20 +37,13 @@ async fn test_list() {
3837

3938
assert!(response.status().is_redirection());
4039

41-
let cookie = response.headers().get(SET_COOKIE).unwrap();
42-
let token = cookie
43-
.to_str()
44-
.unwrap()
45-
.split(';')
46-
.next()
47-
.unwrap()
48-
.split('=')
49-
.nth(1)
40+
let cookie = response
41+
.response()
42+
.cookies()
43+
.find(|cookie| cookie.name() == "token")
5044
.unwrap();
5145

52-
assert_eq!(token, VALID_TOKEN);
53-
54-
let cookie = Cookie::new("token", token);
46+
assert_eq!(cookie.value(), VALID_TOKEN);
5547

5648
let request = test::TestRequest::get()
5749
.uri("/internal-api/list/my")

0 commit comments

Comments
 (0)