mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Merge pull request #606 from guusdk/sint_ox-cleanup
[sinttest] XEP-0373 Integration Tests should clean-up
This commit is contained in:
commit
b3ef3c3477
2 changed files with 48 additions and 34 deletions
|
@ -38,6 +38,7 @@ import org.jivesoftware.smackx.ox.exception.MissingUserIdOnKeyException;
|
||||||
import org.jivesoftware.smackx.ox.exception.NoBackupFoundException;
|
import org.jivesoftware.smackx.ox.exception.NoBackupFoundException;
|
||||||
import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
|
import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
|
||||||
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
|
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
|
||||||
|
import org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil;
|
||||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
|
@ -122,38 +123,43 @@ public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegration
|
||||||
assertNull(self.getSigningKeyFingerprint());
|
assertNull(self.getSigningKeyFingerprint());
|
||||||
|
|
||||||
OpenPgpV4Fingerprint keyFingerprint = openPgpManager.generateAndImportKeyPair(alice);
|
OpenPgpV4Fingerprint keyFingerprint = openPgpManager.generateAndImportKeyPair(alice);
|
||||||
assertEquals(keyFingerprint, self.getSigningKeyFingerprint());
|
|
||||||
|
|
||||||
assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId()));
|
try {
|
||||||
|
assertEquals(keyFingerprint, self.getSigningKeyFingerprint());
|
||||||
|
assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId()));
|
||||||
|
|
||||||
PGPSecretKeyRing beforeSec = beforeStore.getSecretKeyRing(alice, keyFingerprint);
|
PGPSecretKeyRing beforeSec = beforeStore.getSecretKeyRing(alice, keyFingerprint);
|
||||||
assertNotNull(beforeSec);
|
assertNotNull(beforeSec);
|
||||||
|
|
||||||
PGPPublicKeyRing beforePub = beforeStore.getPublicKeyRing(alice, keyFingerprint);
|
PGPPublicKeyRing beforePub = beforeStore.getPublicKeyRing(alice, keyFingerprint);
|
||||||
assertNotNull(beforePub);
|
assertNotNull(beforePub);
|
||||||
|
|
||||||
OpenPgpSecretKeyBackupPassphrase backupPassphrase =
|
OpenPgpSecretKeyBackupPassphrase backupPassphrase =
|
||||||
openPgpManager.backupSecretKeyToServer(availableSecretKeys -> availableSecretKeys);
|
openPgpManager.backupSecretKeyToServer(availableSecretKeys -> availableSecretKeys);
|
||||||
|
|
||||||
FileBasedOpenPgpStore afterStore = new FileBasedOpenPgpStore(afterPath);
|
FileBasedOpenPgpStore afterStore = new FileBasedOpenPgpStore(afterPath);
|
||||||
afterStore.setKeyRingProtector(new UnprotectedKeysProtector());
|
afterStore.setKeyRingProtector(new UnprotectedKeysProtector());
|
||||||
PainlessOpenPgpProvider afterProvider = new PainlessOpenPgpProvider(afterStore);
|
PainlessOpenPgpProvider afterProvider = new PainlessOpenPgpProvider(afterStore);
|
||||||
openPgpManager.setOpenPgpProvider(afterProvider);
|
openPgpManager.setOpenPgpProvider(afterProvider);
|
||||||
|
|
||||||
OpenPgpV4Fingerprint fingerprint = openPgpManager.restoreSecretKeyServerBackup(() -> backupPassphrase);
|
OpenPgpV4Fingerprint fingerprint = openPgpManager.restoreSecretKeyServerBackup(() -> backupPassphrase);
|
||||||
|
|
||||||
assertEquals(keyFingerprint, fingerprint);
|
assertEquals(keyFingerprint, fingerprint);
|
||||||
|
|
||||||
assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId()));
|
assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId()));
|
||||||
|
|
||||||
assertEquals(keyFingerprint, self.getSigningKeyFingerprint());
|
assertEquals(keyFingerprint, self.getSigningKeyFingerprint());
|
||||||
|
|
||||||
PGPSecretKeyRing afterSec = afterStore.getSecretKeyRing(alice, keyFingerprint);
|
PGPSecretKeyRing afterSec = afterStore.getSecretKeyRing(alice, keyFingerprint);
|
||||||
assertNotNull(afterSec);
|
assertNotNull(afterSec);
|
||||||
assertArrayEquals(beforeSec.getEncoded(), afterSec.getEncoded());
|
assertArrayEquals(beforeSec.getEncoded(), afterSec.getEncoded());
|
||||||
|
|
||||||
PGPPublicKeyRing afterPub = afterStore.getPublicKeyRing(alice, keyFingerprint);
|
PGPPublicKeyRing afterPub = afterStore.getPublicKeyRing(alice, keyFingerprint);
|
||||||
assertNotNull(afterPub);
|
assertNotNull(afterPub);
|
||||||
assertArrayEquals(beforePub.getEncoded(), afterPub.getEncoded());
|
assertArrayEquals(beforePub.getEncoded(), afterPub.getEncoded());
|
||||||
|
} finally {
|
||||||
|
OpenPgpPubSubUtil.deletePublicKeyNode(alicePepManager, keyFingerprint);
|
||||||
|
OpenPgpPubSubUtil.deletePubkeysListNode(alicePepManager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jivesoftware.smackx.ox.OpenPgpManager;
|
||||||
import org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider;
|
import org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider;
|
||||||
import org.jivesoftware.smackx.ox.element.SigncryptElement;
|
import org.jivesoftware.smackx.ox.element.SigncryptElement;
|
||||||
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
|
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
|
||||||
|
import org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil;
|
||||||
|
|
||||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||||
|
@ -139,26 +140,33 @@ public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegratio
|
||||||
aliceFingerprint = aliceOpenPgp.generateAndImportKeyPair(alice);
|
aliceFingerprint = aliceOpenPgp.generateAndImportKeyPair(alice);
|
||||||
bobFingerprint = bobOpenPgp.generateAndImportKeyPair(bob);
|
bobFingerprint = bobOpenPgp.generateAndImportKeyPair(bob);
|
||||||
|
|
||||||
aliceOpenPgp.announceSupportAndPublish();
|
try {
|
||||||
bobOpenPgp.announceSupportAndPublish();
|
aliceOpenPgp.announceSupportAndPublish();
|
||||||
|
bobOpenPgp.announceSupportAndPublish();
|
||||||
|
|
||||||
OpenPgpContact bobForAlice = aliceOpenPgp.getOpenPgpContact(bob.asEntityBareJidIfPossible());
|
OpenPgpContact bobForAlice = aliceOpenPgp.getOpenPgpContact(bob.asEntityBareJidIfPossible());
|
||||||
OpenPgpContact aliceForBob = bobOpenPgp.getOpenPgpContact(alice.asEntityBareJidIfPossible());
|
OpenPgpContact aliceForBob = bobOpenPgp.getOpenPgpContact(alice.asEntityBareJidIfPossible());
|
||||||
|
|
||||||
bobForAlice.updateKeys(aliceConnection);
|
bobForAlice.updateKeys(aliceConnection);
|
||||||
|
|
||||||
assertFalse(bobForAlice.isTrusted(bobFingerprint));
|
assertFalse(bobForAlice.isTrusted(bobFingerprint));
|
||||||
assertFalse(aliceForBob.isTrusted(aliceFingerprint));
|
assertFalse(aliceForBob.isTrusted(aliceFingerprint));
|
||||||
|
|
||||||
bobForAlice.trust(bobFingerprint);
|
bobForAlice.trust(bobFingerprint);
|
||||||
aliceForBob.trust(aliceFingerprint);
|
aliceForBob.trust(aliceFingerprint);
|
||||||
|
|
||||||
assertTrue(bobForAlice.isTrusted(bobFingerprint));
|
assertTrue(bobForAlice.isTrusted(bobFingerprint));
|
||||||
assertTrue(aliceForBob.isTrusted(aliceFingerprint));
|
assertTrue(aliceForBob.isTrusted(aliceFingerprint));
|
||||||
|
|
||||||
aliceInstantMessaging.sendOxMessage(bobForAlice, body);
|
aliceInstantMessaging.sendOxMessage(bobForAlice, body);
|
||||||
|
|
||||||
bobReceivedMessage.waitForResult(timeout);
|
bobReceivedMessage.waitForResult(timeout);
|
||||||
|
} finally {
|
||||||
|
OpenPgpPubSubUtil.deletePublicKeyNode(alicePepManager, aliceFingerprint);
|
||||||
|
OpenPgpPubSubUtil.deletePubkeysListNode(alicePepManager);
|
||||||
|
OpenPgpPubSubUtil.deletePublicKeyNode(bobPepManager, bobFingerprint);
|
||||||
|
OpenPgpPubSubUtil.deletePubkeysListNode(bobPepManager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue