- Introduced `CreateTokenUserNotFoundTest.php` to validate `create_token` behavior when users are missing. - Added `WebAuthnLogicCheck.php` to test deserialization handling in `webauthn.php`. - Created `WebAuthnReproLogic.php` for verifying credential ID and user handle matching. - These tests aim to enhance coverage and ensure robust handling of edge cases in authentication processes.
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
if (!defined('WD')) { define('WD', dirname(__DIR__, 2)); }
|
|
require_once WD . '/vendor/autoload.php';
|
|
require_once WD . '/classes/webauthn.php';
|
|
|
|
// Mock passkeys_o
|
|
if (!class_exists('objects\passkeys_o')) {
|
|
eval('
|
|
namespace objects;
|
|
class MockProperty
|
|
{
|
|
public function value() { return "mock"; }
|
|
public function set($v) { echo "Sign count updated to " . $v . "\n"; }
|
|
}
|
|
class passkeys_o
|
|
{
|
|
public $credential_id, $public_key, $transports, $user_id, $sign_count;
|
|
public function __construct()
|
|
{
|
|
$this->credential_id = new MockProperty();
|
|
$this->public_key = new MockProperty();
|
|
$this->transports = new MockProperty();
|
|
$this->user_id = new MockProperty();
|
|
$this->sign_count = new MockProperty();
|
|
}
|
|
}
|
|
');
|
|
}
|
|
|
|
try {
|
|
$wa = new classes\webauthn();
|
|
echo "✔ Successfully instantiated classes\webauthn\n";
|
|
|
|
// Attempting to call verifyAssertion with garbage JSON to see if it crashes on deserialization call
|
|
// It should throw an exception or return false, but NOT a Fatal Error for missing classes.
|
|
$res = $wa->verifyAssertion("{}", "abc", new objects\passkeys_o(), "localhost");
|
|
echo "✔ verifyAssertion returned: " . ($res ? 'true' : 'false') . " (expected false for garbage JSON)\n";
|
|
|
|
} catch (Exception $e) {
|
|
echo "✘ Exception: " . $e->getMessage() . "\n";
|
|
} catch (Error $e) {
|
|
echo "✘ Fatal error: " . $e->getMessage() . "\n";
|
|
exit(1);
|
|
}
|