Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using pyasn1.compat.octets #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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