summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Manfre2022-11-22 23:53:02 -0500
committerGitHub2022-11-22 21:53:02 -0700
commitf88efa40d497995a5f645d03f99345c804f808d7 (patch)
tree1989e2386dba401b2fed981120d779c399110556 /tests
parent96f863d5d8ffa2a326a889eb6b0f8c4c11efb200 (diff)
downloadtakahe-f88efa40d497995a5f645d03f99345c804f808d7.tar.gz
takahe-f88efa40d497995a5f645d03f99345c804f808d7.tar.bz2
takahe-f88efa40d497995a5f645d03f99345c804f808d7.zip
Code dedupe Webfinger and fix SystemActor inbox URL
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/users/views/test_activitypub.py34
2 files changed, 19 insertions, 17 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 69e8e7a..48ee95a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -74,7 +74,7 @@ def identity(user):
"""
domain = Domain.objects.create(domain="example.com", local=True, public=True)
identity = Identity.objects.create(
- actor_uri="https://example.com/test-actor/",
+ actor_uri="https://example.com/@test@example.com/",
username="test",
domain=domain,
name="Test User",
diff --git a/tests/users/views/test_activitypub.py b/tests/users/views/test_activitypub.py
index 72ab8c3..d9ad578 100644
--- a/tests/users/views/test_activitypub.py
+++ b/tests/users/views/test_activitypub.py
@@ -1,26 +1,11 @@
import pytest
-from users.models import Domain, Identity, User
-
@pytest.mark.django_db
-def test_webfinger_actor(client):
+def test_webfinger_actor(client, identity):
"""
Ensures the webfinger and actor URLs are working properly
"""
- # Make a user
- user = User.objects.create(email="test@example.com")
- # Make a domain
- domain = Domain.objects.create(domain="example.com", local=True)
- domain.users.add(user)
- # Make an identity for them
- identity = Identity.objects.create(
- actor_uri="https://example.com/@test@example.com/",
- username="test",
- domain=domain,
- name="Test User",
- local=True,
- )
identity.generate_keypair()
# Fetch their webfinger
data = client.get("/.well-known/webfinger?resource=acct:test@example.com").json()
@@ -29,3 +14,20 @@ def test_webfinger_actor(client):
# Fetch their actor
data = client.get("/@test@example.com/", HTTP_ACCEPT="application/ld+json").json()
assert data["id"] == "https://example.com/@test@example.com/"
+
+
+@pytest.mark.django_db
+def test_webfinger_system_actor(client):
+ """
+ Ensures the webfinger and actor URLs are working properly for system actor
+ """
+ # Fetch their webfinger
+ data = client.get(
+ "/.well-known/webfinger?resource=acct:__system__@example.com"
+ ).json()
+ assert data["subject"] == "acct:__system__@example.com"
+ assert data["aliases"][0] == "https://example.com/about/"
+ # Fetch their actor
+ data = client.get("/actor/", HTTP_ACCEPT="application/ld+json").json()
+ assert data["id"] == "https://example.com/actor/"
+ assert data["inbox"] == "https://example.com/actor/inbox/"