Use the reCAPTCHA Enterprise API.

This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent cc47d0ee51
commit 77800174c9
11 changed files with 265 additions and 60 deletions
+4 -3
View File
@@ -10,15 +10,16 @@ namespace Xxx\Tests\Support;
* returns one of these.
*/
class FakeRecaptcha {
public const PASS = '{"tokenProperties":{"valid":true,"hostname":"site.test","action":"submit"}}';
public static array $requests = array();
public static $reply = '{"success": true}';
public static $reply = self::PASS;
private static bool $active = FALSE;
public $context;
private string $data = '';
private int $position = 0;
public static function install($reply = '{"success": true}'): void {
public static function install($reply = self::PASS): void {
self::$requests = array();
self::$reply = $reply;
if (!self::$active) {
@@ -38,7 +39,7 @@ class FakeRecaptcha {
public function stream_open($path, $mode, $options, &$opened_path) {
$context = $this->context ? stream_context_get_options($this->context) : array();
$http = $context['http'] ?? array();
parse_str((string)($http['content'] ?? ''), $post);
$post = json_decode((string)($http['content'] ?? ''), TRUE) ?? array();
self::$requests[] = array('url' => $path, 'http' => $http, 'post' => $post);
$reply = self::$reply instanceof \Closure ? (self::$reply)($post) : self::$reply;
if ($reply === FALSE)