Skip to content

Commit b6e64e7

Browse files
Add test for SocketPost overriding siteVerifyUrl (#612)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
1 parent 04b4aba commit b6e64e7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/ReCaptcha/RequestMethod/SocketPostTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,27 @@ public function testSubmit(): void
161161
$this->assertTrue(SocketPostGlobalState::$fcloseCalled);
162162
}
163163

164+
public function testOverrideSiteVerifyUrl(): void
165+
{
166+
SocketPostGlobalState::$fgetsResponses = [
167+
"HTTP/1.0 200 OK\r\n",
168+
"Content-Type: application/json\r\n",
169+
"\r\n",
170+
'RESPONSEBODY',
171+
];
172+
173+
$url = 'https://custom.recaptcha.net/recaptcha/api/siteverify';
174+
$sp = new SocketPost($url);
175+
$response = $sp->submit(new RequestParameters('secret', 'response'));
176+
177+
$this->assertEquals('ssl://custom.recaptcha.net', SocketPostGlobalState::$fsockopenHostname);
178+
$this->assertStringContainsString('POST /recaptcha/api/siteverify HTTP/1.0', SocketPostGlobalState::$fwriteData);
179+
$this->assertStringContainsString('secret=secret', SocketPostGlobalState::$fwriteData);
180+
$this->assertStringContainsString('response=response', SocketPostGlobalState::$fwriteData);
181+
$this->assertEquals('RESPONSEBODY', $response);
182+
$this->assertTrue(SocketPostGlobalState::$fcloseCalled);
183+
}
184+
164185
public function testStreamTimeoutFailureReturnsError(): void
165186
{
166187
SocketPostGlobalState::$streamSetTimeoutSuccess = false;

0 commit comments

Comments
 (0)