Hash existing API keys, and do checks against the hash

This commit is contained in:
Alejandro Celaya
2024-11-05 23:23:06 +01:00
parent 9f6975119e
commit 1b9c8377ae
5 changed files with 61 additions and 10 deletions

View File

@@ -24,9 +24,9 @@ class ApiKeyRepositoryTest extends DatabaseTestCase
self::assertCount(0, $this->repo->findAll());
self::assertNotNull($this->repo->createInitialApiKey('initial_value'));
self::assertCount(1, $this->repo->findAll());
self::assertCount(1, $this->repo->findBy(['key' => 'initial_value']));
self::assertCount(1, $this->repo->findBy(['key' => ApiKey::hashKey('initial_value')]));
self::assertNull($this->repo->createInitialApiKey('another_one'));
self::assertCount(1, $this->repo->findAll());
self::assertCount(0, $this->repo->findBy(['key' => 'another_one']));
self::assertCount(0, $this->repo->findBy(['key' => ApiKey::hashKey('another_one')]));
}
}