-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5074 from zenmonkeykstop/4757-source-urls-in-meta…
…data Adds v2 and v3 source interface urls to metadata endpoint.
- Loading branch information
Showing
5 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
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
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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
from source_app.utils import check_url_file | ||
|
||
|
||
def test_check_url_file(config): | ||
|
||
assert check_url_file("nosuchfile", "whatever") is None | ||
|
||
try: | ||
def write_url_file(path, content): | ||
url_file = open(path, "w") | ||
url_file.write("{}\n".format(content)) | ||
|
||
url_path = "test_source_url" | ||
|
||
onion_test_url = "abcdabcdabcdabcd.onion" | ||
write_url_file(url_path, onion_test_url) | ||
assert check_url_file(url_path, r"^[a-z0-9]{16}\.onion$") == onion_test_url | ||
|
||
onion_test_url = "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh.onion" | ||
write_url_file(url_path, onion_test_url) | ||
assert check_url_file(url_path, r"^[a-z0-9]{56}\.onion$") == onion_test_url | ||
|
||
write_url_file(url_path, "NO.onion") | ||
assert check_url_file(url_path, r"^[a-z0-9]{56}\.onion$") is None | ||
finally: | ||
if os.path.exists(url_path): | ||
os.unlink(url_path) |