@@ -93,44 +93,69 @@ public function testUsePath()
93
93
$ this ->assertEquals ('ok ' , $ event ->getResponse ()->getContent ());
94
94
}
95
95
96
+ /**
97
+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
98
+ * @expectedExceptionMessage Invalid JSON
99
+ */
100
+ public function testAttemptAuthenticationNoJson ()
101
+ {
102
+ $ this ->createListener ();
103
+ $ request = new Request ();
104
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)->getMock (), $ request , KernelInterface::MASTER_REQUEST );
105
+
106
+ $ this ->listener ->handle ($ event );
107
+ }
108
+
109
+ /**
110
+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
111
+ * @expectedExceptionMessage The key "username" must be provided
112
+ */
96
113
public function testAttemptAuthenticationNoUsername ()
97
114
{
98
115
$ this ->createListener ();
99
116
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"usr": "dunglas", "password": "foo"} ' );
100
117
$ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)->getMock (), $ request , KernelInterface::MASTER_REQUEST );
101
118
102
119
$ this ->listener ->handle ($ event );
103
- $ this ->assertSame ('ko ' , $ event ->getResponse ()->getContent ());
104
120
}
105
121
122
+ /**
123
+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
124
+ * @expectedExceptionMessage The key "password" must be provided
125
+ */
106
126
public function testAttemptAuthenticationNoPassword ()
107
127
{
108
128
$ this ->createListener ();
109
129
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "pass": "foo"} ' );
110
130
$ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)->getMock (), $ request , KernelInterface::MASTER_REQUEST );
111
131
112
132
$ this ->listener ->handle ($ event );
113
- $ this ->assertSame ('ko ' , $ event ->getResponse ()->getContent ());
114
133
}
115
134
135
+ /**
136
+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
137
+ * @expectedExceptionMessage The key "username" must be a string.
138
+ */
116
139
public function testAttemptAuthenticationUsernameNotAString ()
117
140
{
118
141
$ this ->createListener ();
119
142
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": 1, "password": "foo"} ' );
120
143
$ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)->getMock (), $ request , KernelInterface::MASTER_REQUEST );
121
144
122
145
$ this ->listener ->handle ($ event );
123
- $ this ->assertSame ('ko ' , $ event ->getResponse ()->getContent ());
124
146
}
125
147
148
+ /**
149
+ * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
150
+ * @expectedExceptionMessage The key "password" must be a string.
151
+ */
126
152
public function testAttemptAuthenticationPasswordNotAString ()
127
153
{
128
154
$ this ->createListener ();
129
155
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "password": 1} ' );
130
156
$ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)->getMock (), $ request , KernelInterface::MASTER_REQUEST );
131
157
132
158
$ this ->listener ->handle ($ event );
133
- $ this ->assertSame ('ko ' , $ event ->getResponse ()->getContent ());
134
159
}
135
160
136
161
public function testAttemptAuthenticationUsernameTooLong ()
0 commit comments