forked from mirrors/bookwyrm
Fixes celery mocks on more signature unit tests
This commit is contained in:
parent
73279d65d7
commit
829615cdd7
1 changed files with 57 additions and 56 deletions
|
@ -111,55 +111,56 @@ class Signature(TestCase):
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# @responses.activate
|
@responses.activate
|
||||||
# def test_key_needs_refresh(self):
|
def test_key_needs_refresh(self):
|
||||||
# datafile = pathlib.Path(__file__).parent.joinpath('data/ap_user.json')
|
datafile = pathlib.Path(__file__).parent.joinpath('data/ap_user.json')
|
||||||
# data = json.loads(datafile.read_bytes())
|
data = json.loads(datafile.read_bytes())
|
||||||
# data['id'] = self.fake_remote.remote_id
|
data['id'] = self.fake_remote.remote_id
|
||||||
# data['publicKey']['publicKeyPem'] = self.fake_remote.public_key
|
data['publicKey']['publicKeyPem'] = self.fake_remote.public_key
|
||||||
# del data['icon'] # Avoid having to return an avatar.
|
del data['icon'] # Avoid having to return an avatar.
|
||||||
# responses.add(
|
responses.add(
|
||||||
# responses.GET,
|
responses.GET,
|
||||||
# self.fake_remote.remote_id,
|
self.fake_remote.remote_id,
|
||||||
# json=data,
|
json=data,
|
||||||
# status=200)
|
status=200)
|
||||||
# responses.add(
|
responses.add(
|
||||||
# responses.GET,
|
responses.GET,
|
||||||
# 'https://localhost/.well-known/nodeinfo',
|
'https://localhost/.well-known/nodeinfo',
|
||||||
# status=404)
|
status=404)
|
||||||
# responses.add(
|
responses.add(
|
||||||
# responses.GET,
|
responses.GET,
|
||||||
# 'https://example.com/user/mouse/outbox?page=true',
|
'https://example.com/user/mouse/outbox?page=true',
|
||||||
# json={'orderedItems': []},
|
json={'orderedItems': []},
|
||||||
# status=200
|
status=200
|
||||||
# )
|
)
|
||||||
#
|
|
||||||
# # Second and subsequent fetches get a different key:
|
# Second and subsequent fetches get a different key:
|
||||||
# new_private_key, new_public_key = create_key_pair()
|
new_private_key, new_public_key = create_key_pair()
|
||||||
# new_sender = Sender(
|
new_sender = Sender(
|
||||||
# self.fake_remote.remote_id, new_private_key, new_public_key)
|
self.fake_remote.remote_id, new_private_key, new_public_key)
|
||||||
# data['publicKey']['publicKeyPem'] = new_public_key
|
data['publicKey']['publicKeyPem'] = new_public_key
|
||||||
# responses.add(
|
responses.add(
|
||||||
# responses.GET,
|
responses.GET,
|
||||||
# self.fake_remote.remote_id,
|
self.fake_remote.remote_id,
|
||||||
# json=data,
|
json=data,
|
||||||
# status=200)
|
status=200)
|
||||||
#
|
|
||||||
# # Key correct:
|
with patch('bookwyrm.remote_user.get_remote_reviews.delay') as _:
|
||||||
# response = self.send_test_request(sender=self.fake_remote)
|
# Key correct:
|
||||||
# self.assertEqual(response.status_code, 200)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
#
|
self.assertEqual(response.status_code, 200)
|
||||||
# # Old key is cached, so still works:
|
|
||||||
# response = self.send_test_request(sender=self.fake_remote)
|
# Old key is cached, so still works:
|
||||||
# self.assertEqual(response.status_code, 200)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
#
|
self.assertEqual(response.status_code, 200)
|
||||||
# # Try with new key:
|
|
||||||
# response = self.send_test_request(sender=new_sender)
|
# Try with new key:
|
||||||
# self.assertEqual(response.status_code, 200)
|
response = self.send_test_request(sender=new_sender)
|
||||||
#
|
self.assertEqual(response.status_code, 200)
|
||||||
# # Now the old key will fail:
|
|
||||||
# response = self.send_test_request(sender=self.fake_remote)
|
# Now the old key will fail:
|
||||||
# self.assertEqual(response.status_code, 401)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
|
self.assertEqual(response.status_code, 401)
|
||||||
|
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
|
@ -173,13 +174,13 @@ class Signature(TestCase):
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
self.assertEqual(response.status_code, 401)
|
self.assertEqual(response.status_code, 401)
|
||||||
|
|
||||||
# @pytest.mark.integration
|
@pytest.mark.integration
|
||||||
# def test_changed_data(self):
|
def test_changed_data(self):
|
||||||
# '''Message data must match the digest header.'''
|
'''Message data must match the digest header.'''
|
||||||
# response = self.send_test_request(
|
response = self.send_test_request(
|
||||||
# self.mouse,
|
self.mouse,
|
||||||
# send_data=get_follow_data(self.mouse, self.cat))
|
send_data=get_follow_data(self.mouse, self.cat))
|
||||||
# self.assertEqual(response.status_code, 401)
|
self.assertEqual(response.status_code, 401)
|
||||||
|
|
||||||
# @pytest.mark.integration
|
# @pytest.mark.integration
|
||||||
# def test_invalid_digest(self):
|
# def test_invalid_digest(self):
|
||||||
|
|
Loading…
Reference in a new issue