From ea7068acdfdcbe78412a42f88a731a81753808ed Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 8 Mar 2015 03:12:26 +0100 Subject: minor changes, add convertFingerprintToKeyId method --- .../keychain/operations/CertifyOperationTest.java | 8 ++-- .../keychain/util/KeyFormattingUtilsTest.java | 44 ++++++++++++++++++++++ .../keychain/util/TestingUtils.java | 3 -- 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/KeyFormattingUtilsTest.java (limited to 'OpenKeychain-Test') diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java index 0af87ada4..07bc5508e 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/CertifyOperationTest.java @@ -163,7 +163,7 @@ public class CertifyOperationTest { CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId()); actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(), - mStaticRing2.getPublicKey().getUnorderedUserIds())); + mStaticRing2.getPublicKey().getUnorderedUserIds(), null)); CertifyResult result = op.certify(actions, null); Assert.assertTrue("certification must succeed", result.success()); @@ -213,7 +213,7 @@ public class CertifyOperationTest { CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId()); actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(), - mStaticRing2.getPublicKey().getUnorderedUserIds())); + mStaticRing2.getPublicKey().getUnorderedUserIds(), null)); CertifyResult result = op.certify(actions, null); @@ -231,7 +231,7 @@ public class CertifyOperationTest { CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId()); ArrayList uids = new ArrayList(); uids.add("nonexistent"); - actions.add(new CertifyAction(1234L, uids)); + actions.add(new CertifyAction(1234L, uids, null)); CertifyResult result = op.certify(actions, null); @@ -243,7 +243,7 @@ public class CertifyOperationTest { { CertifyActionsParcel actions = new CertifyActionsParcel(1234L); actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(), - mStaticRing2.getPublicKey().getUnorderedUserIds())); + mStaticRing2.getPublicKey().getUnorderedUserIds(), null)); CertifyResult result = op.certify(actions, null); diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/KeyFormattingUtilsTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/KeyFormattingUtilsTest.java new file mode 100644 index 000000000..6aa4e7b8e --- /dev/null +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/KeyFormattingUtilsTest.java @@ -0,0 +1,44 @@ +package org.sufficientlysecure.keychain.util; + + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; + + +@RunWith(RobolectricTestRunner.class) +@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 +public class KeyFormattingUtilsTest { + + static final byte[] fp = new byte[] { + (byte) 0xD4, (byte) 0xAB, (byte) 0x19, (byte) 0x29, (byte) 0x64, + (byte) 0xF7, (byte) 0x6A, (byte) 0x7F, (byte) 0x8F, (byte) 0x8A, + (byte) 0x9B, (byte) 0x35, (byte) 0x7B, (byte) 0xD1, (byte) 0x83, + (byte) 0x20, (byte) 0xDE, (byte) 0xAD, (byte) 0xFA, (byte) 0x11 + }; + static final long keyId = 0x7bd18320deadfa11L; + + @Test + public void testStuff() { + Assert.assertEquals(KeyFormattingUtils.convertFingerprintToKeyId(fp), keyId); + + Assert.assertEquals( + "d4ab192964f76a7f8f8a9b357bd18320deadfa11", + KeyFormattingUtils.convertFingerprintToHex(fp) + ); + + Assert.assertEquals( + "0x7bd18320deadfa11", + KeyFormattingUtils.convertKeyIdToHex(keyId) + ); + + Assert.assertEquals( + "0xdeadfa11", + KeyFormattingUtils.convertKeyIdToHexShort(keyId) + ); + + } + +} diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/TestingUtils.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/TestingUtils.java index ee0379653..1235e8cdd 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/TestingUtils.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/util/TestingUtils.java @@ -2,9 +2,6 @@ package org.sufficientlysecure.keychain.util; import java.util.Random; -/** - * Created by valodim on 9/15/14. - */ public class TestingUtils { public static String genPassphrase() { return genPassphrase(false); -- cgit v1.2.3