actually canonicalize

This commit is contained in:
Art O Cathain 2014-07-06 15:05:20 +01:00
parent cb64f8865c
commit 5479eafd4b
2 changed files with 11 additions and 5 deletions

View File

@ -14,10 +14,12 @@ import org.spongycastle.openpgp.PGPUserAttributeSubpacketVector;
import org.spongycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; import org.spongycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.UncachedPublicKey; import org.sufficientlysecure.keychain.pgp.UncachedPublicKey;
import org.sufficientlysecure.keychain.service.OperationResultParcel;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Objects;
/** /**
* Created by art on 28/06/14. * Created by art on 28/06/14.
@ -25,7 +27,14 @@ import java.util.Date;
public class UncachedKeyringTestingHelper { public class UncachedKeyringTestingHelper {
public static boolean compareRing(UncachedKeyRing keyRing1, UncachedKeyRing keyRing2) { public static boolean compareRing(UncachedKeyRing keyRing1, UncachedKeyRing keyRing2) {
return TestDataUtil.iterEquals(keyRing1.getPublicKeys(), keyRing2.getPublicKeys(), new OperationResultParcel.OperationLog operationLog = new OperationResultParcel.OperationLog();
UncachedKeyRing canonicalized = keyRing1.canonicalize(operationLog, 0);
if (canonicalized == null) {
throw new AssertionError("Canonicalization failed; messages: [" + operationLog.toString() + "]");
}
return TestDataUtil.iterEquals(canonicalized.getPublicKeys(), keyRing2.getPublicKeys(), new
TestDataUtil.EqualityChecker<UncachedPublicKey>() { TestDataUtil.EqualityChecker<UncachedPublicKey>() {
@Override @Override
public boolean areEquals(UncachedPublicKey lhs, UncachedPublicKey rhs) { public boolean areEquals(UncachedPublicKey lhs, UncachedPublicKey rhs) {

View File

@ -16,11 +16,8 @@ public class UncachedKeyringTest {
@Test @Test
public void testVerifySuccess() throws Exception { public void testVerifySuccess() throws Exception {
UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2(); UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2();
// Uncomment to prove it's working - the createdDate will then be different
// Thread.sleep(1500);
UncachedKeyRing inputKeyRing = KeyringBuilder.ring1(); UncachedKeyRing inputKeyRing = KeyringBuilder.ring1();
new UncachedKeyringTestingHelper().doTestCanonicalize( new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing);
inputKeyRing, expectedKeyRing);
} }
/** /**