mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-25 21:53:16 -05:00
upgrade some deps, including reqwest
The reqwest one is particularly notable because it means not having two versions of hyper/http/tokio/futures/bytes. It also drops a number of transitive deps; with some work I think I could stop depending on regex now.
This commit is contained in:
parent
73f7cdd261
commit
038fc574e9
756
Cargo.lock
generated
756
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
14
Cargo.toml
@ -19,7 +19,7 @@ members = ["base", "db", "ffmpeg"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base = { package = "moonfire-base", path = "base" }
|
base = { package = "moonfire-base", path = "base" }
|
||||||
base64 = "0.10.0"
|
base64 = "0.11.0"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
cstr = "0.1.7"
|
cstr = "0.1.7"
|
||||||
@ -43,20 +43,20 @@ nix = "0.16.1"
|
|||||||
openssl = "0.10"
|
openssl = "0.10"
|
||||||
parking_lot = { version = "0.9", features = [] }
|
parking_lot = { version = "0.9", features = [] }
|
||||||
protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
|
protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
|
||||||
reffers = "0.5.1"
|
reffers = "0.6.0"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
ring = "0.14.6"
|
ring = "0.14.6"
|
||||||
rusqlite = "0.19.0"
|
rusqlite = "0.21.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
smallvec = "0.6"
|
smallvec = "1.0"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
tokio = { version = "0.2.0", features = ["blocking", "macros", "rt-threaded", "signal"] }
|
tokio = { version = "0.2.0", features = ["blocking", "macros", "rt-threaded", "signal"] }
|
||||||
url = "1.4"
|
url = "2.1.1"
|
||||||
uuid = { version = "0.7", features = ["serde", "std", "v4"] }
|
uuid = { version = "0.8", features = ["serde", "std", "v4"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
reqwest = "0.9.5"
|
reqwest = { version = "0.10.1", features = ["json"] }
|
||||||
tempdir = "0.3"
|
tempdir = "0.3"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base = { package = "moonfire-base", path = "../base" }
|
base = { package = "moonfire-base", path = "../base" }
|
||||||
base64 = "0.10.0"
|
base64 = "0.11.0"
|
||||||
blake2-rfc = "0.2.18"
|
blake2-rfc = "0.2.18"
|
||||||
cstr = "0.1.7"
|
cstr = "0.1.7"
|
||||||
failure = "0.1.1"
|
failure = "0.1.1"
|
||||||
@ -31,11 +31,11 @@ parking_lot = { version = "0.9", features = [] }
|
|||||||
prettydiff = "0.3.1"
|
prettydiff = "0.3.1"
|
||||||
protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
|
protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
rusqlite = "0.19.0"
|
rusqlite = "0.21.0"
|
||||||
smallvec = "0.6"
|
smallvec = "1.0"
|
||||||
tempdir = "0.3"
|
tempdir = "0.3"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
uuid = { version = "0.7", features = ["std", "v4"] }
|
uuid = { version = "0.8", features = ["std", "v4"] }
|
||||||
itertools = "0.8.0"
|
itertools = "0.8.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
54
src/web.rs
54
src/web.rs
@ -1057,17 +1057,20 @@ mod tests {
|
|||||||
move |req| std::pin::Pin::from(s.serve(req))
|
move |req| std::pin::Pin::from(s.serve(req))
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
let srv = rt.enter(|| {
|
let handle = ::std::thread::spawn(move || {
|
||||||
let addr = ([127, 0, 0, 1], 0).into();
|
let addr = ([127, 0, 0, 1], 0).into();
|
||||||
hyper::server::Server::bind(&addr)
|
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
|
let srv = rt.enter(|| {
|
||||||
|
hyper::server::Server::bind(&addr)
|
||||||
.tcp_nodelay(true)
|
.tcp_nodelay(true)
|
||||||
.serve(make_svc)
|
.serve(make_svc)
|
||||||
});
|
});
|
||||||
let addr = srv.local_addr(); // resolve port 0 to a real ephemeral port number.
|
let addr = srv.local_addr(); // resolve port 0 to a real ephemeral port number.
|
||||||
let handle = ::std::thread::spawn(move || {
|
tx.send(addr).unwrap();
|
||||||
rt.block_on(srv.with_graceful_shutdown(shutdown_rx.map(|_| ()))).unwrap();
|
rt.block_on(srv.with_graceful_shutdown(shutdown_rx.map(|_| ()))).unwrap();
|
||||||
});
|
});
|
||||||
|
let addr = rx.recv().unwrap();
|
||||||
|
|
||||||
// Create a user.
|
// Create a user.
|
||||||
let mut c = db::UserChange::add_user("slamb".to_owned());
|
let mut c = db::UserChange::add_user("slamb".to_owned());
|
||||||
@ -1203,36 +1206,36 @@ mod tests {
|
|||||||
Segments::parse("1-5.26-42").unwrap());
|
Segments::parse("1-5.26-42").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn unauthorized_without_cookie() {
|
async fn unauthorized_without_cookie() {
|
||||||
testutil::init();
|
testutil::init();
|
||||||
let s = Server::new(None);
|
let s = Server::new(None);
|
||||||
let cli = reqwest::Client::new();
|
let cli = reqwest::Client::new();
|
||||||
let resp = cli.get(&format!("{}/api/", &s.base_url)).send().unwrap();
|
let resp = cli.get(&format!("{}/api/", &s.base_url)).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn login() {
|
async fn login() {
|
||||||
testutil::init();
|
testutil::init();
|
||||||
let s = Server::new(None);
|
let s = Server::new(None);
|
||||||
let cli = reqwest::Client::new();
|
let cli = reqwest::Client::new();
|
||||||
let login_url = format!("{}/api/login", &s.base_url);
|
let login_url = format!("{}/api/login", &s.base_url);
|
||||||
|
|
||||||
let resp = cli.get(&login_url).send().unwrap();
|
let resp = cli.get(&login_url).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::METHOD_NOT_ALLOWED);
|
assert_eq!(resp.status(), reqwest::StatusCode::METHOD_NOT_ALLOWED);
|
||||||
|
|
||||||
let resp = cli.post(&login_url).send().unwrap();
|
let resp = cli.post(&login_url).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
||||||
|
|
||||||
let mut p = HashMap::new();
|
let mut p = HashMap::new();
|
||||||
p.insert("username", "slamb");
|
p.insert("username", "slamb");
|
||||||
p.insert("password", "asdf");
|
p.insert("password", "asdf");
|
||||||
let resp = cli.post(&login_url).json(&p).send().unwrap();
|
let resp = cli.post(&login_url).json(&p).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
||||||
|
|
||||||
p.insert("password", "hunter2");
|
p.insert("password", "hunter2");
|
||||||
let resp = cli.post(&login_url).json(&p).send().unwrap();
|
let resp = cli.post(&login_url).json(&p).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
||||||
let cookie = SessionCookie::new(resp.headers());
|
let cookie = SessionCookie::new(resp.headers());
|
||||||
info!("cookie: {:?}", cookie);
|
info!("cookie: {:?}", cookie);
|
||||||
@ -1241,19 +1244,20 @@ mod tests {
|
|||||||
let resp = cli.get(&format!("{}/api/", &s.base_url))
|
let resp = cli.get(&format!("{}/api/", &s.base_url))
|
||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::OK);
|
assert_eq!(resp.status(), reqwest::StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn logout() {
|
async fn logout() {
|
||||||
testutil::init();
|
testutil::init();
|
||||||
let s = Server::new(None);
|
let s = Server::new(None);
|
||||||
let cli = reqwest::Client::new();
|
let cli = reqwest::Client::new();
|
||||||
let mut p = HashMap::new();
|
let mut p = HashMap::new();
|
||||||
p.insert("username", "slamb");
|
p.insert("username", "slamb");
|
||||||
p.insert("password", "hunter2");
|
p.insert("password", "hunter2");
|
||||||
let resp = cli.post(&format!("{}/api/login", &s.base_url)).json(&p).send().unwrap();
|
let resp = cli.post(&format!("{}/api/login", &s.base_url)).json(&p).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
||||||
let cookie = SessionCookie::new(resp.headers());
|
let cookie = SessionCookie::new(resp.headers());
|
||||||
|
|
||||||
@ -1261,6 +1265,7 @@ mod tests {
|
|||||||
let resp = cli.get(&format!("{}/api/logout", &s.base_url))
|
let resp = cli.get(&format!("{}/api/logout", &s.base_url))
|
||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::METHOD_NOT_ALLOWED);
|
assert_eq!(resp.status(), reqwest::StatusCode::METHOD_NOT_ALLOWED);
|
||||||
|
|
||||||
@ -1268,6 +1273,7 @@ mod tests {
|
|||||||
let resp = cli.post(&format!("{}/api/logout", &s.base_url))
|
let resp = cli.post(&format!("{}/api/logout", &s.base_url))
|
||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
||||||
|
|
||||||
@ -1275,8 +1281,8 @@ mod tests {
|
|||||||
// Retrieve that from the toplevel API request.
|
// Retrieve that from the toplevel API request.
|
||||||
let toplevel: serde_json::Value = cli.post(&format!("{}/api/", &s.base_url))
|
let toplevel: serde_json::Value = cli.post(&format!("{}/api/", &s.base_url))
|
||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.send().unwrap()
|
.send().await.unwrap()
|
||||||
.json().unwrap();
|
.json().await.unwrap();
|
||||||
let csrf = toplevel.get("session").unwrap().get("csrf").unwrap().as_str();
|
let csrf = toplevel.get("session").unwrap().get("csrf").unwrap().as_str();
|
||||||
let mut p = HashMap::new();
|
let mut p = HashMap::new();
|
||||||
p.insert("csrf", csrf);
|
p.insert("csrf", csrf);
|
||||||
@ -1284,6 +1290,7 @@ mod tests {
|
|||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.json(&p)
|
.json(&p)
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
assert_eq!(resp.status(), reqwest::StatusCode::NO_CONTENT);
|
||||||
let mut updated_cookie = cookie.clone();
|
let mut updated_cookie = cookie.clone();
|
||||||
@ -1296,12 +1303,13 @@ mod tests {
|
|||||||
let resp = cli.get(&format!("{}/api/", &s.base_url))
|
let resp = cli.get(&format!("{}/api/", &s.base_url))
|
||||||
.header(reqwest::header::COOKIE, cookie.header())
|
.header(reqwest::header::COOKIE, cookie.header())
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
assert_eq!(resp.status(), reqwest::StatusCode::UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn view_without_segments() {
|
async fn view_without_segments() {
|
||||||
testutil::init();
|
testutil::init();
|
||||||
let mut permissions = db::Permissions::new();
|
let mut permissions = db::Permissions::new();
|
||||||
permissions.view_video = true;
|
permissions.view_video = true;
|
||||||
@ -1309,7 +1317,7 @@ mod tests {
|
|||||||
let cli = reqwest::Client::new();
|
let cli = reqwest::Client::new();
|
||||||
let resp = cli.get(
|
let resp = cli.get(
|
||||||
&format!("{}/api/cameras/{}/main/view.mp4", &s.base_url, s.db.test_camera_uuid))
|
&format!("{}/api/cameras/{}/main/view.mp4", &s.base_url, s.db.test_camera_uuid))
|
||||||
.send().unwrap();
|
.send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
assert_eq!(resp.status(), reqwest::StatusCode::BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user