1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Merge pull request #606 from guusdk/sint_ox-cleanup

[sinttest] XEP-0373 Integration Tests should clean-up
This commit is contained in:
Florian Schmaus 2024-07-09 06:20:25 +00:00 committed by GitHub
commit b3ef3c3477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 34 deletions

View file

@ -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,8 +123,9 @@ 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());
try {
assertEquals(keyFingerprint, self.getSigningKeyFingerprint());
assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId())); assertTrue(self.getSecretKeys().contains(keyFingerprint.getKeyId()));
PGPSecretKeyRing beforeSec = beforeStore.getSecretKeyRing(alice, keyFingerprint); PGPSecretKeyRing beforeSec = beforeStore.getSecretKeyRing(alice, keyFingerprint);
@ -155,5 +157,9 @@ public class OXSecretKeyBackupIntegrationTest extends AbstractOpenPgpIntegration
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);
}
} }
} }

View file

@ -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,6 +140,7 @@ public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegratio
aliceFingerprint = aliceOpenPgp.generateAndImportKeyPair(alice); aliceFingerprint = aliceOpenPgp.generateAndImportKeyPair(alice);
bobFingerprint = bobOpenPgp.generateAndImportKeyPair(bob); bobFingerprint = bobOpenPgp.generateAndImportKeyPair(bob);
try {
aliceOpenPgp.announceSupportAndPublish(); aliceOpenPgp.announceSupportAndPublish();
bobOpenPgp.announceSupportAndPublish(); bobOpenPgp.announceSupportAndPublish();
@ -159,6 +161,12 @@ public class OXInstantMessagingIntegrationTest extends AbstractOpenPgpIntegratio
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);
}
} }
} }