5
5
namespace Chaos \Monkey \Symfony \Tests \Controller ;
6
6
7
7
use Chaos \Monkey \Settings ;
8
+ use Chaos \Monkey \Symfony \Activator \QueryParamActivator ;
8
9
use Chaos \Monkey \Symfony \Tests \Symfony \Kernel ;
9
10
use PHPUnit \Framework \TestCase ;
10
11
use Symfony \Bundle \FrameworkBundle \KernelBrowser ;
12
+ use Symfony \Component \HttpKernel \Exception \LockedHttpException ;
11
13
use Symfony \Component \Stopwatch \Stopwatch ;
12
14
13
15
class SymfonyControllerTest extends TestCase
@@ -49,7 +51,22 @@ public function testRequestExceptionAttack(): void
49
51
$ this ->enableExceptionAssault ();
50
52
$ this ->client ->request ('GET ' , '/hello ' );
51
53
52
- self ::assertEquals (500 , $ this ->client ->getResponse ()->getStatusCode ());
54
+ self ::assertEquals (423 , $ this ->client ->getResponse ()->getStatusCode ());
55
+
56
+ $ this ->disableExceptionAssault ();
57
+ }
58
+
59
+ public function testRequestExceptionAttackWithQueryParamActivatorEnabled (): void
60
+ {
61
+ $ this ->enableQueryParamActivator ();
62
+ $ this ->enableExceptionAssault ();
63
+ $ this ->client ->request ('GET ' , '/hello ' );
64
+
65
+ self ::assertEquals (200 , $ this ->client ->getResponse ()->getStatusCode ());
66
+
67
+ $ this ->client ->request ('GET ' , '/hello?chaos=true ' );
68
+
69
+ self ::assertEquals (423 , $ this ->client ->getResponse ()->getStatusCode ());
53
70
54
71
$ this ->disableExceptionAssault ();
55
72
}
@@ -58,6 +75,7 @@ private function enableExceptionAssault(): void
58
75
{
59
76
$ this ->chaosMonkeySettings ()->setEnabled (true );
60
77
$ this ->chaosMonkeySettings ()->setExceptionActive (true );
78
+ $ this ->chaosMonkeySettings ()->setExceptionClass (LockedHttpException::class);
61
79
$ this ->chaosMonkeySettings ()->setProbability (100 );
62
80
}
63
81
@@ -84,4 +102,9 @@ private function chaosMonkeySettings(): Settings
84
102
{
85
103
return $ this ->client ->getContainer ()->get ('chaos_monkey ' )->settings ();
86
104
}
105
+
106
+ private function enableQueryParamActivator (): void
107
+ {
108
+ $ this ->client ->getContainer ()->get ('test.service_container ' )->set ('chaos_monkey.activator.query_param ' , new QueryParamActivator (true ));
109
+ }
87
110
}
0 commit comments