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

[fix] Endpoint: allow '/' as path

parent f8990d79
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ public class Endpoints { ...@@ -41,7 +41,7 @@ public class Endpoints {
private static final Logger log = LoggerFactory.getLogger(Endpoints.class); private static final Logger log = LoggerFactory.getLogger(Endpoints.class);
// Path regexp (can have no starting slash - see issue https://git.duniter.org/clients/cesium-grp/cesium-plus-pod/-/issues/41) // Path regexp (can have no starting slash - see issue https://git.duniter.org/clients/cesium-grp/cesium-plus-pod/-/issues/41)
public static final String PATH_REGEXP = "\\/?[^\\/\\s]+(?:\\/[^\\/\\s]+)*"; public static final String PATH_REGEXP = "(?:\\/|\\/?[^\\/\\s]+(?:\\/[^\\/\\s]+)*)";
public static final String EP_END_REGEXP = "(?: ([a-z0-9_ğĞ][a-z0-9-_.ğĞ]*))?(?: ([0-9.]+))?(?: ([0-9a-f:]+)(?:%[a-z0-9]+)?)?(?: ([0-9]+))(?: ("+PATH_REGEXP + "))?$"; public static final String EP_END_REGEXP = "(?: ([a-z0-9_ğĞ][a-z0-9-_.ğĞ]*))?(?: ([0-9.]+))?(?: ([0-9a-f:]+)(?:%[a-z0-9]+)?)?(?: ([0-9]+))(?: ("+PATH_REGEXP + "))?$";
public static final String BMA_API_REGEXP = "^BASIC_MERKLED_API" + EP_END_REGEXP; public static final String BMA_API_REGEXP = "^BASIC_MERKLED_API" + EP_END_REGEXP;
public static final String BMAS_API_REGEXP = "^BMAS" + EP_END_REGEXP; public static final String BMAS_API_REGEXP = "^BMAS" + EP_END_REGEXP;
......
...@@ -114,6 +114,13 @@ public class EndpointsTest { ...@@ -114,6 +114,13 @@ public class EndpointsTest {
Assert.assertNull(ep.id); Assert.assertNull(ep.id);
Assert.assertNull(ep.path); Assert.assertNull(ep.path);
ep = Endpoints.parse("WS2P bb5e697f node.g1cotis.fr 20901 /").orElse(null);
Assert.assertNotNull(ep);
Assert.assertEquals(ep.api, "WS2P");
Assert.assertEquals("bb5e697f", ep.id);
Assert.assertEquals("/", ep.path);
Assert.assertEquals(new Integer(20901), ep.port);
// Parse Invalid endpoints // Parse Invalid endpoints
// This must failed (missing port) // This must failed (missing port)
...@@ -124,6 +131,22 @@ public class EndpointsTest { ...@@ -124,6 +131,22 @@ public class EndpointsTest {
ep = Endpoints.parse("WS2P R8t2sg7w g1.ambau.ovh 443").orElse(null); ep = Endpoints.parse("WS2P R8t2sg7w g1.ambau.ovh 443").orElse(null);
Assert.assertNull(ep); Assert.assertNull(ep);
// Parse invalid
String[] errorEndpoints = new String[]{
"WS2P 93.8.54.71 20910", // no id
"GVA 77.131.240.28 [2a02:8428:471:6701:cc3e:ef7a:ef19:81f] 30901 gva", // Bad ipV6 (character '[' not need)
"BMAS duniter.adn.life/bma/ 443", // Bad path position
"BMAS duniter.adn.life/bma 443",
"WS2P duniter.vincentux.fr 443 /ws2p",
"WS2P 93.8.54.71 20910",
"BMAS cloudanua.ddns.net/bma 192.168.0.46 443",
"WS2P 9938ae63 cloudanua.ddns.net/bma 443 /ws2p"
};
for (String epStr: errorEndpoints) {
ep = Endpoints.parse(epStr).orElse(null);
Assert.assertNull(ep);
}
} }
} }
...@@ -374,12 +374,6 @@ ...@@ -374,12 +374,6 @@
<groupId>org.glassfish.tyrus</groupId> <groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-client</artifactId> <artifactId>tyrus-container-grizzly-client</artifactId>
<version>${tyrus.version}</version> <version>${tyrus.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-server</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish.tyrus</groupId> <groupId>org.glassfish.tyrus</groupId>
......
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