aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2013-04-14 16:35:21 -0700
committerKenny Root <kenny@the-b.org>2013-04-14 16:35:21 -0700
commitc6cc322ab28ba55c0253c40b0774bba5a751bc35 (patch)
tree2a3bbaa4f9887fb34e6e523c7d1966bdd61aa167 /tests
parentfc0fd37d666bb8bd1452c2263cd6fdcf652230cd (diff)
downloadconnectbot-c6cc322ab28ba55c0253c40b0774bba5a751bc35.tar.gz
connectbot-c6cc322ab28ba55c0253c40b0774bba5a751bc35.tar.bz2
connectbot-c6cc322ab28ba55c0253c40b0774bba5a751bc35.zip
Split recoverKeyPair method for testing
Diffstat (limited to 'tests')
-rw-r--r--tests/src/org/connectbot/util/PubkeyUtilsTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/src/org/connectbot/util/PubkeyUtilsTest.java b/tests/src/org/connectbot/util/PubkeyUtilsTest.java
index fb5bb13..1eb1ee6 100644
--- a/tests/src/org/connectbot/util/PubkeyUtilsTest.java
+++ b/tests/src/org/connectbot/util/PubkeyUtilsTest.java
@@ -20,6 +20,7 @@ package org.connectbot.util;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.ECPublicKey;
@@ -319,4 +320,26 @@ public class PubkeyUtilsTest extends AndroidTestCase {
assertEquals(EC_KEY_pub_x, pubKey.getW().getAffineX());
assertEquals(EC_KEY_pub_y, pubKey.getW().getAffineY());
}
+
+ private static class MyPrivateKey implements PrivateKey {
+ public String getAlgorithm() {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] getEncoded() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getFormat() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public void testRecoverPublicKey_FakeKey_Failure() throws Exception {
+ try {
+ PubkeyUtils.recoverPublicKey(null, new MyPrivateKey());
+ fail("Should not accept unknown key types");
+ } catch (NoSuchAlgorithmException expected) {
+ }
+ }
}