Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parameterization(self):
specs = []
for codec in CODECS:
specs.append(asn1tools.compile_dict(deepcopy(PARAMETERIZATION),
codec))
# A-Boolean.
decoded = {'a': True}
encoded_messages = [
b'\x30\x05\xa0\x03\x01\x01\xff',
b'\x30\x05\xa0\x03\x01\x01\xff',
b'{"a": true}',
b'\xff',
b'\x80',
b'\x80',
b'<a></a>'
]
for spec, codec, encoded in zip(specs, CODECS, encoded_messages):
def test_rfc5280_errors(self):
rfc5280 = asn1tools.compile_dict(deepcopy(RFC5280))
# Empty data.
encoded = b''
with self.assertRaises(asn1tools.DecodeError) as cm:
rfc5280.decode('Certificate', encoded)
self.assertEqual(
str(cm.exception),
"Expected SEQUENCE with tag '30' at offset 0, but got ''.")
# Only tag and length, no contents.
encoded = b'\x30\x81\x9f'
with self.assertRaises(asn1tools.DecodeError) as cm:
rfc5280.decode('Certificate', encoded)
def test_ieee1609_2(self):
foo = asn1tools.compile_dict(deepcopy(IEEE1609_2), 'oer')
decoded = {
'version': 1,
'content': (
'caCerts',
[
{
'version': 3,
'type': 'explicit',
'issuer': ('sha256AndDigest', 8 * b'\x01'),
'toBeSigned': {
'id': ('none', None),
'cracaId': 3 * b'\x32',
'crlSeries': 65535,
'validityPeriod': {
'start': 12345,
def test_rrc_8_6_0(self):
rrc = asn1tools.compile_dict(deepcopy(RRC_8_6_0), 'gser')
decoded = {
'message': (
'c1',
(
'systemInformation',
{
'criticalExtensions': (
'systemInformation-r8',
{
'sib-TypeAndInfo': [
(
'sib2',
{
'ac-BarringInfo': {
'ac-BarringForEmergency': True,
def test_rfc4511(self):
rfc4511 = asn1tools.compile_dict(deepcopy(RFC4511))
# A search request message.
decoded = {
'messageID': 2,
'protocolOp': (
'searchRequest',
{
'baseObject': b'',
'scope': 'wholeSubtree',
'derefAliases': 'neverDerefAliases',
'sizeLimit': 0,
'timeLimit': 0,
'typesOnly': False,
'filter': (
'and',
[
def test_rrc_8_6_0(self):
rrc = asn1tools.compile_dict(deepcopy(RRC_8_6_0), 'xer')
# Message 1.
decoded = {
'message': (
'c1',
(
'paging',
{
'systemInfoModification': 'true',
'nonCriticalExtension': {
}
}
)
)
}
def test_lpp_14_3_0(self):
lpp = asn1tools.compile_dict(deepcopy(LPP_14_3_0), 'uper')
# Message 1.
decoded = {
'transactionID': {
'initiator': 'targetDevice',
'transactionNumber': 254
},
'endTransaction': True,
'lpp-MessageBody': (
'c1',
(
'provideAssistanceData',
{
'criticalExtensions': (
'c1',
(
def test_oma_ulp(self):
ulp = asn1tools.compile_dict(deepcopy(OMA_ULP), 'uper')
decoded = {
'length': 162,
'version': {'maj': 2, 'min': 0, 'servind': 0},
'sessionID': {
'setSessionID': {
'sessionId': 8838,
'setId': ('imsi', b'\x64\x00\x00\x00\x00\x00\x20\xf2')
},
'slpSessionID': {
'sessionID': b'\x00\x00\x40\x00',
'slpId': ('iPAddress', ('ipv4Address', b'\x7f\x00\x00\x01'))
}
},
'message': (
'msSUPLPOSINIT', {
def test_rrc_8_6_0(self):
rrc = asn1tools.compile_dict(deepcopy(RRC_8_6_0), 'uper')
# Message 1.
decoded = {
'message': (
'c1',
(
'paging',
{
'systemInfoModification': 'true',
'nonCriticalExtension': {
}
}
)
)
}