Add unit test

This commit is contained in:
Jake Barnby
2025-02-11 22:02:20 +13:00
parent d04a5cab0d
commit bed7ab321e
3 changed files with 67 additions and 0 deletions
+9
View File
@@ -52,6 +52,15 @@ class Key
return $this->usage;
}
/**
* Decode the given secret key into a Key object, containing the project ID, type, role, scopes, and name.
* Can be a stored API key or a dynamic key (JWT).
*
* @param Document $project
* @param string $key
* @return Key
* @throws Exception
*/
public static function decode(
Document $project,
string $key
@@ -193,6 +193,7 @@ class Migrations extends Action
protected function generateAPIKey(Document $project): string
{
$jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 86400, 0);
$apiKey = $jwt->encode([
'projectId' => $project->getId(),
'usage' => false,