Skip to content

Commit e189a0d

Browse files
committed
Test both encoding and decoding of ASN.1 OIDs
1 parent 2add134 commit e189a0d

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

gssapi/tests/test_raw.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -732,21 +732,32 @@ def test_basic_wrap_unwrap(self):
732732
unwrapped_message.should_be(b'test message')
733733

734734

735-
TEST_OIDS = {'SPNEGO': {'bytes': '\053\006\001\005\005\002',
736-
'string': '<OID 1.3.6.1.5.5.2>'},
737-
'KRB5': {'bytes': '\052\206\110\206\367\022\001\002\002',
738-
'string': '<OID 1.2.840.113554.1.2.2>'},
739-
'KRB5_OLD': {'bytes': '\053\005\001\005\002',
740-
'string': '<OID 1.3.5.1.5.2>'},
741-
'KRB5_WRONG': {'bytes': '\052\206\110\202\367\022\001\002\002',
742-
'string': '<OID 1.2.840.48018.1.2.2>'},
743-
'IAKERB': {'bytes': '\053\006\001\005\002\005',
744-
'string': '<OID 1.3.6.1.5.2.5>'}}
735+
TEST_OIDS = {'SPNEGO': {'bytes': b'\053\006\001\005\005\002',
736+
'string': '1.3.6.1.5.5.2'},
737+
'KRB5': {'bytes': b'\052\206\110\206\367\022\001\002\002',
738+
'string': '1.2.840.113554.1.2.2'},
739+
'KRB5_OLD': {'bytes': b'\053\005\001\005\002',
740+
'string': '1.3.5.1.5.2'},
741+
'KRB5_WRONG': {'bytes': b'\052\206\110\202\367\022\001\002\002',
742+
'string': '1.2.840.48018.1.2.2'},
743+
'IAKERB': {'bytes': b'\053\006\001\005\002\005',
744+
'string': '1.3.6.1.5.2.5'}}
745745

746746

747747
class TestOIDTransforms(unittest.TestCase):
748748
def test_decode_from_bytes(self):
749749
for oid in TEST_OIDS.values():
750750
o = gb.OID(elements=oid['bytes'])
751751
text = repr(o)
752-
text.should_be(oid['string'])
752+
text.should_be("<OID {0}>".format(oid['string']))
753+
754+
def test_encode_from_string(self):
755+
for oid in TEST_OIDS.values():
756+
o = gb.OID.from_int_seq(oid['string'])
757+
o.__bytes__().should_be(oid['bytes'])
758+
759+
def test_encode_from_int_seq(self):
760+
for oid in TEST_OIDS.values():
761+
int_seq = oid['string'].split('.')
762+
o = gb.OID.from_int_seq(int_seq)
763+
o.__bytes__().should_be(oid['bytes'])

0 commit comments

Comments
 (0)