コード例 #1
0
def test_cve_delete_prepare_payload():
    """Test CVEDelete.prepare_payload()."""
    cve = CVEDelete(valid_delete_input)
    json_payload = cve.prepare_payload()

    assert 'gremlin' in json_payload
    assert json_payload['gremlin'].startswith(cve_node_delete_script_template)

    assert 'bindings' in json_payload
    bindings = json_payload['bindings']

    assert 'cve_id' in bindings
    assert bindings['cve_id']
コード例 #2
0
def cves_put_delete():
    """Put or delete CVE nodes.

    Missing EPVs will be created.
    """
    payload = request.get_json(silent=True)
    try:
        if request.method == 'PUT':
            cve = CVEPut(payload)
        elif request.method == 'DELETE':
            cve = CVEDelete(payload)
        else:
            # this should never happen
            return flask.jsonify({'error': 'method not allowed'}), 405
    except ValueError as e:
        return flask.jsonify({'error': str(e)}), 400

    try:
        cve.process()
    except ValueError as e:
        return flask.jsonify({'error': str(e)}), 500

    return flask.jsonify({}), 200
コード例 #3
0
def test_cve_delete_creation():
    """Test CVEDelete input validation."""
    assert CVEDelete(valid_delete_input)

    with pytest.raises(ValueError):
        CVEDelete(invalid_delete_input)