summaryrefslogtreecommitdiffstats
path: root/base/kra/functional
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2014-02-19 09:43:24 -0500
committerAde Lee <alee@redhat.com>2014-02-19 13:10:38 -0500
commita34d15a4000c70ed89cb44884b33d7c95499ebcc (patch)
tree352aace9ce8ad81981ae548bab5c657e967caf1a /base/kra/functional
parentfda9b5c579d62498f846ab9c313ccbe1a85b0cdb (diff)
downloadpki-a34d15a4000c70ed89cb44884b33d7c95499ebcc.tar.gz
pki-a34d15a4000c70ed89cb44884b33d7c95499ebcc.tar.xz
pki-a34d15a4000c70ed89cb44884b33d7c95499ebcc.zip
Add methods to getKeyInfo and change key status
Diffstat (limited to 'base/kra/functional')
-rw-r--r--base/kra/functional/drmtest.py26
-rw-r--r--base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java21
2 files changed, 42 insertions, 5 deletions
diff --git a/base/kra/functional/drmtest.py b/base/kra/functional/drmtest.py
index 471792113..43c297d4a 100644
--- a/base/kra/functional/drmtest.py
+++ b/base/kra/functional/drmtest.py
@@ -111,7 +111,7 @@ def main():
wrapped_session_key = crypto.asymmetric_wrap(session_key, kraclient.transport_cert)
key_data, _unwrapped_key = kraclient.retrieve_key(key_id, trans_wrapped_session_key=wrapped_session_key)
print_key_data(key_data)
- unwrapped_key = crypto.symmetric_unwrap(key_data.wrappedPrivateData, session_key, iv=key_data.nonceData)
+ unwrapped_key = crypto.symmetric_unwrap(key_data.wrappedPrivateData, session_key, nonce_iv=key_data.nonceData)
key1 = base64.encodestring(unwrapped_key)
# Test 7: Recover key without providing trans_wrapped_session_key
@@ -139,18 +139,34 @@ def main():
try:
keyrequest = kraclient.keys.get_request_info('200000034')
except pki.RequestNotFoundException as exc:
- print "RequestNotFoundRequestException thrown - Code:" + exc.code + " Message: " + exc.message
+ print "RequestNotFoundException 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.
+ # Test 12 - Test exception on retrieve_key.
print "Try to retrieve an invalid key"
try:
key_data, unwrapped_key = kraclient.retrieve_key('2000003434')
+ except pki.KeyNotFoundException as exc:
+ print "KeyNotFoundException thrown - Code:" + exc.code + " Message: " + exc.message
except pki.PKIException as exc:
+ # note: this is broken - we should be sending KeyNotFoundException here before the recovery
+ # request is created - to be fixed in next patch
print "PKIException thrown - Code:" + exc.code + " Message: " + exc.message
+ #Test 13 = getKeyInfo
+ print "Get key info for existing key"
+ key_info = kraclient.keys.get_key_info(key_id)
+ print_key_info(key_info)
+ #Test 14: 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))
+
+ 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
if __name__ == "__main__":
main()
diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
index 5b2d39af3..52190091e 100644
--- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
+++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java
@@ -39,6 +39,7 @@ import org.mozilla.jss.crypto.KeyGenerator;
import org.mozilla.jss.crypto.SymmetricKey;
import org.mozilla.jss.util.Password;
+import com.netscape.certsrv.base.ResourceNotFoundException;
import com.netscape.certsrv.client.ClientConfig;
import com.netscape.certsrv.client.PKIClient;
import com.netscape.certsrv.dbs.keydb.KeyId;
@@ -724,6 +725,25 @@ public class DRMTest {
log("Success: recoverd and archived keys match!");
}
+ // Test 41: Get key info
+ log("getting key info for existing key");
+ printKeyInfo(keyClient.getKeyInfo(keyId));
+
+ //Test 42: Modify status
+ log("modify the key status");
+ keyClient.modifyKeyStatus(keyId, "inactive");
+ keyInfo = keyClient.getKeyInfo(keyId);
+ printKeyInfo(keyInfo);
+
+ //Test 43: Confirm no more active keys with this ID
+ log("look for active keys with this id");
+ clientId = keyInfo.getClientID();
+ try {
+ keyInfo = keyClient.getActiveKeyInfo(clientId);
+ printKeyInfo(keyInfo);
+ } catch (ResourceNotFoundException e) {
+ log("Success: ResourceNotFound exception thrown: " + e);
+ }
}
private static void printKeyInfo(KeyInfo keyInfo) {
@@ -732,6 +752,7 @@ public class DRMTest {
log("Key URL: " + keyInfo.getKeyURL());
log("Algorithm: " + keyInfo.getAlgorithm());
log("Strength: " + keyInfo.getSize());
+ log("Status: " + keyInfo.getStatus());
}
private static void log(String string) {