From 8f65f6c709b57c3ba560ea5886389ce13d7f9b63 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 16 Oct 2023 21:44:29 +0100 Subject: [PATCH] Fix unit tests --- epicyon.py | 4 ++-- posts.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/epicyon.py b/epicyon.py index 5bbe93dd3..64d488ee2 100644 --- a/epicyon.py +++ b/epicyon.py @@ -63,7 +63,7 @@ from follow import clear_follows from follow import add_follower_of_person from follow import send_follow_request_via_server from follow import send_unfollow_request_via_server -# from tests import test_shared_items_federation +from tests import test_shared_items_federation from tests import test_group_follow from tests import test_post_message_between_servers from tests import test_follow_between_servers @@ -820,7 +820,7 @@ def _command_options() -> None: if argb.testsnetwork: print('Network Tests') base_dir = os.getcwd() - # test_shared_items_federation(base_dir) + test_shared_items_federation(base_dir) test_group_follow(base_dir) test_post_message_between_servers(base_dir) test_follow_between_servers(base_dir) diff --git a/posts.py b/posts.py index 88152c22b..b877335c8 100644 --- a/posts.py +++ b/posts.py @@ -2837,13 +2837,14 @@ def send_post(signing_priv_key_pem: str, project_version: str, # NOTE: the inbox domain being sent to isn't always the same # as the destination instance domain. eg public-api.wordpress.com # rather than the wordpress instance domain - inbox_url_domain, _ = get_domain_from_actor(inbox_url) + inbox_url_domain, inbox_url_port = get_domain_from_actor(inbox_url) if inbox_url_domain: - if inbox_url_domain != to_domain: + inbox_domain = get_full_domain(inbox_url_domain, inbox_url_port) + if inbox_domain != to_domain: print('send_post ' + 'inbox domain is not the same as instance domain ' + - inbox_url_domain + ' != ' + to_domain) - to_domain = inbox_url_domain + inbox_domain + ' != ' + to_domain) + to_domain = inbox_domain if to_domain not in inbox_url: return 7 @@ -3271,13 +3272,14 @@ def send_signed_json(post_json_object: {}, session, base_dir: str, # NOTE: the inbox domain being sent to isn't always the same # as the destination instance domain. eg public-api.wordpress.com # rather than the wordpress instance domain - inbox_url_domain, _ = get_domain_from_actor(inbox_url) + inbox_url_domain, inbox_url_port = get_domain_from_actor(inbox_url) if inbox_url_domain: - if inbox_url_domain != to_domain: + inbox_domain = get_full_domain(inbox_url_domain, inbox_url_port) + if inbox_domain != to_domain: print('send_signed_json ' + 'inbox domain is not the same as instance domain ' + - inbox_url_domain + ' != ' + to_domain) - to_domain = inbox_url_domain + inbox_domain + ' != ' + to_domain) + to_domain = inbox_domain if to_domain not in inbox_url: if debug: