Commit 4d92702e authored by Simo Sorce's avatar Simo Sorce Committed by Simo Sorce

Get the protected header from the right place

Modify test to check the header is emitted correctly
Signed-off-by: 's avatarSimo Sorce <simo@redhat.com>
Fixes #105
parent 3bc514d4
......@@ -496,7 +496,7 @@ class JWS(object):
jhl = list()
for o in obj['signatures']:
jh = dict()
if 'protected' in obj:
if 'protected' in o:
p = json_decode(o['protected'])
jh = self._merge_headers(jh, p)
jh = self._merge_headers(jh, o.get('header', dict()))
......
......@@ -570,7 +570,11 @@ A6_example = {
'key2': jwk.JWK(**A3_key),
'protected2': bytes(bytearray(A3_protected)).decode('utf-8'),
'header2': json_encode({"kid": "e9bc097a-ce51-4036-9562-d2ade882db0d"}),
'serialized': A6_serialized}
'serialized': A6_serialized,
'jose_header': [{"kid": "2010-12-29",
"alg": "RS256"},
{"kid": "e9bc097a-ce51-4036-9562-d2ade882db0d",
"alg": "ES256"}]}
A7_example = \
'{' + \
......@@ -644,6 +648,7 @@ class TestJWS(unittest.TestCase):
sig = s.serialize()
s.deserialize(sig, A6_example['key1'])
s.deserialize(A6_serialized, A6_example['key2'])
self.assertEqual(A6_example['jose_header'], s.jose_header)
def test_A7(self):
s = jws.JWS(A6_example['payload'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment