Skip to content
Snippets Groups Projects
Commit 74af28aa authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[enh] Add Unit test on endpoints parsing

parent b5d25dc9
No related branches found
No related tags found
No related merge requests found
Pipeline #4612 passed
......@@ -8,6 +8,7 @@ public class EndpointsTest {
@Test
public void parse() throws Exception {
// Parse valid endpoints
NetworkPeering.Endpoint ep = Endpoints.parse("BASIC_MERKLED_API g1.duniter.fr 81.81.81.81 80");
Assert.assertNotNull(ep);
Assert.assertEquals(EndpointApi.BASIC_MERKLED_API, ep.api);
......@@ -43,13 +44,6 @@ public class EndpointsTest {
Assert.assertNotNull(ep.id);
Assert.assertNotNull(ep.path);
// path without slash
ep = Endpoints.parse("WS2P 90e9b12 duniter.g1.1000i100.fr 443 ws2p");
Assert.assertNotNull(ep);
Assert.assertEquals(ep.api, EndpointApi.WS2P);
Assert.assertNotNull(ep.id);
Assert.assertNotNull(ep.path);
ep = Endpoints.parse("WS2PTOR 1be86653 3k2zovlpihbt3j3g.onion 20901");
Assert.assertNotNull(ep);
Assert.assertNotNull(ep.id);
......@@ -65,6 +59,22 @@ public class EndpointsTest {
Assert.assertNull(ep.id);
Assert.assertNull(ep.path);
// Parse Invalid endpoints
// FIXME: make sure this must failed (missing port)
ep = Endpoints.parse("BMAS g1.cgeek.fr");
Assert.assertNotNull(ep);
Assert.assertNull(ep.api);
// FIXME: make sure this must failed (because bad ID)
ep = Endpoints.parse("WS2P R8t2sg7w g1.ambau.ovh 443");
Assert.assertNotNull(ep);
Assert.assertNull(ep.api);
// FIXME: make sure this must failed (missing path first '/')
ep = Endpoints.parse("WS2P 90e9b12 duniter.g1.1000i100.fr 443 ws2p");
Assert.assertNotNull(ep);
Assert.assertNull(ep.api);
}
}
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