async def METHOD_NAME(legacy, user_id, password, result, mongo):
    """
    Test that valid, bcrypt-based credentials work.
    """
    document = {"_id": "test"}
    if legacy:
        salt = random_alphanumeric(24)
        document.update(
            {
                "salt": salt,
                "password": hashlib.sha512(
                    salt.encode("utf-8") + "foobar".encode("utf-8")
                ).hexdigest(),
            }
        )
    else:
        document["password"] = hash_password("foobar")
    await mongo.users.insert_one(document)
    assert await validate_credentials(mongo, user_id, password) is result