Esempio n. 1
0
async def _validate(key: str):
    if not muid.validate(key):
        raise HTTPException(status_code=http.HTTPStatus.BAD_REQUEST,
                            detail='Invalid key')

    record = await database.fetch_one("select * from keys where key=:key",
                                      values={'key': key})

    if record is not None:
        raise HTTPException(status_code=http.HTTPStatus.ALREADY_REPORTED,
                            detail=f'key already in db: {record}')
Esempio n. 2
0
def test_create():
    key = create(difficulty=7)
    assert validate(key)
Esempio n. 3
0
 def is_valid_key(key):
     """ Check if key is hash-memorable """
     return isinstance(key, str) and muid.validate(key)