Skip to content

Commit a09cadb

Browse files
committed
test: new test for registered users to update torrents someone elses torrents
1 parent e1f87e2 commit a09cadb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/e2e/web/api/v1/contexts/torrent/contract.rs

+33
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,39 @@ mod for_authenticated_users {
11971197

11981198
assert_eq!(response.status, 403);
11991199
}
1200+
#[tokio::test]
1201+
async fn it_should_allow_registered_users_to_update_their_own_torrents() {
1202+
let mut env = TestEnv::new();
1203+
env.start(api::Version::V1).await;
1204+
1205+
if !env.provides_a_tracker() {
1206+
println!("test skipped. It requires a tracker to be running.");
1207+
return;
1208+
}
1209+
1210+
// Given a users uploads a torrent
1211+
let uploader = new_logged_in_user(&env).await;
1212+
let (test_torrent, _uploaded_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
1213+
1214+
let client = Client::authenticated(&env.server_socket_addr().unwrap(), &uploader.token);
1215+
1216+
let new_title = format!("{}-new-title", test_torrent.index_info.title);
1217+
let new_description = format!("{}-new-description", test_torrent.index_info.description);
1218+
1219+
let response = client
1220+
.update_torrent(
1221+
&test_torrent.file_info_hash(),
1222+
UpdateTorrentFrom {
1223+
title: Some(new_title.clone()),
1224+
description: Some(new_description.clone()),
1225+
category: None,
1226+
tags: None,
1227+
},
1228+
)
1229+
.await;
1230+
1231+
assert_eq!(response.status, 200);
1232+
}
12001233
}
12011234
}
12021235
}

0 commit comments

Comments
 (0)