@@ -72,16 +72,37 @@ public void testRequestPathWithNamedParam() throws InvocationTargetException, Il
72
72
}
73
73
74
74
@ Test
75
- public void testRequestPathMismatch () throws InvocationTargetException , IllegalAccessException {
76
- String requestPath = "_plugins/security/api/x/y" ;
77
- String handlerPath = "_plugins/security/api/z/y" ;
75
+ public void testMatchWithLeadingSlashDifference () throws InvocationTargetException , IllegalAccessException {
76
+ String requestPath = "api/v1/resource" ;
77
+ String handlerPath = "/api/v1/resource" ;
78
+ assertTrue ((Boolean ) restPathMatches .invoke (securityRestFilter , requestPath , handlerPath ));
79
+ }
80
+
81
+ @ Test
82
+ public void testMatchWithTrailingSlashDifference () throws InvocationTargetException , IllegalAccessException {
83
+ String requestPath = "/api/v1/resource/" ;
84
+ String handlerPath = "/api/v1/resource" ;
85
+ assertTrue ((Boolean ) restPathMatches .invoke (securityRestFilter , requestPath , handlerPath ));
86
+ }
87
+
88
+ @ Test
89
+ public void testPathsMatchWithMultipleNamedParameters () throws InvocationTargetException , IllegalAccessException {
90
+ String requestPath = "/api/v1/resource/123/details" ;
91
+ String handlerPath = "/api/v1/resource/{id}/details" ;
92
+ assertTrue ((Boolean ) restPathMatches .invoke (securityRestFilter , requestPath , handlerPath ));
93
+ }
94
+
95
+ @ Test
96
+ public void testPathsDoNotMatchWithNonMatchingNamedParameterSegment () throws InvocationTargetException , IllegalAccessException {
97
+ String requestPath = "/api/v1/resource/123/details" ;
98
+ String handlerPath = "/api/v1/resource/{id}/summary" ;
78
99
assertFalse ((Boolean ) restPathMatches .invoke (securityRestFilter , requestPath , handlerPath ));
79
100
}
80
101
81
102
@ Test
82
- public void testRequestPathWithExtraSegments () throws InvocationTargetException , IllegalAccessException {
83
- String requestPath = "_plugins/security/ api/x/y/z " ;
84
- String handlerPath = "_plugins/security/ api/x/y " ;
103
+ public void testDifferentSegmentCount () throws InvocationTargetException , IllegalAccessException {
104
+ String requestPath = "/ api/v1/resource/123/extra " ;
105
+ String handlerPath = "/ api/v1/resource/{id} " ;
85
106
assertFalse ((Boolean ) restPathMatches .invoke (securityRestFilter , requestPath , handlerPath ));
86
107
}
87
108
}
0 commit comments