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