Merge pull request #280 from vbnmmnbv/api_activate_locate_mac

Add the missing locate/activate KmipClient abstractmethod definition
This commit is contained in:
Peter Hamilton 2017-04-19 18:07:56 -04:00 committed by GitHub
commit e26e0748af
2 changed files with 57 additions and 4 deletions

View File

@ -60,6 +60,25 @@ class KmipClient:
"""
pass
@abc.abstractmethod
def locate(self, maximum_items, storage_status_mask, object_group_member,
attributes):
"""
Search for managed objects with a KMIP appliance.
Args:
maximum_items (integer): Maximum number of object identifiers the
server MAY return.
storage_status_mask (integer): A bit mask that indicates whether
on-line or archived objects are to be searched.
object_group_member (ObjectGroupMember): An enumeration that
indicates the object group member type.
attributes (list): Attributes the are REQUIRED to match those in a
candidate object.
"""
pass
@abc.abstractmethod
def get(self, uid):
"""
@ -81,6 +100,16 @@ class KmipClient:
"""
pass
@abc.abstractmethod
def activate(self, uid):
"""
Activate a managed object stored by a KMIP appliance.
Args:
uid (string): The unique ID of the managed object to activate.
"""
pass
@abc.abstractmethod
def destroy(self, uid):
"""
@ -92,15 +121,15 @@ class KmipClient:
pass
@abc.abstractmethod
def mac(self, uid, algorithm, data):
def mac(self, data, uid, algorithm):
"""
Get the message authentication code for data.
Args:
data (string): The data to be MACed.
uid (string): The unique ID of the managed object that is the key
to use for the MAC operation.
algorithm (CryptographicAlgorithm): An enumeration defining the
algorithm to use to generate the MAC.
data (string): The data to be MACed.
"""
pass

View File

@ -35,17 +35,26 @@ class DummyKmipClient(api.KmipClient):
def register(self, managed_object, *args, **kwargs):
super(DummyKmipClient, self).register(managed_object)
def locate(self, maximum_items, storage_status_mask, object_group_member,
attributes):
super(DummyKmipClient, self).locate(
maximum_items, storage_status_mask, object_group_member,
attributes)
def get(self, uid, *args, **kwargs):
super(DummyKmipClient, self).get(uid)
def get_attribute_list(self, uid, *args, **kwargs):
super(DummyKmipClient, self).get_attribute_list(uid)
def activate(self, uid):
super(DummyKmipClient, self).activate(uid)
def destroy(self, uid):
super(DummyKmipClient, self).destroy(uid)
def mac(self, uid, algorithm, data):
super(DummyKmipClient, self).mac(uid, algorithm, data)
def mac(self, data, uid, algorithm):
super(DummyKmipClient, self).mac(data, uid, algorithm)
class TestKmipClient(testtools.TestCase):
@ -89,6 +98,14 @@ class TestKmipClient(testtools.TestCase):
dummy = DummyKmipClient()
dummy.register('secret')
def test_locate(self):
"""
Test that the locate method can be called without error.
"""
dummy = DummyKmipClient()
dummy.locate('maximum_items', 'storage_status_mask',
'object_group_member', 'attributes')
def test_get(self):
"""
Test that the get method can be called without error.
@ -103,6 +120,13 @@ class TestKmipClient(testtools.TestCase):
dummy = DummyKmipClient()
dummy.get_attribute_list('uid')
def test_activate(self):
"""
Test that the activate method can be called without error.
"""
dummy = DummyKmipClient()
dummy.activate('uid')
def test_destroy(self):
"""
Test that the destroy method can be called without error.