kopia lustrzana https://gitlab.com/marnanel/chapeau
create_person() always creates an Actor object, even with no extra data for it.
test_message() split into test_message() and test_message_body_and_headers().2019-08-17
rodzic
b6fc2812d5
commit
34b6c59e30
|
@ -65,10 +65,6 @@ def create_person(name,
|
||||||
|
|
||||||
result = create(spec)
|
result = create(spec)
|
||||||
|
|
||||||
if actor_fields:
|
|
||||||
# XXX kepi should allow us to create
|
|
||||||
# XXX this using create(), as part of
|
|
||||||
# XXX the Thing creation
|
|
||||||
actor = Actor(
|
actor = Actor(
|
||||||
thing=result,
|
thing=result,
|
||||||
**actor_fields,
|
**actor_fields,
|
||||||
|
@ -100,16 +96,19 @@ def mock_remote_object(
|
||||||
status,
|
status,
|
||||||
content)
|
content)
|
||||||
|
|
||||||
def test_message(secret='', **fields):
|
def test_message_body_and_headers(secret='',
|
||||||
|
path=INBOX_PATH,
|
||||||
|
host=INBOX_HOST,
|
||||||
|
**fields):
|
||||||
|
|
||||||
body = dict([(f[2:],v) for f,v in fields.items() if f.startswith('f_')])
|
body = dict([(f[2:],v) for f,v in fields.items() if f.startswith('f_')])
|
||||||
body['@context'] = MESSAGE_CONTEXT
|
body['@context'] = MESSAGE_CONTEXT
|
||||||
body['Host'] = INBOX_HOST
|
body['Host'] = host,
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'content-type': "application/activity+json",
|
'content-type': "application/activity+json",
|
||||||
'date': "Thu, 04 Apr 2019 21:12:11 GMT",
|
'date': "Thu, 04 Apr 2019 21:12:11 GMT",
|
||||||
'host': INBOX_HOST,
|
'host': host,
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'key_id' in fields:
|
if 'key_id' in fields:
|
||||||
|
@ -127,13 +126,22 @@ def test_message(secret='', **fields):
|
||||||
headers = signer.sign(
|
headers = signer.sign(
|
||||||
headers,
|
headers,
|
||||||
method='POST',
|
method='POST',
|
||||||
path=INBOX_PATH,
|
path=path,
|
||||||
)
|
)
|
||||||
|
|
||||||
SIGNATURE = 'Signature'
|
SIGNATURE = 'Signature'
|
||||||
if headers['Authorization'].startswith(SIGNATURE):
|
if headers['Authorization'].startswith(SIGNATURE):
|
||||||
headers['Signature'] = headers['Authorization'][len(SIGNATURE)+1:]
|
headers['Signature'] = headers['Authorization'][len(SIGNATURE)+1:]
|
||||||
|
|
||||||
|
return body, headers
|
||||||
|
|
||||||
|
def test_message(secret='', **fields):
|
||||||
|
|
||||||
|
body, headers = test_message_body_and_headers(
|
||||||
|
secret,
|
||||||
|
**fields,
|
||||||
|
)
|
||||||
|
|
||||||
result = IncomingMessage(
|
result = IncomingMessage(
|
||||||
content_type = headers['content-type'],
|
content_type = headers['content-type'],
|
||||||
date = headers['date'],
|
date = headers['date'],
|
||||||
|
|
Ładowanie…
Reference in New Issue