Validate transfer control IDs and verify paused downloads on beta14
This commit is contained in:
1 parent
c6cb35366e
commit
b4e084dd25
7 files changed
+107
-1
No files matched your search
@@ -365,7 +365,10 @@ pub(crate) fn validate(request: &mut Request) -> Result<(), ErrorObj> {
|
||||
check_password(password)?; check_host_path("source", source)?;
|
||||
}
|
||||
Request::FetchImage { channel_id, path } => { channel(*channel_id)?; check_remote_item(path)?; }
|
||||
Request::Cancel { .. } | Request::Pause { .. } | Request::Resume { .. } | Request::Transfers => {}
|
||||
Request::Cancel { transfer_id } | Request::Pause { transfer_id } | Request::Resume { transfer_id } => {
|
||||
if *transfer_id == 0 { return Err(bad("transfer_id must be positive")); }
|
||||
}
|
||||
Request::Transfers => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -308,6 +308,23 @@ fn file_browser_rejects_invalid_list_before_connection() {
|
||||
core.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transfer_controls_validate_the_id_before_connection_lookup() {
|
||||
let dir = TempDir::new("transfer-control-ids");
|
||||
let mut core = Core::start(&dir.0);
|
||||
for cmd in ["file_cancel", "file_pause", "file_resume"] {
|
||||
for id in [0, u64::from(u32::MAX) + 1] {
|
||||
let (reply, _) = core.request("invalid-id", cmd, json!({"transfer_id":id}));
|
||||
assert_eq!(reply["error"]["code"], "bad_request", "{cmd}: {reply}");
|
||||
}
|
||||
for id in [1, u32::MAX] {
|
||||
let (reply, _) = core.request("valid-id", cmd, json!({"transfer_id":id}));
|
||||
assert_eq!(reply["error"]["code"], "not_connected", "{cmd}: {reply}");
|
||||
}
|
||||
}
|
||||
core.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publisher_commands_validate_through_real_stdio_without_server() {
|
||||
let dir = TempDir::new("publisher");
|
||||
|
||||
Reference in new issue
Block a user