예제 #1
0
def test_blobs_put(curieapi_small, blob):
    r = curieapi_small.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, vec_blobs[blob])
    jdata = {"format": "string", "blob": "LQKJDMLAKJDLQDS?NF%LQKNSKQ"}
    r = curieapi_small.blobs.update("pytest", blob, body=jdata)
    assert r.status_code == 200
    r = curieapi_small.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, jdata)
예제 #2
0
def test_blobs_delete(curieapi_small, blob):
    r = curieapi_small.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, vec_blobs[blob])
    r = curieapi_small.blobs.delete("pytest", blob)
    assert r.status_code == 200
    with pytest.raises(NotFoundError):
        r = curieapi_small.blobs.get("pytest", blob)
    with pytest.raises(NotFoundError):
        r = curieapi_small.blobs.delete("pytest", blob)
예제 #3
0
def test_configs_update(curieapi_small):
    curieapi = curieapi_small
    r = curieapi.configs.get("pytest")
    assert r.status_code == 200
    assert compare_jblob(r.body["blobs"]["bltor"] , vec_bltor)
    assert r.body["documents"]["limits"] == [ vec_limit ]
    assert r.body["documents"]["wafsigs"] == [ vec_wafsig ]
    assert r.body["documents"]["urlmaps"] == [ vec_urlmap ]

    jblob = { "blob":["xxx"],"format":"json" }

    newlimits = [ { "id": vec_limit["id"], "data": { "name": "foobar", "key":"1", "limit":"2", "ttl": "3" } },
                  { "id": "newid", "data": {"name": "barfoo", "key":"10", "limit":"20", "ttl": "30" } } ]
    newwafsigs = [ { "id": vec_wafsig["id"], "msg": "XXXX" },
                   {"id": "newid", "msg": "hola", "category":"1", "certainity":2, "operand":"3", "severity":4, "subcategory":"5" } ]
    update = {
        "meta": { "id": "renamed_pytest" },
        "blobs": { "bltor": jblob },
        "documents": { "limits": newlimits, "wafsigs": newwafsigs},
        "delete_blobs": { "bltor": False, "blvpnip": True },
        "delete_documents": { 
            "urlmaps": { "sqdqsd": True, "fezfzf": True, vec_urlmap["id"]: False },
            "wafsigs": { vec_wafsig["id"]: True }
        }
    }

    r = curieapi.configs.update("pytest", body=update)
    assert r.status_code == 200
    with pytest.raises(NotFoundError):
        r = curieapi.configs.get("pytest")

    r = curieapi.configs.get("renamed_pytest")
    assert compare_jblob(r.body["blobs"]["bltor"], jblob)
    assert r.body["documents"]["limits"] == newlimits
    assert r.body["documents"]["wafsigs"] == newwafsigs[1:]
    assert r.body["documents"]["urlmaps"] == [vec_urlmap]
예제 #4
0
def test_configs_get(curieapi):
    r = curieapi.configs.get("pytest")
    assert r.status_code == 200
    res = r.body
    assert res["meta"]["id"] == "pytest"
    assert res["meta"]["version"] != None
    assert res["meta"]["date"] != None
    assert res["meta"]["description"] != None

    assert bootstrap_config_json["documents"].keys() == res["documents"].keys()
    for k in bootstrap_config_json["documents"]:
        assert bootstrap_config_json["documents"][k] == res["documents"][k], k

    assert bootstrap_config_json["blobs"].keys() == res["blobs"].keys()
    for k, retrieved in res["blobs"].items():
        sent = bootstrap_config_json["blobs"][k]
        assert compare_jblob(sent, retrieved)
예제 #5
0
def test_blobs_revert(curieapi, blob):
    r = curieapi.blobs.get("pytest", blob)
    assert r.status_code == 200
    old = r.body
    r = curieapi.configs.list_versions("pytest")
    assert r.status_code == 200
    oldv = r.body[-1]["version"]

    new = {"format": "string", "blob": "LQKJDMLAKJDLQDS?NF%LQKNSKQ"}
    r = curieapi.blobs.update("pytest", blob, body=new)
    assert r.status_code == 200
    r = curieapi.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, new)

    r = curieapi.blobs.revert("pytest", blob, oldv)
    assert r.status_code == 200
    r = curieapi.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert r.body == old
예제 #6
0
def test_blobs_get_2(curieapi, blob):
    r = curieapi.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, bootstrap_config_json["blobs"][blob])
예제 #7
0
def test_blobs_get(curieapi_small, blob):
    r = curieapi_small.blobs.get("pytest", blob)
    assert r.status_code == 200
    assert compare_jblob(r.body, vec_blobs[blob])