Handle date_deletion_requested in user-modified webhook D10139

This commit is contained in:
Anna Sirota
2021-01-20 10:43:11 +01:00
parent b6127c736d
commit 6b835e74f1
2 changed files with 65 additions and 0 deletions

View File

@@ -82,6 +82,29 @@ class UserModifiedTest(AbstractWebhookTest):
self.assertEqual('ကြယ်ဆွတ်', db_user['full_name'])
self.assertEqual(['subscriber'], db_user['roles'])
def test_date_deletion_requested_is_set(self):
payload = {'id': 1112333,
'old_email': 'old@email.address',
'full_name': 'ကြယ်ဆွတ်',
'email': 'new.address+here-there@email.address',
'roles': ['cloud_subscriber'],
'date_deletion_requested': '2020-12-31T23:02:03+00:00'}
as_json = json.dumps(payload).encode()
mac = hmac.new(self.hmac_secret,
as_json, hashlib.sha256)
self.post('/api/webhooks/user-modified',
data=as_json,
content_type='application/json',
headers={'X-Webhook-HMAC': mac.hexdigest()},
expected_status=204)
# Check the effect on the user
db_user = self.fetch_user_from_db(self.uid)
self.assertIsNone(db_user['email'])
self.assertIsNone(db_user['full_name'])
self.assertIsNone(db_user['username'])
self.assertTrue(db_user['_deleted'])
def test_change_email_unknown_old(self):
payload = {'id': 1112333,
'old_email': 'ancient@email.address',