MCPcopy Create free account
hub / github.com/alephdata/aleph / test_hash_plaintext_api_keys

Method test_hash_plaintext_api_keys

aleph/tests/test_api_keys.py:199–224  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

197 assert outbox[5].subject == "[Aleph] Your API key has expired"
198
199 def test_hash_plaintext_api_keys(self):
200 user_1 = self.create_user(foreign_id="user_1", email="user1@example.org")
201 user_1.api_key = "1234567890"
202 user_1.api_key_digest = None
203
204 user_2 = self.create_user(foreign_id="user_2", email="user2@example.org")
205 user_2.api_key = None
206 user_2.api_key_digest = None
207
208 db.session.add_all([user_1, user_2])
209 db.session.commit()
210
211 hash_plaintext_api_keys()
212
213 db.session.refresh(user_1)
214
215 # Do not delete the plaintext API key to allow for version rollbacks.
216 # `api_key` column will be removed in the next version at which point all
217 # plaintext keys will be deleted.
218 assert user_1.api_key == "1234567890"
219
220 assert user_1.api_key_digest == hash_api_key("1234567890")
221
222 db.session.refresh(user_2)
223 assert user_2.api_key is None
224 assert user_2.api_key_digest is None

Callers

nothing calls this directly

Calls 3

hash_plaintext_api_keysFunction · 0.90
hash_api_keyFunction · 0.90
create_userMethod · 0.80

Tested by

no test coverage detected