Skip to content

Commit df61d9d

Browse files
committed
test: verify SocketPost correctly rejects unsupported HTTP protocols
1 parent 9b1acb9 commit df61d9d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/ReCaptcha/RequestMethod/SocketPostTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public function testSubmitReturnsResponseWhenHttp11(): void
193193

194194
$sp = new SocketPost();
195195
$response = $sp->submit(new RequestParameters('secret', 'response'));
196+
196197
$this->assertEquals('RESPONSEBODY', $response);
197198
$this->assertTrue(SocketPostGlobalState::$fcloseCalled);
198199
}
@@ -301,4 +302,19 @@ public function testBadResponseReturnsErrorWhenHttp11(): void
301302

302303
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}', $response);
303304
}
305+
306+
public function testBadResponseReturnsErrorWhenHttp2(): void
307+
{
308+
SocketPostGlobalState::$fgetsResponses = [
309+
"HTTP/2.0 200 OK\r\n",
310+
"Content-Type: application/json\r\n",
311+
"\r\n",
312+
'RESPONSEBODY',
313+
];
314+
315+
$sp = new SocketPost();
316+
$response = $sp->submit(new RequestParameters('secret', 'response'));
317+
318+
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}', $response);
319+
}
304320
}

0 commit comments

Comments
 (0)