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:
committed by
Peter Hamilton
parent
77d5b32ea4
commit
b045e08ce2
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user