26
26
import org .apache .struts2 .dispatcher .RequestMap ;
27
27
import org .apache .struts2 .dispatcher .SessionMap ;
28
28
import org .apache .struts2 .mock .MockActionInvocation ;
29
+ import org .apache .struts2 .ognl .ThreadAllowlist ;
29
30
import org .apache .struts2 .util .ValueStack ;
31
+ import org .assertj .core .api .InstanceOfAssertFactories ;
30
32
import org .assertj .core .util .Maps ;
31
- import org .junit .After ;
32
33
import org .junit .Before ;
33
34
import org .junit .Test ;
34
35
import org .springframework .mock .web .MockHttpServletRequest ;
@@ -47,6 +48,7 @@ public class DebuggingInterceptorTest extends StrutsJUnit4InternalTestCase {
47
48
private MockHttpServletRequest request ;
48
49
private MockHttpServletResponse response ;
49
50
private ActionContext context ;
51
+ private TestAction action ;
50
52
51
53
@ Test
52
54
public void noDevMode () throws Exception {
@@ -509,6 +511,31 @@ function expand(src, path) {
509
511
""" );
510
512
}
511
513
514
+ @ Test
515
+ public void allowlist () throws Exception {
516
+ interceptor .setDevMode ("true" );
517
+ context .withParameters (HttpParameters .create (Maps .newHashMap ("debug" , "browser" )).build ());
518
+
519
+ assertThat (container .getInstance (ThreadAllowlist .class ))
520
+ .extracting (ThreadAllowlist ::getAllowlist ).asInstanceOf (InstanceOfAssertFactories .SET )
521
+ .isEmpty ();
522
+
523
+ interceptor .intercept (invocation );
524
+ invocation .invoke ();
525
+
526
+ assertThat (container .getInstance (ThreadAllowlist .class ))
527
+ .extracting (ThreadAllowlist ::getAllowlist ).asInstanceOf (InstanceOfAssertFactories .SET )
528
+ .contains (
529
+ org .apache .struts2 .interceptor .ValidationAware .class ,
530
+ org .apache .struts2 .Validateable .class ,
531
+ org .apache .struts2 .action .Action .class ,
532
+ org .apache .struts2 .text .TextProvider .class ,
533
+ org .apache .struts2 .ActionSupport .class ,
534
+ org .apache .struts2 .locale .LocaleProvider .class ,
535
+ org .apache .struts2 .TestAction .class
536
+ );
537
+ }
538
+
512
539
@ Before
513
540
public void before () {
514
541
request = new MockHttpServletRequest ();
@@ -530,23 +557,13 @@ public void before() {
530
557
invocation = new MockActionInvocation ();
531
558
invocation .setResultCode ("mock" );
532
559
invocation .setInvocationContext (context );
533
- invocation .setAction (new TestAction ());
560
+ action = new TestAction ();
561
+ invocation .setAction (action );
534
562
invocation .setStack (valueStack );
535
563
536
564
valueStack .set ("action" , invocation .getAction ());
537
565
538
566
context = context .withActionInvocation (invocation ).bind ();
539
567
}
540
568
541
- @ After
542
- public void after () {
543
- interceptor .destroy ();
544
- interceptor = null ;
545
- invocation = null ;
546
-
547
- servletContext = null ;
548
- request = null ;
549
- response = null ;
550
- }
551
-
552
569
}
0 commit comments