mirror of https://github.com/OpenKMIP/PyKMIP.git
Update the Query payloads to rename Protection Storage Masks
This change makes a simple renaming update to the Query response payload, correcting how Protection Storage Masks are used and referenced. All related unit tests have been updated to reflect this change.
This commit is contained in:
parent
a2712e7541
commit
b4c3980da0
|
@ -224,7 +224,7 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
defaults_information: A DefaultsInformation structure detailing the
|
defaults_information: A DefaultsInformation structure detailing the
|
||||||
default attribute values used by the server for new managed
|
default attribute values used by the server for new managed
|
||||||
objects. Added in KMIP 2.0.
|
objects. Added in KMIP 2.0.
|
||||||
storage_protection_mask: A list of integers representing combined sets
|
protection__storage_mask: A list of integers representing combined sets
|
||||||
of ProtectionStorageMask enumerations detailing the storage
|
of ProtectionStorageMask enumerations detailing the storage
|
||||||
protections supported by the server. Added in KMIP 2.0.
|
protections supported by the server. Added in KMIP 2.0.
|
||||||
"""
|
"""
|
||||||
|
@ -242,7 +242,7 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
capability_information=None,
|
capability_information=None,
|
||||||
client_registration_methods=None,
|
client_registration_methods=None,
|
||||||
defaults_information=None,
|
defaults_information=None,
|
||||||
storage_protection_masks=None):
|
protection_storage_masks=None):
|
||||||
"""
|
"""
|
||||||
Construct a QueryResponsePayload object.
|
Construct a QueryResponsePayload object.
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
detailing the default attribute values used by the server for
|
detailing the default attribute values used by the server for
|
||||||
new managed objects. Optional, defaults to None. Added in
|
new managed objects. Optional, defaults to None. Added in
|
||||||
KMIP 2.0.
|
KMIP 2.0.
|
||||||
storage_protection_mask (list): A list of integers representing
|
protection__storage_masks (list): A list of integers representing
|
||||||
combined sets of ProtectionStorageMask enumerations detailing
|
combined sets of ProtectionStorageMask enumerations detailing
|
||||||
the storage protections supported by the server. Optional,
|
the storage protections supported by the server. Optional,
|
||||||
defaults to None. Added in KMIP 2.0.
|
defaults to None. Added in KMIP 2.0.
|
||||||
|
@ -322,7 +322,7 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
self.capability_information = capability_information
|
self.capability_information = capability_information
|
||||||
self.client_registration_methods = client_registration_methods
|
self.client_registration_methods = client_registration_methods
|
||||||
self.defaults_information = defaults_information
|
self.defaults_information = defaults_information
|
||||||
self.storage_protection_masks = storage_protection_masks
|
self.protection_storage_masks = protection_storage_masks
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def operations(self):
|
def operations(self):
|
||||||
|
@ -661,20 +661,20 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def storage_protection_masks(self):
|
def protection_storage_masks(self):
|
||||||
if self._storage_protection_masks:
|
if self._protection_storage_masks:
|
||||||
return [x.value for x in self._storage_protection_masks]
|
return [x.value for x in self._protection_storage_masks]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@storage_protection_masks.setter
|
@protection_storage_masks.setter
|
||||||
def storage_protection_masks(self, value):
|
def protection_storage_masks(self, value):
|
||||||
if value is None:
|
if value is None:
|
||||||
self._storage_protection_masks = None
|
self._protection_storage_masks = None
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
storage_protection_masks = []
|
protection_storage_masks = []
|
||||||
for i in value:
|
for i in value:
|
||||||
if isinstance(i, six.integer_types):
|
if isinstance(i, six.integer_types):
|
||||||
storage_protection_masks.append(
|
protection_storage_masks.append(
|
||||||
primitives.Integer(
|
primitives.Integer(
|
||||||
value=i,
|
value=i,
|
||||||
tag=enums.Tags.PROTECTION_STORAGE_MASK
|
tag=enums.Tags.PROTECTION_STORAGE_MASK
|
||||||
|
@ -682,13 +682,13 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"The storage protection masks must be a list of "
|
"The protection storage masks must be a list of "
|
||||||
"integers."
|
"integers."
|
||||||
)
|
)
|
||||||
self._storage_protection_masks = storage_protection_masks
|
self._protection_storage_masks = protection_storage_masks
|
||||||
else:
|
else:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"The storage protection masks must be a list of integers."
|
"The protection storage masks must be a list of integers."
|
||||||
)
|
)
|
||||||
|
|
||||||
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
|
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
|
||||||
|
@ -863,21 +863,21 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
)
|
)
|
||||||
self._defaults_information = defaults_information
|
self._defaults_information = defaults_information
|
||||||
|
|
||||||
storage_protection_masks = []
|
protection_storage_masks = []
|
||||||
while(self.is_tag_next(
|
while(self.is_tag_next(
|
||||||
enums.Tags.PROTECTION_STORAGE_MASK,
|
enums.Tags.PROTECTION_STORAGE_MASK,
|
||||||
local_buffer
|
local_buffer
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
storage_protection_mask = primitives.Integer(
|
protection_storage_mask = primitives.Integer(
|
||||||
tag=enums.Tags.PROTECTION_STORAGE_MASK
|
tag=enums.Tags.PROTECTION_STORAGE_MASK
|
||||||
)
|
)
|
||||||
storage_protection_mask.read(
|
protection_storage_mask.read(
|
||||||
local_buffer,
|
local_buffer,
|
||||||
kmip_version=kmip_version
|
kmip_version=kmip_version
|
||||||
)
|
)
|
||||||
storage_protection_masks.append(storage_protection_mask)
|
protection_storage_masks.append(protection_storage_mask)
|
||||||
self._storage_protection_masks = storage_protection_masks
|
self._protection_storage_masks = protection_storage_masks
|
||||||
|
|
||||||
self.is_oversized(local_buffer)
|
self.is_oversized(local_buffer)
|
||||||
|
|
||||||
|
@ -976,9 +976,9 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
local_buffer,
|
local_buffer,
|
||||||
kmip_version=kmip_version
|
kmip_version=kmip_version
|
||||||
)
|
)
|
||||||
if self._storage_protection_masks:
|
if self._protection_storage_masks:
|
||||||
for storage_protection_mask in self._storage_protection_masks:
|
for protection_storage_mask in self._protection_storage_masks:
|
||||||
storage_protection_mask.write(
|
protection_storage_mask.write(
|
||||||
local_buffer,
|
local_buffer,
|
||||||
kmip_version=kmip_version
|
kmip_version=kmip_version
|
||||||
)
|
)
|
||||||
|
@ -1050,10 +1050,10 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
repr(self._defaults_information)
|
repr(self._defaults_information)
|
||||||
) if self._defaults_information else None
|
) if self._defaults_information else None
|
||||||
)
|
)
|
||||||
spm = "storage_protection_masks={}".format(
|
spm = "protection_storage_masks={}".format(
|
||||||
"[{}]".format(
|
"[{}]".format(
|
||||||
", ".join([str(x) for x in self.storage_protection_masks])
|
", ".join([str(x) for x in self.protection_storage_masks])
|
||||||
) if self._storage_protection_masks else None
|
) if self._protection_storage_masks else None
|
||||||
)
|
)
|
||||||
|
|
||||||
v = ", ".join(
|
v = ", ".join(
|
||||||
|
@ -1122,10 +1122,10 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
str(self.defaults_information)
|
str(self.defaults_information)
|
||||||
) if self._defaults_information else None
|
) if self._defaults_information else None
|
||||||
)
|
)
|
||||||
spm = '"storage_protection_masks": {}'.format(
|
spm = '"protection_storage_masks": {}'.format(
|
||||||
"[{}]".format(
|
"[{}]".format(
|
||||||
", ".join([str(x) for x in self.storage_protection_masks])
|
", ".join([str(x) for x in self.protection_storage_masks])
|
||||||
) if self._storage_protection_masks else None
|
) if self._protection_storage_masks else None
|
||||||
)
|
)
|
||||||
|
|
||||||
v = ", ".join(
|
v = ", ".join(
|
||||||
|
@ -1163,8 +1163,8 @@ class QueryResponsePayload(primitives.Struct):
|
||||||
return False
|
return False
|
||||||
elif self.defaults_information != other.defaults_information:
|
elif self.defaults_information != other.defaults_information:
|
||||||
return False
|
return False
|
||||||
elif self.storage_protection_masks != \
|
elif self.protection_storage_masks != \
|
||||||
other.storage_protection_masks:
|
other.protection_storage_masks:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -970,7 +970,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
# Cryptographic Algorithm - AES
|
# Cryptographic Algorithm - AES
|
||||||
# Cryptographic Length - 128
|
# Cryptographic Length - 128
|
||||||
# Cryptographic Usage Mask - Encrypt | Decrypt
|
# Cryptographic Usage Mask - Encrypt | Decrypt
|
||||||
# Storage Status Mask - Software | Hardware
|
# Protection Storage Mask - Software | Hardware
|
||||||
self.full_encoding_kmip_2_0 = utils.BytearrayStream(
|
self.full_encoding_kmip_2_0 = utils.BytearrayStream(
|
||||||
b'\x42\x00\x7C\x01\x00\x00\x06\x10'
|
b'\x42\x00\x7C\x01\x00\x00\x06\x10'
|
||||||
b'\x42\x00\x5C\x05\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00'
|
b'\x42\x00\x5C\x05\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00'
|
||||||
|
@ -1625,45 +1625,45 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
*args
|
*args
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_invalid_storage_protection_masks(self):
|
def test_invalid_protection_storage_masks(self):
|
||||||
"""
|
"""
|
||||||
Test that a TypeError is raised when an invalid value is used to set
|
Test that a TypeError is raised when an invalid value is used to set
|
||||||
the storage protection masks of a Query response payload.
|
the protection storage masks of a Query response payload.
|
||||||
"""
|
"""
|
||||||
kwargs = {"storage_protection_masks": "invalid"}
|
kwargs = {"protection_storage_masks": "invalid"}
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
TypeError,
|
TypeError,
|
||||||
"The storage protection masks must be a list of integers.",
|
"The protection storage masks must be a list of integers.",
|
||||||
payloads.QueryResponsePayload,
|
payloads.QueryResponsePayload,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
kwargs = {"storage_protection_masks": ["invalid"]}
|
kwargs = {"protection_storage_masks": ["invalid"]}
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
TypeError,
|
TypeError,
|
||||||
"The storage protection masks must be a list of integers.",
|
"The protection storage masks must be a list of integers.",
|
||||||
payloads.QueryResponsePayload,
|
payloads.QueryResponsePayload,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
args = (
|
args = (
|
||||||
payloads.QueryResponsePayload(),
|
payloads.QueryResponsePayload(),
|
||||||
"storage_protection_masks",
|
"protection_storage_masks",
|
||||||
"invalid"
|
"invalid"
|
||||||
)
|
)
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
TypeError,
|
TypeError,
|
||||||
"The storage protection masks must be a list of integers.",
|
"The protection storage masks must be a list of integers.",
|
||||||
setattr,
|
setattr,
|
||||||
*args
|
*args
|
||||||
)
|
)
|
||||||
args = (
|
args = (
|
||||||
payloads.QueryResponsePayload(),
|
payloads.QueryResponsePayload(),
|
||||||
"storage_protection_masks",
|
"protection_storage_masks",
|
||||||
["invalid"]
|
["invalid"]
|
||||||
)
|
)
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
TypeError,
|
TypeError,
|
||||||
"The storage protection masks must be a list of integers.",
|
"The protection storage masks must be a list of integers.",
|
||||||
setattr,
|
setattr,
|
||||||
*args
|
*args
|
||||||
)
|
)
|
||||||
|
@ -2130,7 +2130,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
self.assertIsNone(payload.capability_information)
|
self.assertIsNone(payload.capability_information)
|
||||||
self.assertIsNone(payload.client_registration_methods)
|
self.assertIsNone(payload.client_registration_methods)
|
||||||
self.assertIsNone(payload.defaults_information)
|
self.assertIsNone(payload.defaults_information)
|
||||||
self.assertIsNone(payload.storage_protection_masks)
|
self.assertIsNone(payload.protection_storage_masks)
|
||||||
|
|
||||||
payload.read(
|
payload.read(
|
||||||
self.full_encoding_kmip_2_0,
|
self.full_encoding_kmip_2_0,
|
||||||
|
@ -2319,7 +2319,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
),
|
),
|
||||||
payload.defaults_information
|
payload.defaults_information
|
||||||
)
|
)
|
||||||
self.assertEqual([3], payload.storage_protection_masks)
|
self.assertEqual([3], payload.protection_storage_masks)
|
||||||
|
|
||||||
def test_read_empty(self):
|
def test_read_empty(self):
|
||||||
"""
|
"""
|
||||||
|
@ -2826,7 +2826,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
buffer = utils.BytearrayStream()
|
buffer = utils.BytearrayStream()
|
||||||
|
@ -2998,7 +2998,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -3145,10 +3145,10 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
d = "DefaultsInformation(object_defaults=[{}])".format(r)
|
d = "DefaultsInformation(object_defaults=[{}])".format(r)
|
||||||
di = "defaults_information={}".format(d)
|
di = "defaults_information={}".format(d)
|
||||||
|
|
||||||
spm = "storage_protection_masks=[3]"
|
psm = "protection_storage_masks=[3]"
|
||||||
|
|
||||||
v = ", ".join(
|
v = ", ".join(
|
||||||
[ops, ot, vei, sei, an, ei, att, rp, pi, vi, ci, crm, di, spm]
|
[ops, ot, vei, sei, an, ei, att, rp, pi, vi, ci, crm, di, psm]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -3306,7 +3306,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -3449,10 +3449,10 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
d = "{" + '"object_defaults": [' + r + "]}"
|
d = "{" + '"object_defaults": [' + r + "]}"
|
||||||
di = '"defaults_information": {}'.format(d)
|
di = '"defaults_information": {}'.format(d)
|
||||||
|
|
||||||
spm = '"storage_protection_masks": [3]'
|
psm = '"protection_storage_masks": [3]'
|
||||||
|
|
||||||
v = ", ".join(
|
v = ", ".join(
|
||||||
[ops, ot, vei, sei, an, ei, att, rp, pi, vi, ci, crm, di, spm]
|
[ops, ot, vei, sei, an, ei, att, rp, pi, vi, ci, crm, di, psm]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual("{" + v + "}", str(payload))
|
self.assertEqual("{" + v + "}", str(payload))
|
||||||
|
@ -3614,7 +3614,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
b = payloads.QueryResponsePayload(
|
b = payloads.QueryResponsePayload(
|
||||||
operations=[
|
operations=[
|
||||||
|
@ -3762,7 +3762,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(a == b)
|
self.assertTrue(a == b)
|
||||||
|
@ -4199,14 +4199,14 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
self.assertFalse(a == b)
|
self.assertFalse(a == b)
|
||||||
self.assertFalse(b == a)
|
self.assertFalse(b == a)
|
||||||
|
|
||||||
def test_equal_on_not_equal_storage_protection_masks(self):
|
def test_equal_on_not_equal_protection_storage_masks(self):
|
||||||
"""
|
"""
|
||||||
Test that the equality operator returns False when comparing two
|
Test that the equality operator returns False when comparing two
|
||||||
QueryResponsePayload structures with different storage protection
|
QueryResponsePayload structures with different protection storage
|
||||||
masks fields.
|
masks fields.
|
||||||
"""
|
"""
|
||||||
a = payloads.QueryResponsePayload(storage_protection_masks=[3, 1])
|
a = payloads.QueryResponsePayload(protection_storage_masks=[3, 1])
|
||||||
b = payloads.QueryResponsePayload(storage_protection_masks=[1, 2])
|
b = payloads.QueryResponsePayload(protection_storage_masks=[1, 2])
|
||||||
|
|
||||||
self.assertFalse(a == b)
|
self.assertFalse(a == b)
|
||||||
self.assertFalse(b == a)
|
self.assertFalse(b == a)
|
||||||
|
@ -4379,7 +4379,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
b = payloads.QueryResponsePayload(
|
b = payloads.QueryResponsePayload(
|
||||||
operations=[
|
operations=[
|
||||||
|
@ -4527,7 +4527,7 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
storage_protection_masks=[3]
|
protection_storage_masks=[3]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertFalse(a != b)
|
self.assertFalse(a != b)
|
||||||
|
@ -4964,14 +4964,14 @@ class TestQueryResponsePayload(testtools.TestCase):
|
||||||
self.assertTrue(a != b)
|
self.assertTrue(a != b)
|
||||||
self.assertTrue(b != a)
|
self.assertTrue(b != a)
|
||||||
|
|
||||||
def test_not_equal_on_not_equal_storage_protection_masks(self):
|
def test_not_equal_on_not_equal_protection_storage_masks(self):
|
||||||
"""
|
"""
|
||||||
Test that the inequality operator returns True when comparing two
|
Test that the inequality operator returns True when comparing two
|
||||||
QueryResponsePayload structures with different storage protection
|
QueryResponsePayload structures with different protection storage
|
||||||
masks fields.
|
masks fields.
|
||||||
"""
|
"""
|
||||||
a = payloads.QueryResponsePayload(storage_protection_masks=[3, 1])
|
a = payloads.QueryResponsePayload(protection_storage_masks=[3, 1])
|
||||||
b = payloads.QueryResponsePayload(storage_protection_masks=[1, 2])
|
b = payloads.QueryResponsePayload(protection_storage_masks=[1, 2])
|
||||||
|
|
||||||
self.assertTrue(a != b)
|
self.assertTrue(a != b)
|
||||||
self.assertTrue(b != a)
|
self.assertTrue(b != a)
|
||||||
|
|
Loading…
Reference in New Issue