1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 20:42:06 +01:00

Preserve OmemoConfiguration values

This commit is contained in:
Paul Schaub 2018-01-23 16:30:08 +01:00
parent 411104e7bc
commit 2d79cc981f

View file

@ -34,11 +34,10 @@ public class SessionRenegotiationIntegrationTest extends AbstractTwoUsersOmemoIn
@SmackIntegrationTest @SmackIntegrationTest
public void sessionRenegotiationTest() throws Exception { public void sessionRenegotiationTest() throws Exception {
if (!OmemoConfiguration.getRepairBrokenSessionsWithPreKeyMessages()) { boolean prevRepairProperty = OmemoConfiguration.getRepairBrokenSessionsWithPreKeyMessages();
throw new TestNotPossibleException("This test requires the property " + OmemoConfiguration.setRepairBrokenSessionsWithPrekeyMessages(true);
"OmemoConfiguration.REPAIR_BROKEN_SESSIONS_WITH_PREKEY_MESSAGES " + boolean prevCompleteSessionProperty = OmemoConfiguration.getCompleteSessionWithEmptyMessage();
"set to 'true'."); OmemoConfiguration.setCompleteSessionWithEmptyMessage(false);
}
// send PreKeyMessage -> Success // send PreKeyMessage -> Success
final String body1 = "P = NP is true for all N,P from the set of complex numbers, where P is equal to 0"; final String body1 = "P = NP is true for all N,P from the set of complex numbers, where P is equal to 0";
@ -56,22 +55,25 @@ public class SessionRenegotiationIntegrationTest extends AbstractTwoUsersOmemoIn
} }
// Send normal message -> fail, bob repairs session with preKeyMessage // Send normal message -> fail, bob repairs session with preKeyMessage
final String body3 = "P = NP is also true for all N,P from the set of complex numbers, where N is equal to 1."; final String body2 = "P = NP is also true for all N,P from the set of complex numbers, where N is equal to 1.";
AbstractOmemoMessageListener.PreKeyKeyTransportListener listener3 = AbstractOmemoMessageListener.PreKeyKeyTransportListener listener2 =
new AbstractOmemoMessageListener.PreKeyKeyTransportListener(); new AbstractOmemoMessageListener.PreKeyKeyTransportListener();
OmemoMessage.Sent e3 = alice.encrypt(bob.getOwnJid(), body3); OmemoMessage.Sent e2 = alice.encrypt(bob.getOwnJid(), body2);
alice.addOmemoMessageListener(listener3); alice.addOmemoMessageListener(listener2);
alice.getConnection().sendStanza(e3.asMessage(bob.getOwnJid())); alice.getConnection().sendStanza(e2.asMessage(bob.getOwnJid()));
listener3.getSyncPoint().waitForResult(10 * 1000); listener2.getSyncPoint().waitForResult(10 * 1000);
alice.removeOmemoMessageListener(listener3); alice.removeOmemoMessageListener(listener2);
// Send normal message -> success // Send normal message -> success
final String body4 = "P = NP would be a disaster for the world of cryptography."; final String body3 = "P = NP would be a disaster for the world of cryptography.";
AbstractOmemoMessageListener.MessageListener listener4 = new AbstractOmemoMessageListener.MessageListener(body4); AbstractOmemoMessageListener.MessageListener listener3 = new AbstractOmemoMessageListener.MessageListener(body3);
OmemoMessage.Sent e4 = alice.encrypt(bob.getOwnJid(), body4); OmemoMessage.Sent e3 = alice.encrypt(bob.getOwnJid(), body3);
bob.addOmemoMessageListener(listener4); bob.addOmemoMessageListener(listener3);
alice.getConnection().sendStanza(e4.asMessage(bob.getOwnJid())); alice.getConnection().sendStanza(e3.asMessage(bob.getOwnJid()));
listener4.getSyncPoint().waitForResult(10 * 1000); listener3.getSyncPoint().waitForResult(10 * 1000);
bob.removeOmemoMessageListener(listener4); bob.removeOmemoMessageListener(listener3);
OmemoConfiguration.setRepairBrokenSessionsWithPrekeyMessages(prevRepairProperty);
OmemoConfiguration.setCompleteSessionWithEmptyMessage(prevCompleteSessionProperty);
} }
} }