diff --git a/protocol.py b/protocol.py index f90687d..dc0df59 100644 --- a/protocol.py +++ b/protocol.py @@ -81,10 +81,10 @@ class Protocol: :class:`Protocol` subclass, or None if the provided domain or request hostname domain is not a subdomain of brid.gy or isn't a known protocol """ - return Protocol.for_domain(request.host, fed=fed) + return Protocol.for_bridgy_subdomain(request.host, fed=fed) @staticmethod - def for_domain(domain_or_url, fed=None): + def for_bridgy_subdomain(domain_or_url, fed=None): """Returns the protocol for a brid.gy subdomain. Args: @@ -183,10 +183,10 @@ class Protocol: # step 1: check for our per-protocol subdomains if util.is_web(id): - by_domain = Protocol.for_domain(id) - if by_domain: - logger.info(f' {by_domain.__name__} owns {id}') - return by_domain + by_subdomain = Protocol.for_bridgy_subdomain(id) + if by_subdomain: + logger.info(f' {by_subdomain.__name__} owns {id}') + return by_subdomain # step 2: check if any Protocols say conclusively that they own it # sort to be deterministic diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 751f6eb..6f3f434 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -44,7 +44,7 @@ class ProtocolTest(TestCase): self.assertEqual(Web, PROTOCOLS['web']) self.assertEqual(Web, PROTOCOLS['webmention']) - def test_for_domain_for_request(self): + def test_for_bridgy_subdomain_for_request(self): for domain, expected in [ ('fake.brid.gy', Fake), ('ap.brid.gy', ActivityPub), @@ -60,11 +60,11 @@ class ProtocolTest(TestCase): ('fake.com', None), ]: with self.subTest(domain=domain, expected=expected): - self.assertEqual(expected, Protocol.for_domain(domain)) + self.assertEqual(expected, Protocol.for_bridgy_subdomain(domain)) with app.test_request_context('/foo', base_url=f'https://{domain}/'): self.assertEqual(expected, Protocol.for_request()) - def test_for_domain_for_request_fed(self): + def test_for_bridgy_subdomain_for_request_fed(self): for url, expected in [ ('https://fed.brid.gy/', Fake), ('http://localhost/foo', Fake), @@ -72,7 +72,8 @@ class ProtocolTest(TestCase): ('https://baz/biff', None), ]: with self.subTest(url=url, expected=expected): - self.assertEqual(expected, Protocol.for_domain(url, fed=Fake)) + self.assertEqual(expected, + Protocol.for_bridgy_subdomain(url, fed=Fake)) with app.test_request_context('/foo', base_url=url): self.assertEqual(expected, Protocol.for_request(fed=Fake)) diff --git a/webfinger.py b/webfinger.py index c45771c..327b5c2 100644 --- a/webfinger.py +++ b/webfinger.py @@ -50,7 +50,7 @@ class Webfinger(flask_util.XrdOrJrd): cls = None try: user, id = util.parse_acct_uri(resource) - cls = Protocol.for_domain(id, fed=Web) + cls = Protocol.for_bridgy_subdomain(id, fed=Web) if cls: id = user allow_indirect = True