mirror of https://github.com/OpenKMIP/PyKMIP.git
Merge pull request #26 from OpenKMIP/bug/add-test-for-unsigned-enum
Adding test case for bug with unsigned Enumeration encoding
This commit is contained in:
commit
ac6a9edec7
|
@ -415,10 +415,9 @@ class Enumeration(Integer):
|
|||
|
||||
def __validate(self):
|
||||
if self.enum is not None:
|
||||
if type(self.enum) is not self.ENUM_TYPE:
|
||||
msg = ErrorStrings.BAD_EXP_RECV
|
||||
raise TypeError(msg.format(Enumeration.__name__, 'value',
|
||||
Enum, type(self.enum)))
|
||||
if not isinstance(self.enum, Enum):
|
||||
raise TypeError("expected {0}, observed {1}".format(
|
||||
type(self.enum), Enum))
|
||||
|
||||
def __repr__(self):
|
||||
return "{0}(value={1})".format(type(self).__name__, self.enum)
|
||||
|
|
|
@ -18,6 +18,7 @@ from testtools import TestCase
|
|||
|
||||
from kmip.core.enums import Tags
|
||||
from kmip.core.enums import Types
|
||||
from kmip.core.enums import OpaqueDataType
|
||||
|
||||
from kmip.core.utils import BytearrayStream
|
||||
|
||||
|
@ -905,6 +906,20 @@ class TestEnumeration(TestCase):
|
|||
len_rcv))
|
||||
self.assertEqual(encoding, result, self.bad_encoding)
|
||||
|
||||
def test_write_unsigned(self):
|
||||
"""
|
||||
Test that a large enumeration value is written correctly as an
|
||||
unsigned integer.
|
||||
"""
|
||||
encoding = (b'\x42\x00\x00\x05\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00'
|
||||
b'\x00\x00')
|
||||
e = Enumeration(OpaqueDataType.NONE)
|
||||
e.write(self.stream)
|
||||
result = self.stream.read()
|
||||
|
||||
self.assertEqual(len(encoding), len(result))
|
||||
self.assertEqual(encoding, result)
|
||||
|
||||
|
||||
class TestBoolean(TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue