Commit 037234bf authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] use IEnpointApi.label() instead of EnpointApi.name()

parent 125a38bb
Pipeline #9543 passed with stage
in 16 seconds
......@@ -76,6 +76,6 @@ public enum EndpointApi implements IEndpointApi {
}
public static boolean useWebSocketProtocol(String api) {
return WS2P.name().equals(api);
return WS2P.label().equals(api);
}
}
......@@ -73,7 +73,7 @@ public class Endpoints {
// BMAS API
mather = bmasPattern.matcher(raw);
if (mather.matches()) {
endpoint.api = EndpointApi.BMAS.name();
endpoint.api = EndpointApi.BMAS.label();
parseDefaultFormatEndPoint(mather, endpoint, 1);
return Optional.of(endpoint);
}
......@@ -83,7 +83,7 @@ public class Endpoints {
if (mather.matches()) {
String api = mather.group(1);
try {
endpoint.api = EndpointApi.valueOf(api).name();
endpoint.api = EndpointApi.valueOf(api).label();
endpoint.id = mather.group(2);
parseDefaultFormatEndPoint(mather, endpoint, 3);
return Optional.of(endpoint);
......
......@@ -215,7 +215,7 @@ public class Peer implements LocalEntity<String>, Serializable {
int port = this.port != null ? this.port : 80;
String api = this.api != null ? this.api : EndpointApi.BASIC_MERKLED_API.label();
boolean useSsl = this.useSsl != null ? this.useSsl :
(port == 443 || EndpointApi.BMAS.name().equals(this.api));
(port == 443 || EndpointApi.BMAS.label().equals(this.api));
Peer ep = new Peer(api, dns, ipv4, ipv6, port, useSsl);
if (StringUtils.isNotBlank(this.epId)) {
ep.setEpId(this.epId);
......@@ -300,7 +300,7 @@ public class Peer implements LocalEntity<String>, Serializable {
this.dns = host;
}
this.port = port != null ? port : 80;
this.useSsl = (port == 443 || this.api == EndpointApi.BMAS.name());
this.useSsl = (port == 443 || EndpointApi.BMAS.label().equals(this.api));
init();
}
......
......@@ -396,7 +396,7 @@ public class NetworkServiceImpl extends BaseRemoteServiceImpl implements Network
Filter filterDef = new Filter();
filterDef.filterType = null;
filterDef.filterStatus = Peer.PeerStatus.UP;
filterDef.filterEndpoints = ImmutableList.of(EndpointApi.BASIC_MERKLED_API.name(), EndpointApi.BMAS.name(), EndpointApi.WS2P.name());
filterDef.filterEndpoints = ImmutableList.of(EndpointApi.BASIC_MERKLED_API.label(), EndpointApi.BMAS.label(), EndpointApi.WS2P.label());
filterDef.currency = parameters.getCurrency();
// Skip node on an old fork
......
......@@ -21,7 +21,7 @@ public class EndpointsTest {
ep = Endpoints.parse("BMAS g1.duniter.org 443").orElse(null);
Assert.assertNotNull(ep);
Assert.assertEquals(EndpointApi.BMAS.name(), ep.api);
Assert.assertEquals(EndpointApi.BMAS.label(), ep.api);
Assert.assertEquals("g1.duniter.org", ep.dns);
Assert.assertNotNull(ep.port);
Assert.assertEquals(443, ep.port.intValue());
......@@ -32,7 +32,7 @@ public class EndpointsTest {
Assert.assertNotNull(ep);
Assert.assertNotNull("fb17fcd4", ep.id);
Assert.assertEquals("g1.duniter.org", ep.dns);
Assert.assertEquals(EndpointApi.WS2P.name(), ep.api);
Assert.assertEquals(EndpointApi.WS2P.label(), ep.api);
Assert.assertNotNull(ep.port);
Assert.assertEquals(443, ep.port.intValue());
Assert.assertEquals("/ws2p", ep.path);
......@@ -40,7 +40,7 @@ public class EndpointsTest {
ep = Endpoints.parse("WS2P fb17fcd4 g1.duniter.org 443 ws2p").orElse(null);
Assert.assertNotNull(ep);
Assert.assertNotNull(ep.id);
Assert.assertEquals(EndpointApi.WS2P.name(), ep.api);
Assert.assertEquals(EndpointApi.WS2P.label(), ep.api);
Assert.assertEquals("g1.duniter.org", ep.dns);
Assert.assertNotNull(ep.port);
Assert.assertEquals(443, ep.port.intValue());
......@@ -49,7 +49,7 @@ public class EndpointsTest {
// ws2pId on 7 characters
ep = Endpoints.parse("WS2P 90e9b12 duniter.g1.1000i100.fr 443 /ws2p").orElse(null);
Assert.assertNotNull(ep);
Assert.assertEquals(ep.api, EndpointApi.WS2P.name());
Assert.assertEquals(ep.api, EndpointApi.WS2P.label());
Assert.assertNotNull(ep.id);
Assert.assertNotNull(ep.path);
......@@ -57,14 +57,14 @@ public class EndpointsTest {
Assert.assertNotNull(ep);
Assert.assertNotNull(ep.id);
Assert.assertNull(ep.path);
Assert.assertEquals(EndpointApi.WS2PTOR.name(), ep.api);
Assert.assertEquals(EndpointApi.WS2PTOR.label(), ep.api);
Assert.assertEquals("3k2zovlpihbt3j3g.onion", ep.dns);
Assert.assertNotNull(ep.port);
Assert.assertEquals(20901, ep.port.intValue());
ep = Endpoints.parse("GCHANGE_API data.gchange.fr 443").orElse(null);
Assert.assertNotNull(ep);
Assert.assertEquals(ep.api, EndpointApi.GCHANGE_API.name());
Assert.assertEquals(ep.api, EndpointApi.GCHANGE_API.label());
Assert.assertNull(ep.id);
Assert.assertNull(ep.path);
......
......@@ -26,7 +26,7 @@ public class NetworkPeeringTest {
epBma.setPort(80);
NetworkPeering.Endpoint epWs2p = new NetworkPeering.Endpoint();
epWs2p.setApi(EndpointApi.WS2P.name());
epWs2p.setApi(EndpointApi.WS2P.label());
epWs2p.setDns("g1.duniter.fr");
epWs2p.setPath("/ws2p");
epWs2p.setId("fb17fcd4");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment