Update: 2026-07-17 00:13:30

This commit is contained in:
Hamza-Ayed
2026-07-17 00:13:30 +03:00
parent 034d64b6f2
commit 8cb83b31f2
5 changed files with 236 additions and 13 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
// stress_test/generate_mock_data.php
// Generates a valid JWT for the driver using the system's JWT_SECRET_KEY
require_once dirname(__DIR__) . '/backend/connect.php';
require_once dirname(__DIR__) . '/loction_server/vendor/autoload.php';
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
function getJwtSecret(): string {
$keyPath = getenv('JWT_SECRET_KEY_PATH');
if ($keyPath && file_exists($keyPath)) {
return trim(file_get_contents($keyPath));
}
return getenv('JWT_SECRET_KEY') ?: '';
}
$secret = getJwtSecret();
if (empty($secret)) {
die("Error: JWT_SECRET_KEY not found. Cannot generate mock JWT.\n");
}
$driverId = $argv[1] ?? '999999';
$payload = [
'sub' => (string)$driverId,
'role' => 'driver',
'iat' => time(),
'exp' => time() + 86400
];
$jwt = JWT::encode($payload, $secret, 'HS256');
echo json_encode([
'driver_id' => $driverId,
'jwt' => $jwt
]);