Skip to content
Snippets Groups Projects
Verified Commit f0a3130b authored by akwizgran's avatar akwizgran
Browse files

Test that UnsupportedVersionException is thrown.

parent 64aa121c
No related branches found
No related tags found
1 merge request!1081Implement contact manager methods for pending contacts
Pipeline #3284 passed
package org.briarproject.bramble.contact; package org.briarproject.bramble.contact;
import org.briarproject.bramble.api.FormatException; import org.briarproject.bramble.api.FormatException;
import org.briarproject.bramble.api.UnsupportedVersionException;
import org.briarproject.bramble.api.contact.PendingContact; import org.briarproject.bramble.api.contact.PendingContact;
import org.briarproject.bramble.api.crypto.CryptoComponent; import org.briarproject.bramble.api.crypto.CryptoComponent;
import org.briarproject.bramble.api.crypto.KeyParser; import org.briarproject.bramble.api.crypto.KeyParser;
...@@ -25,6 +26,8 @@ import static org.briarproject.bramble.test.TestUtils.getRandomId; ...@@ -25,6 +26,8 @@ import static org.briarproject.bramble.test.TestUtils.getRandomId;
import static org.briarproject.bramble.util.StringUtils.getRandomString; import static org.briarproject.bramble.util.StringUtils.getRandomString;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
public class PendingContactFactoryImplTest extends BrambleMockTestCase { public class PendingContactFactoryImplTest extends BrambleMockTestCase {
...@@ -45,10 +48,15 @@ public class PendingContactFactoryImplTest extends BrambleMockTestCase { ...@@ -45,10 +48,15 @@ public class PendingContactFactoryImplTest extends BrambleMockTestCase {
pendingContactFactory.createPendingContact("briar://potato", alias); pendingContactFactory.createPendingContact("briar://potato", alias);
} }
@Test(expected = FormatException.class) @Test
public void testRejectsLinkWithUnknownFormatVersion() throws Exception { public void testRejectsLinkWithUnknownFormatVersion() throws Exception {
String link = encodeLink(FORMAT_VERSION + 1); String link = encodeLink(FORMAT_VERSION + 1);
pendingContactFactory.createPendingContact(link, alias); try {
pendingContactFactory.createPendingContact(link, alias);
fail();
} catch (UnsupportedVersionException e) {
assertFalse(e.isTooOld());
}
} }
@Test(expected = FormatException.class) @Test(expected = FormatException.class)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment