diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/org/connectbot/util/PubkeyUtilsTest.java | 23 |
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) { + } + } } |