1
1
import json
2
2
3
3
import pytest
4
- import six
5
4
6
5
import jose .backends
7
6
from jose import jwe
@@ -429,7 +428,7 @@ def test_alg_enc_headers(self):
429
428
enc = ALGORITHMS .A256CBC_HS512
430
429
alg = ALGORITHMS .RSA_OAEP_256
431
430
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg )
432
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
431
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
433
432
assert header ["enc" ] == enc
434
433
assert header ["alg" ] == alg
435
434
@@ -439,15 +438,15 @@ def test_cty_header_present_when_provided(self):
439
438
alg = ALGORITHMS .RSA_OAEP_256
440
439
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg ,
441
440
cty = "expected" )
442
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
441
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
443
442
assert header ["cty" ] == "expected"
444
443
445
444
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
446
445
def test_cty_header_not_present_when_not_provided (self ):
447
446
enc = ALGORITHMS .A256CBC_HS512
448
447
alg = ALGORITHMS .RSA_OAEP_256
449
448
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg )
450
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
449
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
451
450
assert "cty" not in header
452
451
453
452
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
@@ -456,15 +455,15 @@ def test_zip_header_present_when_provided(self):
456
455
alg = ALGORITHMS .RSA_OAEP_256
457
456
encrypted = jwe .encrypt (b"Text" , PUBLIC_KEY_PEM , enc , alg ,
458
457
zip = ZIPS .DEF )
459
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
458
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
460
459
assert header ["zip" ] == ZIPS .DEF
461
460
462
461
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
463
462
def test_zip_header_not_present_when_not_provided (self ):
464
463
enc = ALGORITHMS .A256CBC_HS512
465
464
alg = ALGORITHMS .RSA_OAEP_256
466
465
encrypted = jwe .encrypt (b"Text" , PUBLIC_KEY_PEM , enc , alg )
467
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
466
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
468
467
assert "zip" not in header
469
468
470
469
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
@@ -473,7 +472,7 @@ def test_zip_header_not_present_when_none(self):
473
472
alg = ALGORITHMS .RSA_OAEP_256
474
473
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg ,
475
474
zip = ZIPS .NONE )
476
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
475
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
477
476
assert "zip" not in header
478
477
479
478
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
@@ -482,13 +481,13 @@ def test_kid_header_present_when_provided(self):
482
481
alg = ALGORITHMS .RSA_OAEP_256
483
482
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg ,
484
483
kid = "expected" )
485
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
484
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
486
485
assert header ["kid" ] == "expected"
487
486
488
487
@pytest .mark .skipif (AESKey is None , reason = "No AES backend" )
489
488
def test_kid_header_not_present_when_not_provided (self ):
490
489
enc = ALGORITHMS .A256CBC_HS512
491
490
alg = ALGORITHMS .RSA_OAEP_256
492
491
encrypted = jwe .encrypt ("Text" , PUBLIC_KEY_PEM , enc , alg )
493
- header = json .loads (six . ensure_str ( base64url_decode (encrypted .split (b"." )[0 ]) ))
492
+ header = json .loads (base64url_decode (encrypted .split (b"." )[0 ]))
494
493
assert "kid" not in header
0 commit comments