def testFromBERNullKnownValues(self): """BERNull(encoded="...") should give known result with known input""" encoded=[0x05, 0x00] m=MutableString(apply(s,encoded)) m.append('foo') result = pureber.BERNull(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m=='foo' assert 0x05==result.tag
def testFromBERNullKnownValues(self): """BERNull(encoded="...") should give known result with known input""" encoded = [0x05, 0x00] m = MutableString(apply(s, encoded)) m.append("foo") result = pureber.BERNull(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m == "foo" assert 0x05 == result.tag
def testFromBERIntegerKnownValues(self): """BERInteger(encoded="...") should give known result with known input""" for integer, encoded in self.knownValues: m = MutableString(apply(s, encoded)) m.append("foo") result = pureber.BERInteger(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m == "foo" result = result.value assert integer == result
def testSanity(self): """BEREnumerated(encoded=BEREnumerated(n)).value==n for -1000..1000""" for n in range(-1000, 1001, 10): encoded = MutableString(pureber.BEREnumerated(n)) encoded.append("foo") result = pureber.BEREnumerated(encoded=encoded, berdecoder=pureber.BERDecoderContext()) result = result.value assert encoded == "foo" assert n == result
def testSanity(self): """BEROctetString(encoded=BEROctetString(n*'x')).value==n*'x' for some values of n""" for n in 0, 1, 2, 3, 4, 5, 6, 100, 126, 127, 128, 129, 1000, 2000: encoded = MutableString(pureber.BEROctetString(n * "x")) encoded.append("foo") result = pureber.BEROctetString(encoded=encoded, berdecoder=pureber.BERDecoderContext()) result = result.value assert encoded == "foo" assert n * "x" == result
def testFromBERIntegerKnownValues(self): """BERInteger(encoded="...") should give known result with known input""" for integer, encoded in self.knownValues: m=MutableString(apply(s,encoded)) m.append('foo') result = pureber.BERInteger(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m=='foo' result = result.value assert integer==result
def testSanity(self): """BEROctetString(encoded=BEROctetString(n*'x')).value==n*'x' for some values of n""" for n in 0,1,2,3,4,5,6,100,126,127,128,129,1000,2000: encoded = MutableString(pureber.BEROctetString(n*'x')) encoded.append('foo') result = pureber.BEROctetString(encoded=encoded, berdecoder=pureber.BERDecoderContext()) result = result.value assert encoded=='foo' assert n*'x'==result
def testFromBEROctetStringKnownValues(self): """BEROctetString(encoded="...") should give known result with known input""" for st, encoded in self.knownValues: m = MutableString(apply(s, encoded)) m.append("foo") result = pureber.BEROctetString(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m == "foo" result = str(result) result = map(ord, result) assert encoded == result
def testSanity(self): """BEREnumerated(encoded=BEREnumerated(n)).value==n for -1000..1000""" for n in range(-1000, 1001, 10): encoded = MutableString(pureber.BEREnumerated(n)) encoded.append('foo') result = pureber.BEREnumerated(encoded=encoded, berdecoder=pureber.BERDecoderContext()) result = result.value assert encoded=='foo' assert n==result
def testFromBEROctetStringKnownValues(self): """BEROctetString(encoded="...") should give known result with known input""" for st, encoded in self.knownValues: m=MutableString(apply(s,encoded)) m.append('foo') result = pureber.BEROctetString(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m=='foo' result = str(result) result = map(ord, result) assert encoded==result
def testFromBERSequenceKnownValues(self): """BERSequence(encoded="...") should give known result with known input""" for content, encoded in self.knownValues: m = MutableString(apply(s, encoded)) m.append("foo") result = pureber.BERSequence(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m == "foo" result = result.data assert len(content) == len(result) for i in xrange(len(content)): assert content[i] == result[i] assert content == result
def testFromBERSequenceKnownValues(self): """BERSequence(encoded="...") should give known result with known input""" for content, encoded in self.knownValues: m=MutableString(apply(s,encoded)) m.append('foo') result = pureber.BERSequence(encoded=m, berdecoder=pureber.BERDecoderContext()) assert m=='foo' result = result.data assert len(content)==len(result) for i in xrange(len(content)): assert content[i]==result[i] assert content==result