diff options
author | Ade Lee <alee@redhat.com> | 2014-02-17 11:28:53 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2014-02-19 10:49:31 -0500 |
commit | 86dfed578c3230064f2c93156b38309070a478f8 (patch) | |
tree | 708720f576142c32f233c99b62391b417026c3f1 /base/kra/functional/drmtest.py | |
parent | f4aafb999efc1367c005c9683ae9d935720d2482 (diff) | |
download | pki-86dfed578c3230064f2c93156b38309070a478f8.tar.gz pki-86dfed578c3230064f2c93156b38309070a478f8.tar.xz pki-86dfed578c3230064f2c93156b38309070a478f8.zip |
Added decorator to handle exceptions
Decorator catches HttpErrorExceptions from Requests
and extracts the relevant PKIException object, and rethrows
it.
Diffstat (limited to 'base/kra/functional/drmtest.py')
-rw-r--r-- | base/kra/functional/drmtest.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/base/kra/functional/drmtest.py b/base/kra/functional/drmtest.py index 5c7e41244..471792113 100644 --- a/base/kra/functional/drmtest.py +++ b/base/kra/functional/drmtest.py @@ -30,6 +30,7 @@ See drmtest.readme.txt. ''' import base64 +import pki import pki.cryptoutil as cryptoutil import pki.key as key import time @@ -126,5 +127,30 @@ def main(): print "key1: " + key1 print "key2: " + key2 + # Test 10 = test BadRequestException on create() + print "Trying to generate a new symkey with the same client ID" + try: + response = kraclient.generate_sym_key(client_id, algorithm, key_size, usages) + except pki.BadRequestException as exc: + print "BadRequestException thrown - Code:" + exc.code + " Message: " + exc.message + + # Test 11 - Test RequestNotFoundException on get_request_info + print "Try to list a nonexistent request" + try: + keyrequest = kraclient.keys.get_request_info('200000034') + except pki.RequestNotFoundException as exc: + print "RequestNotFoundRequestException thrown - Code:" + exc.code + " Message: " + exc.message + + # Test 12 - Test exception on retrieve_key + # Note - this currently throws PKIException when it should probably throw a ResourceNotFound exception + # Fix in next patch. + print "Try to retrieve an invalid key" + try: + key_data, unwrapped_key = kraclient.retrieve_key('2000003434') + except pki.PKIException as exc: + print "PKIException thrown - Code:" + exc.code + " Message: " + exc.message + + + if __name__ == "__main__": main() |