diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/common/python/pki/key.py | 9 | ||||
-rw-r--r-- | base/kra/functional/drmtest.py | 15 |
2 files changed, 23 insertions, 1 deletions
diff --git a/base/common/python/pki/key.py b/base/common/python/pki/key.py index 235825746..ab6db9625 100644 --- a/base/common/python/pki/key.py +++ b/base/common/python/pki/key.py @@ -27,6 +27,7 @@ import pki.encoder as encoder import json import pki import types +import urllib class KeyId(object): ''' @@ -466,6 +467,14 @@ class KeyClient(object): return KeyInfo.from_json(response.json()) @pki.handle_exceptions() + def get_active_key_info(self, client_id): + ''' Get the info in the KeyRecord for the active secret in the DRM. ''' + url = self.keyURL + '/active/' + urllib.quote_plus(client_id) + response = self.connection.get(url, headers=self.headers) + print response + return KeyInfo.from_json(response.json()) + + @pki.handle_exceptions() def modify_key_status(self, key_id, status): ''' Modify the status of a key ''' url = self.keyURL + '/' + key_id diff --git a/base/kra/functional/drmtest.py b/base/kra/functional/drmtest.py index f3352b687..f658d06b8 100644 --- a/base/kra/functional/drmtest.py +++ b/base/kra/functional/drmtest.py @@ -167,16 +167,29 @@ def main(): key_info = kraclient.keys.get_key_info(key_id) print_key_info(key_info) - #Test 14: change the key status + # Test 14: get the active key + print "Get the active key for client id: " + client_id + key_info = kraclient.keys.get_active_key_info(client_id) + print_key_info(key_info) + + #Test 15: change the key status print "Change the key status" kraclient.keys.modify_key_status(key_id, "inactive") print_key_info(kraclient.keys.get_key_info(key_id)) + # Test 16: Get key info for non-existent key print "Get key info for non-existent key" try: key_info = kraclient.keys.get_key_info('200004556') except pki.KeyNotFoundException as exc: print "KeyNotFoundException thrown - Code:" + exc.code + " Message: " + exc.message + # Test 17: Get key info for non-existent active key + print "Get non-existent active key" + try: + key_info = kraclient.keys.get_active_key_info(client_id) + except pki.ResourceNotFoundException as exc: + print "ResourceNotFoundException thrown - Code: " + exc.code + "Message: " + exc.message + if __name__ == "__main__": main() |