-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #572: New E2E test: download torrent in private mode
7e67008 test: [#414] download torrent in private mode (Jose Celano) Pull request description: It only checks that downloading a torrent works in private mode. This PR does not check that the downloaded torrent contains the tracker keys. The index should have a test for that. Sample torrent with tracker keys (in JSON): ```json { "announce": "http://tracker:7070//3PISvzYph3GYkjJvz39hhnUqANLeVC7r", "announce-list": [ [ "http://tracker:7070//3PISvzYph3GYkjJvz39hhnUqANLeVC7r" ], [ "udp://tracker.torrust-demo.com:6969" ], [ "udp://tracker.coppersurfer.tk:6969/announce" ], [ "udp://9.rarbg.com:2710/announce" ], [ "udp://p4p.arenabg.com:1337" ], [ "udp://tracker.leechers-paradise.org:6969" ], [ "udp://tracker.internetwarriors.net:1337" ], [ "udp://tracker.opentrackr.org:1337/announce" ], [ "http://tracker.openbittorrent.com:80/announce" ], [ "udp://opentracker.i2p.rocks:6969/announce" ], [ "udp://tracker.internetwarriors.net:1337/announce" ], [ "udp://tracker.leechers-paradise.org:6969/announce" ], [ "udp://coppersurfer.tk:6969/announce" ], [ "udp://tracker.zer0day.to:1337/announce" ] ], "creation date": 1713791389, "info": { "files": [ { "length": 2142878501, "path": [ "Spirited.Away.2001.1080p.BluRay.x264-[YTS.AM].mp4" ] }, { "length": 58132, "path": [ "www.YTS.AM.jpg" ] } ], "name": "Spirited Away (2001) [BluRay] [1080p] [YTS.AM]", "piece length": 524288, "pieces": "<hex>1D 99 72 BF 0A E7 F0 D8 61 86 D7 AE 3B 59 A9 EF FA 5E CB 04 2D DB 14 04 A3 C0 82 0E DA 0B 7F 73 E5 5B 07 84 31 45 0C 06 4C BF 59 22 89 87 82 6B 71 D9 A8 A4 3C ... 20 4C 80 FB C7 EA</hex>" } } ``` ACKs for top commit: josecelano: ACK 7e67008 Tree-SHA512: a4344556323abc726abaa41e65fba413fa2d8f2eb80c17f86adb9e8060f233b9187df4f02f30ce3b0ed5a911b6f91212d3ae1fc06bd2ada023d2b9ccf06bfa58
- Loading branch information
Showing
13 changed files
with
149 additions
and
35 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
contrib/dev-tools/container/e2e/sqlite/mode/private/e2e-env-down.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.private.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.private.e2e.container.sqlite3.toml) \ | ||
docker compose down |
17 changes: 17 additions & 0 deletions
17
contrib/dev-tools/container/e2e/sqlite/mode/private/e2e-env-up.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.private.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.private.e2e.container.sqlite3.toml) \ | ||
docker compose build | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.private.e2e.container.sqlite3.toml) \ | ||
TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \ | ||
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \ | ||
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \ | ||
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.private.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \ | ||
TORRUST_TRACKER_CONFIG_OVERRIDE_DB_DRIVER="Sqlite3" \ | ||
TORRUST_TRACKER_CONFIG_OVERRIDE_HTTP_API__ACCESS_TOKENS__ADMIN="MyAccessToken" \ | ||
docker compose up --detach --pull always --remove-orphans |
4 changes: 2 additions & 2 deletions
4
...ools/container/e2e/sqlite/e2e-env-down.sh → ...er/e2e/sqlite/mode/public/e2e-env-down.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \ | ||
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.public.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.public.e2e.container.sqlite3.toml) \ | ||
docker compose down |
8 changes: 4 additions & 4 deletions
8
...-tools/container/e2e/sqlite/e2e-env-up.sh → ...iner/e2e/sqlite/mode/public/e2e-env-up.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { type RegistrationForm, random_user_registration_data } from "../../user/registration"; | ||
import { parseInfoHash } from "../api"; | ||
import { generateRandomTestTorrentInfo } from "../test_torrent_info"; | ||
|
||
describe("In private mode, a registered user", () => { | ||
let registration_form: RegistrationForm; | ||
|
||
before(() => { | ||
registration_form = random_user_registration_data(); | ||
cy.register_and_login(registration_form); | ||
}); | ||
|
||
after(() => { | ||
cy.delete_user_from_database(registration_form.username); | ||
}); | ||
|
||
if (Cypress.env("TRACKER_MODE") === "private") { | ||
it("should be able to download a preexisting torrent with the tracker key", () => { | ||
const torrent_info = generateRandomTestTorrentInfo(); | ||
|
||
cy.upload_torrent(torrent_info); | ||
|
||
cy.intercept({ | ||
method: "GET", | ||
url: "/*/torrent/download/*" | ||
}).as("download"); | ||
|
||
cy.get("button[data-cy=\"torrent-action-download\"]").click(); | ||
|
||
cy.wait("@download").then((interception) => { | ||
// Ensure the filename is correct | ||
expect(interception.response.headers["content-disposition"]).to.include(torrent_info.filename); | ||
|
||
// todo: ensure that the torrent contains the tracker key | ||
|
||
// Delete the test torrent generated for this test | ||
const torrentInfoHash = parseInfoHash(interception.response.headers["x-torrust-torrent-infohash"]); | ||
cy.delete_torrent_from_database_and_fixture(torrent_info, torrentInfoHash); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
share/default/config/index.private.e2e.container.sqlite3.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[tracker] | ||
url = "http://tracker:7070" | ||
mode = "Private" | ||
api_url = "http://tracker:1212" | ||
|
||
[database] | ||
connect_url = "sqlite:///var/lib/torrust/index/database/e2e_testing_sqlite3.db?mode=rwc" | ||
|
||
[mail] | ||
server = "mailcatcher" | ||
port = 1025 |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
share/default/config/tracker.private.e2e.container.sqlite3.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
mode = "private" | ||
db_path = "/var/lib/torrust/tracker/database/e2e_testing_sqlite3.db" | ||
|
||
[[udp_trackers]] | ||
enabled = false | ||
|
||
[http_api] | ||
bind_address = "0.0.0.0:1212" |
File renamed without changes.