Example #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
            })
Example #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
            })
Example #3
0
def test_validate_response_missing_fingerprint_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "fingerprint", "foo": "bar"})
Example #4
0
def test_validate_fingerprint_good():
    assert plugins.validate_response({
        "type": "fingerprint",
        "fingerprint_key": "FINGERPRINT",
        "foo": "bar"}) is None
Example #5
0
def test_validate_response_missing_error_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "rule", "foo": "bar"})
Example #6
0
def test_validate_response_invalid_type_key():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"type": "dance off"})
Example #7
0
def test_validate_response_missing_type():
    with pytest.raises(plugins.ValidationException):
        plugins.validate_response({"error_key": "an_error"})
Example #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)
Example #9
0
def test_validate_response_good():
    assert plugins.validate_response({
        "type": "rule",
        "error_key": "a_test",
        "foo": "bar"}) is None