From b9d33296a135db03a530ab807ddd4a2ec26afe28 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 3 Jan 2021 15:27:59 +0000 Subject: [PATCH] Check for changing json signature --- tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests.py b/tests.py index 740f092bd..70421cd3c 100644 --- a/tests.py +++ b/tests.py @@ -2034,6 +2034,24 @@ def testJsonld(): # signedDocument['object']['content'] = 'forged content' # assert(not jsonldVerify(signedDocument, publicKeyPem)) + jldDocument2 = { + "description": "Another json document", + "numberField": 13353, + "object": { + "content": "More content" + } + } + signedDocument2 = testSignJsonld(jldDocument2, privateKeyPem) + assert(signedDocument2) + assert(signedDocument2.get('signature')) + assert(signedDocument2['signature'].get('signatureValue')) + # changed signature on different document + if signedDocument['signature']['signatureValue'] == \ + signedDocument2['signature']['signatureValue']: + print('json signature has not changed for different documents') +# assert(signedDocument['signature']['signatureValue'] != +# signedDocument2['signature']['signatureValue']) + def testSiteIsActive(): print('testSiteIsActive')