Skip to content

Commit e235107

Browse files
🧪 [testing improvement] Add test for case-insensitive hostname matching (#622)
- Added testVerifyHostnameMatchCaseInsensitive to ReCaptchaTest.php. - Verified that the test correctly handles mismatched casing between expected and actual hostnames. - Confirmed that the test fails if case-insensitive matching is disabled. 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 a6c5041 commit e235107

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎tests/ReCaptcha/ReCaptchaTest.php‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ public function testVerifyHostnameMisMatch(): void
192192
$this->assertEquals([ReCaptcha::E_HOSTNAME_MISMATCH], $response->getErrorCodes());
193193
}
194194

195+
public function testVerifyHostnameMatchCaseInsensitive(): void
196+
{
197+
$method = $this->getMockRequestMethod('{"success": true, "hostname": "host.name"}');
198+
$rc = new ReCaptcha('secret', $method);
199+
$response = $rc->setExpectedHostname('HOST.NAME')->verify('response');
200+
$this->assertTrue($response->isSuccess());
201+
202+
$method = $this->getMockRequestMethod('{"success": true, "hostname": "HOST.NAME"}');
203+
$rc = new ReCaptcha('secret', $method);
204+
$response = $rc->setExpectedHostname('host.name')->verify('response');
205+
$this->assertTrue($response->isSuccess());
206+
}
207+
195208
public function testVerifyApkPackageNameMatch(): void
196209
{
197210
$method = $this->getMockRequestMethod('{"success": true, "apk_package_name": "apk.name"}');

0 commit comments

Comments
 (0)