| @@ -38,7 +38,7 @@ mod signed_out { |
| | #[test] |
| | fn nothing_private_is_reachable() { |
| | let s = Server::start_signed_out(repos()); |
| | for path in ["/", "/ada/notes", "/ada/notes/raw?path=x", "/ada/notes/log", "/account", "/nope", "/login/../"] { |
| | for path in ["/ada/notes", "/ada/notes/raw?path=x", "/ada/notes/log", "/account", "/nope", "/login/../"] { |
| | let response = s.get_signed_out(path); |
| | assert_eq!(response.status, 303, "{path} was served"); |
| | assert!(response.header("location").starts_with("/login"), "{path}"); |
| @@ -220,7 +220,7 @@ mod signing_in { |
| | fn a_forged_cookie_is_not_a_session() { |
| | let mut s = Server::start_signed_out(repos()); |
| | s.cookie = Some("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".into()); |
| | assert_eq!(s.get("/").status, 303); |
| | assert_eq!(s.get("/account").status, 303); |
| | } |
| | } |
| | |
| @@ -239,14 +239,14 @@ mod signing_out { |
| | let response = s.post("/logout", &[("csrf", &csrf(&s))]); |
| | assert_eq!((response.status, response.header("location")), (303, "/login")); |
| | assert!(response.header("set-cookie").contains("Max-Age=0")); |
| | assert_eq!(s.get("/").status, 303, "the old cookie still works"); |
| | assert_eq!(s.get("/account").status, 303, "the old cookie still works"); |
| | } |
| | |
| | #[test] |
| | fn needs_the_form_token() { |
| | let s = Server::start(repos()); |
| | assert_eq!(s.post("/logout", &[("csrf", "forged")]).status, 403); |
| | assert_eq!(s.get("/").status, 200, "a forged sign-out ended the session"); |
| | assert_eq!(s.get("/account").status, 200, "a forged sign-out ended the session"); |
| | } |
| | } |
| | |
| @@ -276,7 +276,7 @@ mod changing_the_password { |
| | ); |
| | assert_eq!(response.status, 200, "{}", response.text()); |
| | assert!(response.text().contains("Password changed.")); |
| | assert_eq!(s.get("/").status, 200); |
| | assert_eq!(s.get("/account").status, 200); |
| | } |
| | |
| | #[test] |
| @@ -302,12 +302,12 @@ mod changing_the_password { |
| | let mut second = Server::start_signed_out(repos()); |
| | second.port = first.port; |
| | second.cookie = session_cookie(&response); |
| | assert_eq!(second.get("/").status, 200); |
| | assert_eq!(second.get("/account").status, 200); |
| | let new = "yet another new password"; |
| | let response = change(&first, &csrf(&first), &first.account.password, new, new, &first.account.code(1)); |
| | assert_eq!(response.status, 200, "{}", response.text()); |
| | assert_eq!(second.get("/").status, 303, "the other session survived"); |
| | assert_eq!(first.get("/").status, 200, "this session was ended"); |
| | assert_eq!(second.get("/account").status, 303, "the other session survived"); |
| | assert_eq!(first.get("/account").status, 200, "this session was ended"); |
| | } |
| | |
| | #[test] |
| @@ -367,12 +367,12 @@ mod changing_the_password { |
| | #[test] |
| | fn on_the_server_signs_everyone_out() { |
| | let s = Server::start(repos()); |
| | assert_eq!(s.get("/").status, 200); |
| | assert_eq!(s.get("/account").status, 200); |
| | // What `gitv-web password` does: rewrite the account file with a new password. |
| | let mut credentials = gitv::auth::Credentials::load(&s.account.file).unwrap(); |
| | credentials.set_password("changed on the server").unwrap(); |
| | credentials.save(&s.account.file, None).unwrap(); |
| | assert_eq!(s.get("/").status, 303); |
| | assert_eq!(s.get("/account").status, 303); |
| | } |
| | } |
| | |
| @@ -426,7 +426,7 @@ mod setup { |
| | .output() |
| | .unwrap(); |
| | assert!(out.status.success(), "{}", stderr(&out)); |
| | assert_eq!(s.get("/").status, 303); |
| | assert_eq!(s.get("/account").status, 303); |
| | } |
| | |
| | #[test] |
| @@ -457,7 +457,10 @@ mod setup { |
| | fn without_an_account_the_site_says_how_to_set_one_up() { |
| | let s = Server::start_signed_out(repos()); |
| | std::fs::remove_file(&s.account.file).unwrap(); |
| | let response = s.get_signed_out("/"); |
| | let index = s.get_signed_out("/"); |
| | assert_eq!(index.status, 200); |
| | assert!(index.text().contains("No public repositories yet")); |
| | let response = s.get_signed_out("/account"); |
| | assert_eq!(response.status, 503); |
| | assert!(response.text().contains("gitv-web setup")); |
| | } |