2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-26 21:23:44 +00:00

Add ModifyAttribute support to the client

This change adds ModifyAttribute support to the ProxyKmipClient,
leveraging the new generic request capability in the underlying
KMIPProxy client. New unit tests have been added to cover the new
client additions.

Partially implements #547
This commit is contained in:
Peter Hamilton
2019-11-27 14:16:12 -05:00
committed by Peter Hamilton
parent 2d283e128c
commit 53308c346b
4 changed files with 137 additions and 2 deletions

View File

@@ -832,6 +832,48 @@ class TestProxyKmipClient(testtools.TestCase):
client.proxy.send_request_payload.assert_called_with(*args)
self.assertEqual("1", unique_identifier)
@mock.patch(
"kmip.pie.client.KMIPProxy",
mock.MagicMock(spec_set=KMIPProxy)
)
def test_modify_attribute(self):
"""
Test that the client can modify an attribute.
"""
request_payload = payloads.ModifyAttributeRequestPayload(
unique_identifier="1",
new_attribute=obj.NewAttribute(
attribute=primitives.Boolean(
value=True,
tag=enums.Tags.SENSITIVE
)
)
)
response_payload = payloads.ModifyAttributeResponsePayload(
unique_identifier="1"
)
with ProxyKmipClient() as client:
client.proxy.send_request_payload.return_value = response_payload
unique_identifier, attribute = client.modify_attribute(
unique_identifier="1",
new_attribute=obj.NewAttribute(
attribute=primitives.Boolean(
value=True,
tag=enums.Tags.SENSITIVE
)
)
)
args = (
enums.Operation.MODIFY_ATTRIBUTE,
request_payload
)
client.proxy.send_request_payload.assert_called_with(*args)
self.assertEqual("1", unique_identifier)
self.assertIsNone(attribute)
@mock.patch(
'kmip.pie.client.KMIPProxy', mock.MagicMock(spec_set=KMIPProxy)
)