Add new command to delete API keys

This commit is contained in:
Alejandro Celaya
2025-10-20 09:58:21 +02:00
parent cae18ccfb3
commit b5a9353b85
10 changed files with 276 additions and 4 deletions

View File

@@ -40,4 +40,18 @@ class ApiKeyRepositoryTest extends DatabaseTestCase
self::assertTrue($this->repo->nameExists('foo'));
self::assertFalse($this->repo->nameExists('bar'));
}
#[Test]
public function deleteByNameReturnsExpectedValue(): void
{
$this->getEntityManager()->persist(ApiKey::fromMeta(ApiKeyMeta::fromParams(name: 'foo')));
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
self::assertEquals(0, $this->repo->deleteByName('invalid'));
self::assertEquals(1, $this->repo->deleteByName('foo'));
// Verify the API key has been deleted
self::assertNull($this->repo->findOneBy(['name' => 'foo']));
}
}