Exemple #1
0
def test_projectkeys(default_project, task_runner, redis_cache):
    with task_runner():
        deleted_pks = list(ProjectKey.objects.filter(project=default_project))
        for key in deleted_pks:
            key.delete()

        pk = ProjectKey(project=default_project)
        pk.save()

    for key in deleted_pks:
        # XXX: Ideally we would write `{"disabled": False}` into Redis, however
        # it's fine if we don't and instead Relay starts hitting the endpoint
        # which will write this for us.
        assert not redis_cache.get(key.public_key)

    for cache_key in (default_project.id, pk.public_key):
        (pk_json, ) = redis_cache.get(cache_key)["publicKeys"]
        assert pk_json["publicKey"] == pk.public_key
        assert pk_json["isEnabled"]

    with task_runner():
        pk.delete()

    assert not redis_cache.get(default_project.id)["publicKeys"]

    for key in ProjectKey.objects.filter(project_id=default_project.id):
        assert not redis_cache.get(default_project.id)
Exemple #2
0
def test_projectkeys(default_project, task_runner, redis_cache):
    with task_runner():
        ProjectKey.objects.filter(project=default_project).delete()
        pk = ProjectKey(project=default_project)
        pk.save()

    (pk_json, ) = redis_cache.get(default_project.id)["publicKeys"]
    assert pk_json["publicKey"] == pk.public_key
    assert pk_json["isEnabled"]

    with task_runner():
        pk.delete()

    assert not redis_cache.get(default_project.id)["publicKeys"]