Ejemplo n.º 1
0
def test_validate_response_invalid_error_key_type():
    for bad in [{}, None, 1, lambda x: x, set()]:
        with pytest.raises(plugins.ValidationException):
            plugins.validate_response({
                "type": "rule",
                "error_key": bad
            })
Ejemplo n.º 2
0
def test_validate_fingerprint_invalid_fingerprint_key_type():
    for bad in [{}, None, 1, lambda x: x, set()]:
        with pytest.raises(plugins.ValidationException):
            plugins.validate_response({
                "type": "fingerprint",
                "fingerprint_key": bad
            })
Ejemplo n.º 3
0
def test_validate_response_missing_fingerprint_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "fingerprint", "foo": "bar"})
Ejemplo n.º 4
0
def test_validate_fingerprint_good():
    assert plugins.validate_response({
        "type": "fingerprint",
        "fingerprint_key": "FINGERPRINT",
        "foo": "bar"}) is None
Ejemplo n.º 5
0
def test_validate_response_missing_error_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "rule", "foo": "bar"})
Ejemplo n.º 6
0
def test_validate_response_invalid_type_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "dance off"})
Ejemplo n.º 7
0
def test_validate_response_missing_type():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"error_key": "an_error"})
Ejemplo n.º 8
0
def test_validate_response_invalid_types():
    for bad in [[], None, set(), "", 1, lambda x: x]:
        with pytest.raises(plugins.ValidationException):
            plugins.validate_response(bad)
Ejemplo n.º 9
0
def test_validate_response_good():
    assert plugins.validate_response({
        "type": "rule",
        "error_key": "a_test",
        "foo": "bar"}) is None