Fix invalid digest test.

This commit is contained in:
Adam Kelly 2020-08-19 14:26:55 +01:00
parent 8fc67d7b3c
commit 2e080055ea

View file

@ -33,7 +33,7 @@ class Signature(TestCase):
public_key, public_key,
) )
def send(self, signature, now, data): def send(self, signature, now, data, digest):
c = Client() c = Client()
return c.post( return c.post(
urlsplit(self.rat.inbox).path, urlsplit(self.rat.inbox).path,
@ -42,7 +42,7 @@ class Signature(TestCase):
**{ **{
'HTTP_DATE': now, 'HTTP_DATE': now,
'HTTP_SIGNATURE': signature, 'HTTP_SIGNATURE': signature,
'HTTP_DIGEST': make_digest(data), 'HTTP_DIGEST': digest,
'HTTP_CONTENT_TYPE': 'application/activity+json; charset=utf-8', 'HTTP_CONTENT_TYPE': 'application/activity+json; charset=utf-8',
'HTTP_HOST': DOMAIN, 'HTTP_HOST': DOMAIN,
} }
@ -57,9 +57,10 @@ class Signature(TestCase):
date=None): date=None):
now = date or http_date() now = date or http_date()
data = get_follow_data(sender, self.rat) data = get_follow_data(sender, self.rat)
digest = digest or make_digest(data)
signature = make_signature( signature = make_signature(
signer or sender, self.rat.inbox, now, digest or make_digest(data)) signer or sender, self.rat.inbox, now, digest)
return self.send(signature, now, send_data or data) return self.send(signature, now, send_data or data, digest)
def test_correct_signature(self): def test_correct_signature(self):
response = self.send_test_request(sender=self.mouse) response = self.send_test_request(sender=self.mouse)