TagClassUniversal,
))
tag_forms = sampled_from((TagFormConstructed, TagFormPrimitive))
+decode_path_strat = lists(integers(), max_size=3).map(
+ lambda decode_path: tuple(str(dp) for dp in decode_path)
+)
class TestHex(TestCase):
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Boolean().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_expl_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Boolean(expl=Boolean.tag_default).decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Boolean().decode(
Boolean.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_expl_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Boolean(expl=Boolean.tag_default).decode(
Boolean.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Integer().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Integer().decode(
Integer.tag_default + len_encode(l)[:-1],
@given(
sets(integers(), min_size=2, max_size=2),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_invalid_bounds_while_decoding(self, ints, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
value, bound_min = list(sorted(ints))
class Int(Integer):
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
BitString().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
BitString().decode(
BitString.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
OctetString().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
OctetString().decode(
OctetString.tag_default + len_encode(l)[:-1],
@given(
sets(integers(min_value=0, max_value=10), min_size=2, max_size=2),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_invalid_bounds_while_decoding(self, ints, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
value, bound_min = list(sorted(ints))
class String(OctetString):
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Null().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Null().decode(
Null.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
ObjectIdentifier().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
ObjectIdentifier().decode(
ObjectIdentifier.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
self.base_klass.tag_default + len_encode(l)[:-1],
@given(
sets(integers(min_value=0, max_value=10), min_size=2, max_size=2),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_invalid_bounds_while_decoding(self, ints, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
value, bound_min = list(sorted(ints))
class String(self.base_klass):
@given(
sets(integers(min_value=0, max_value=10), min_size=2, max_size=2),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_invalid_bounds_while_decoding(self, ints, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
value, bound_min = list(sorted(ints))
class String(self.base_klass):
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Any().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
Any().decode(
Any.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
self.base_klass.tag_default + len_encode(l)[:-1],
@given(
integers(min_value=31),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_tag(self, tag, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
tag_encode(tag)[:-1],
@given(
integers(min_value=128),
integers(min_value=0),
- lists(integers()),
+ decode_path_strat,
)
def test_bad_len(self, l, offset, decode_path):
- decode_path = tuple(str(i) for i in decode_path)
with self.assertRaises(DecodeError) as err:
self.base_klass().decode(
self.base_klass.tag_default + len_encode(l)[:-1],