@@ -88,7 +88,7 @@ public void should_return_management_context_with_context_path() throws Exceptio
88
88
public void should_return_empty_when_no_endpoints () {
89
89
EndpointsSupplier <ExposableWebEndpoint > endpointsSupplier = Collections ::emptyList ;
90
90
Optional <Pattern > pattern = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
91
- .skipPatternForActuatorEndpoints (new ServerProperties (),
91
+ .skipPatternForActuatorEndpointsSamePort (new ServerProperties (),
92
92
new WebEndpointProperties (), endpointsSupplier )
93
93
.skipPattern ();
94
94
@@ -107,8 +107,7 @@ public void should_return_endpoints_without_context_path() {
107
107
};
108
108
109
109
Optional <Pattern > pattern = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
110
- .skipPatternForActuatorEndpoints (properties , webEndpointProperties ,
111
- endpointsSupplier )
110
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
112
111
.skipPattern ();
113
112
114
113
then (pattern ).isNotEmpty ();
@@ -130,8 +129,7 @@ public void should_return_endpoints_with_context_path() {
130
129
};
131
130
132
131
Optional <Pattern > pattern = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
133
- .skipPatternForActuatorEndpoints (properties , webEndpointProperties ,
134
- endpointsSupplier )
132
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
135
133
.skipPattern ();
136
134
137
135
then (pattern ).isNotEmpty ();
@@ -153,8 +151,7 @@ public void should_return_endpoints_without_context_path_and_base_path_set_to_ro
153
151
};
154
152
155
153
Optional <Pattern > pattern = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
156
- .skipPatternForActuatorEndpoints (properties , webEndpointProperties ,
157
- endpointsSupplier )
154
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
158
155
.skipPattern ();
159
156
160
157
then (pattern ).isNotEmpty ();
@@ -176,14 +173,103 @@ public void should_return_endpoints_with_context_path_and_base_path_set_to_root(
176
173
};
177
174
178
175
Optional <Pattern > pattern = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
179
- .skipPatternForActuatorEndpoints (properties , webEndpointProperties ,
180
- endpointsSupplier )
176
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
181
177
.skipPattern ();
182
178
183
179
then (pattern ).isNotEmpty ();
184
180
then (pattern .get ().pattern ()).isEqualTo ("foo/(info|info/.*|health|health/.*)" );
185
181
}
186
182
183
+ @ Test
184
+ public void should_return_endpoints_with_actuator_context_path_set_to_root () {
185
+ WebEndpointProperties webEndpointProperties = new WebEndpointProperties ();
186
+ webEndpointProperties .setBasePath ("/" );
187
+ ServerProperties properties = new ServerProperties ();
188
+ properties .getServlet ().setContextPath ("foo" );
189
+
190
+ EndpointsSupplier <ExposableWebEndpoint > endpointsSupplier = () -> {
191
+ ExposableWebEndpoint infoEndpoint = createEndpoint ("info" );
192
+ ExposableWebEndpoint healthEndpoint = createEndpoint ("health" );
193
+
194
+ return Arrays .asList (infoEndpoint , healthEndpoint );
195
+ };
196
+
197
+ Optional <Pattern > patternDifferentPort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
198
+ .skipPatternForActuatorEndpointsDifferentPort (properties , webEndpointProperties , endpointsSupplier )
199
+ .skipPattern ();
200
+
201
+ then (patternDifferentPort ).isNotEmpty ();
202
+ then (patternDifferentPort .get ().pattern ()).isEqualTo ("/(info|info/.*|health|health/.*)" );
203
+
204
+ Optional <Pattern > patternSamePort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
205
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
206
+ .skipPattern ();
207
+
208
+ then (patternSamePort ).isNotEmpty ();
209
+ then (patternSamePort .get ().pattern ())
210
+ .isEqualTo ("foo/(info|info/.*|health|health/.*)" );
211
+ }
212
+
213
+ @ Test
214
+ public void should_return_endpoints_with_actuator_context_path_only () {
215
+ WebEndpointProperties webEndpointProperties = new WebEndpointProperties ();
216
+ webEndpointProperties .setBasePath ("/mgt" );
217
+ ServerProperties properties = new ServerProperties ();
218
+ properties .getServlet ().setContextPath ("foo" );
219
+
220
+ EndpointsSupplier <ExposableWebEndpoint > endpointsSupplier = () -> {
221
+ ExposableWebEndpoint infoEndpoint = createEndpoint ("info" );
222
+ ExposableWebEndpoint healthEndpoint = createEndpoint ("health" );
223
+
224
+ return Arrays .asList (infoEndpoint , healthEndpoint );
225
+ };
226
+
227
+ Optional <Pattern > patternDifferentPort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
228
+ .skipPatternForActuatorEndpointsDifferentPort (properties , webEndpointProperties , endpointsSupplier )
229
+ .skipPattern ();
230
+
231
+ then (patternDifferentPort ).isNotEmpty ();
232
+ then (patternDifferentPort .get ().pattern ())
233
+ .isEqualTo ("/mgt/(info|info/.*|health|health/.*)" );
234
+
235
+ Optional <Pattern > patternSamePort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
236
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
237
+ .skipPattern ();
238
+
239
+ then (patternSamePort ).isNotEmpty ();
240
+ then (patternSamePort .get ().pattern ())
241
+ .isEqualTo ("foo/mgt/(info|info/.*|health|health/.*)" );
242
+ }
243
+
244
+ @ Test
245
+ public void should_return_endpoints_with_actuator_default_context_path () {
246
+ WebEndpointProperties webEndpointProperties = new WebEndpointProperties ();
247
+ ServerProperties properties = new ServerProperties ();
248
+ properties .getServlet ().setContextPath ("/foo" );
249
+ properties .setPort (8080 );
250
+
251
+ EndpointsSupplier <ExposableWebEndpoint > endpointsSupplier = () -> {
252
+ ExposableWebEndpoint infoEndpoint = createEndpoint ("info" );
253
+ ExposableWebEndpoint healthEndpoint = createEndpoint ("health" );
254
+
255
+ return Arrays .asList (infoEndpoint , healthEndpoint );
256
+ };
257
+
258
+ Optional <Pattern > patternDifferentPort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
259
+ .skipPatternForActuatorEndpointsDifferentPort (properties , webEndpointProperties , endpointsSupplier )
260
+ .skipPattern ();
261
+
262
+ then (patternDifferentPort ).isNotEmpty ();
263
+ then (patternDifferentPort .get ().pattern ()).isEqualTo ("/actuator/(info|info/.*|health|health/.*)" );
264
+
265
+ Optional <Pattern > patternSamePort = new TraceWebAutoConfiguration .ActuatorSkipPatternProviderConfig ()
266
+ .skipPatternForActuatorEndpointsSamePort (properties , webEndpointProperties , endpointsSupplier )
267
+ .skipPattern ();
268
+
269
+ then (patternSamePort ).isNotEmpty ();
270
+ then (patternSamePort .get ().pattern ()).isEqualTo ("/foo/actuator/(info|info/.*|health|health/.*)" );
271
+ }
272
+
187
273
@ Test
188
274
public void should_combine_skip_patterns_from_list () throws Exception {
189
275
TraceWebAutoConfiguration configuration = new TraceWebAutoConfiguration ();
0 commit comments