Пример #1
0
def test_snyk_put_process_epv_fail(mock_pv):
    """Test the SnykCVEPut.process() fail."""
    mock_pv.return_value = [], False, {}

    cve = SnykCVEPut(valid_snyk_put_input)
    try:
        cve.process()
    except InternalServerError as e:
        assert "CVEIngestionError" in str(e)
def test_snyk_put_process_cve_fail(mock_gremlin, mock_pv):
    """Test the SnykCVEPut.process() success."""
    mock_pv.return_value = [], True, {}
    mock_gremlin.side_effect = [
        RequestsMockResponse({}, 200),
        RequestsMockResponse({}, 200),
        RequestsMockResponse({}, 500),
        RequestsMockResponse({}, 200)
    ]

    cve = SnykCVEPut(valid_snyk_put_input)
    cve.process()
Пример #3
0
def test_snyk_put_process_cve_fail(mock_gremlin, mock_pv):
    """Test the SnykCVEPut.process() success."""
    mock_pv.return_value = [], True, {}
    mock_gremlin.side_effect = [RequestsMockResponse({}, 200),
                                RequestsMockResponse({}, 200),
                                RequestsMockResponse({}, 500),
                                RequestsMockResponse({}, 200)]

    cve = SnykCVEPut(valid_snyk_put_input)
    try:
        cve.process()
    except InternalServerError as e:
        assert "Snyk CVEIngestionError - While creating CVE edges." in str(e)
Пример #4
0
def snyk_cves_put_delete():
    """Put or delete Snyk CVE nodes.

    Missing EPVs will be created.
    """
    payload = request.get_json(silent=True)
    try:
        if request.method == 'PUT':
            cve = SnykCVEPut(payload)
        elif request.method == 'DELETE':
            cve = SnykCVEDelete(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
def test_snyk_put_process_epv_fail(mock_pv):
    """Test the SnykCVEPut.process() fail."""
    mock_pv.return_value = [], False, {}

    cve = SnykCVEPut(valid_snyk_put_input)
    cve.process()