Skip to content

Commit

Permalink
Stop using pyasn1.compat.octets
Browse files Browse the repository at this point in the history
It was removed from pyasn1 in
pyasn1/pyasn1@6f770ba

Fixes #19.
  • Loading branch information
heirecka committed Sep 25, 2024
1 parent 36b0363 commit 079c176
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
3 changes: 1 addition & 2 deletions tests/test_pem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
import unittest

from pyasn1.compat.octets import ints2octs
from pyasn1_modules import pem


Expand Down Expand Up @@ -93,7 +92,7 @@ def testReadBase64fromText(self):
24, 102, 241, 236, 50
]

self.assertEqual(ints2octs(expected), binary)
self.assertEqual(bytes(expected), binary)


suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
Expand Down
3 changes: 1 addition & 2 deletions tests/test_rfc3770.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc5480
Expand Down Expand Up @@ -79,7 +78,7 @@ def testOpenTypes(self):
self.assertEqual(extn['extnValue'], der_encoder(extnValue))

if extn['extnID'] == rfc3770.id_pe_wlanSSID:
self.assertIn(str2octs('Example'), extnValue)
self.assertIn(b'Example', extnValue)

if extn['extnID'] == rfc5280.id_ce_extKeyUsage:
self.assertIn(rfc3770.id_kp_eapOverLAN, extnValue)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_rfc4073.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc2634
Expand Down Expand Up @@ -131,7 +130,7 @@ def testOpenTypes(self):

self.assertIn(next_ci['contentType'], rfc5652.cmsContentTypesMap)
self.assertEqual(rfc5652.id_data, next_ci['contentType'])
self.assertIn(str2octs('Content-Type: text'), next_ci['content'])
self.assertIn(b'Content-Type: text', next_ci['content'])

for attr in ci['content']['attrs']:
self.assertIn(attr['attrType'], rfc5652.cmsAttributesMap)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_rfc4334.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc5280
Expand Down Expand Up @@ -67,7 +66,7 @@ def testOpenTypes(self):
self.assertEqual(extn['extnValue'], der_encoder(extnValue))

if extn['extnID'] == rfc4334.id_pe_wlanSSID:
self.assertIn( str2octs('Example'), extnValue)
self.assertIn(b'Example', extnValue)

if extn['extnID'] == rfc5280.id_ce_extKeyUsage:
self.assertIn(rfc4334.id_kp_eapOverLAN, extnValue)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_rfc5755.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc5280
Expand Down Expand Up @@ -85,7 +84,7 @@ def testOpenTypes(self):
count += 1
if attr['type'] == rfc5755.id_aca_authenticationInfo:
self.assertEqual(
str2octs('password'), attr['values'][0]['authInfo'])
b'password', attr['values'][0]['authInfo'])

self.assertEqual(5, count)

Expand Down
7 changes: 3 additions & 4 deletions tests/test_rfc6032.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc5652
Expand Down Expand Up @@ -64,7 +63,7 @@ def testDerCodec(self):
self.assertFalse(rest)
self.assertTrue(keyid.prettyPrint())
self.assertEqual(attrVal0, der_encoder(keyid))
self.assertEqual(str2octs('ptf-kdc-812374'), keyid)
self.assertEqual(b'ptf-kdc-812374', keyid)

def testOpenTypes(self):
substrate = pem.readBase64fromText(self.encrypted_key_pkg_pem_text)
Expand All @@ -86,8 +85,8 @@ def testOpenTypes(self):
self.assertNotEqual('0x', attr['attrValues'][0].prettyPrint()[:2])

if attr['attrType'] == rfc6032.id_aa_KP_contentDecryptKeyID:
self.assertEqual(str2octs(
'ptf-kdc-812374'), attr['attrValues'][0])
self.assertEqual(
b'ptf-kdc-812374', attr['attrValues'][0])


suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
Expand Down
1 change: 0 additions & 1 deletion tests/test_rfc6120.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.codec.der.encoder import encode as der_encoder
from pyasn1.compat.octets import str2octs

from pyasn1_modules import pem
from pyasn1_modules import rfc5280
Expand Down

0 comments on commit 079c176

Please sign in to comment.