2
0
mirror of https://github.com/openkmip/pykmip synced 2026-01-04 17:43:51 +00:00

Add DeleteAttribute support to the client

This change adds DeleteAttribute support to the ProxyKmipClient,
leveraging the new generic request capability in the underlying
KMIPProxy client. Going forward all new attribute support will
leverage the new request capability and older supported operations
will be migrated to use it as well, with the ultimate vision
being a final merger of the two client classes into one easy to
use architecture. New unit tests have been added to cover the new
client additions.

Partially implements #547
This commit is contained in:
Peter Hamilton
2019-11-15 16:17:05 -05:00
committed by Peter Hamilton
parent 77d5b32ea4
commit b045e08ce2
5 changed files with 414 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ from kmip.core import objects as obj
from kmip.core.factories import attributes
from kmip.core.messages import contents
from kmip.core.messages import payloads
from kmip.core.primitives import DateTime
from kmip.services.kmip_client import KMIPProxy
@@ -758,6 +759,41 @@ class TestProxyKmipClient(testtools.TestCase):
KmipOperationFailure, error_msg,
client.create_key_pair, *args)
@mock.patch(
"kmip.pie.client.KMIPProxy",
mock.MagicMock(spec_set=KMIPProxy)
)
def test_delete_attribute(self):
"""
Test that the client can delete an attribute.
"""
request_payload = payloads.DeleteAttributeRequestPayload(
unique_identifier="1",
attribute_name="Object Group",
attribute_index=2
)
response_payload = payloads.DeleteAttributeResponsePayload(
unique_identifier="1",
attribute=None
)
with ProxyKmipClient() as client:
client.proxy.send_request_payload.return_value = response_payload
unique_identifier, attribute = client.delete_attribute(
"1",
attribute_name="Object Group",
attribute_index=2
)
args = (
enums.Operation.DELETE_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)
)