kopia lustrzana https://gitlab.com/marnanel/chapeau
post_test_message()
rodzic
dadff3a45d
commit
038d0ca2d1
|
@ -1,6 +1,7 @@
|
||||||
from django_kepi.models import create
|
from django_kepi.models import create
|
||||||
from django_kepi.validation import IncomingMessage, validate
|
from django_kepi.validation import IncomingMessage, validate
|
||||||
from django_kepi.models.actor import Actor
|
from django_kepi.models.actor import Actor
|
||||||
|
import django.test
|
||||||
import httpretty
|
import httpretty
|
||||||
import logging
|
import logging
|
||||||
import httpsig
|
import httpsig
|
||||||
|
@ -155,6 +156,43 @@ def test_message(secret='', **fields):
|
||||||
result.save()
|
result.save()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def post_test_message(
|
||||||
|
path, host,
|
||||||
|
secret,
|
||||||
|
f_id, f_type, f_actor, f_object,
|
||||||
|
client = None,
|
||||||
|
):
|
||||||
|
|
||||||
|
if client is None:
|
||||||
|
client = django.test.Client()
|
||||||
|
|
||||||
|
body, headers = test_message_body_and_headers(
|
||||||
|
f_id=f_id,
|
||||||
|
f_type=f_type,
|
||||||
|
f_actor=f_actor,
|
||||||
|
f_object=f_object,
|
||||||
|
secret = secret,
|
||||||
|
path = path,
|
||||||
|
host = host,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.debug("Test message is %s",
|
||||||
|
body)
|
||||||
|
logger.debug(" -- with headers %s",
|
||||||
|
headers)
|
||||||
|
|
||||||
|
client.post(
|
||||||
|
path = path,
|
||||||
|
content_type = headers['content-type'], # XXX why twice?
|
||||||
|
data = json.dumps(body),
|
||||||
|
CONTENT_TYPE = headers['content-type'],
|
||||||
|
HTTP_DATE = headers['date'],
|
||||||
|
HOST = headers['host'],
|
||||||
|
HTTP_SIGNATURE = headers['signature'],
|
||||||
|
)
|
||||||
|
|
||||||
|
return client
|
||||||
|
|
||||||
def remote_user(url, name,
|
def remote_user(url, name,
|
||||||
publicKey='',
|
publicKey='',
|
||||||
inbox=None,
|
inbox=None,
|
||||||
|
|
|
@ -30,32 +30,18 @@ class TestInbox(TestCase):
|
||||||
publicKey = keys['public'],
|
publicKey = keys['public'],
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
|
|
||||||
body, headers = test_message_body_and_headers(
|
|
||||||
f_id=ACTIVITY_ID,
|
|
||||||
f_type="Follow",
|
|
||||||
f_actor=REMOTE_FRED,
|
|
||||||
f_object=LOCAL_ALICE,
|
|
||||||
secret = keys['private'],
|
|
||||||
path = ALICE_INBOX,
|
|
||||||
host = 'europa.example.com',
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.debug("Test message is %s",
|
|
||||||
body)
|
|
||||||
logger.debug(" -- with headers %s",
|
|
||||||
headers)
|
|
||||||
|
|
||||||
c = Client()
|
c = Client()
|
||||||
c.post(
|
|
||||||
ALICE_INBOX,
|
post_test_message(
|
||||||
content_type = 'application/activity+json',
|
client = c,
|
||||||
data = json.dumps(body),
|
path = ALICE_INBOX,
|
||||||
CONTENT_TYPE = headers['content-type'],
|
host = 'europa.example.com',
|
||||||
HTTP_DATE = headers['date'],
|
secret = keys['private'],
|
||||||
HOST = headers['host'],
|
f_id = ACTIVITY_ID,
|
||||||
HTTP_SIGNATURE = headers['signature'],
|
f_type = "Follow",
|
||||||
)
|
f_actor = REMOTE_FRED,
|
||||||
|
f_object = LOCAL_ALICE,
|
||||||
|
)
|
||||||
|
|
||||||
@httpretty.activate
|
@httpretty.activate
|
||||||
def test_shared_post(self):
|
def test_shared_post(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue