コード例 #1
0
def test_snyk_create_pv_nodes(mock_bg, mock_gp, util):
    """Test SnykCVEPut.create_pv_nodes()."""
    mock_gp.return_value = "query pkg.property('latest_version', '1.2.3');"
    mock_bg.return_value = True, {}
    util.return_value = "Success"

    cve = SnykCVEPut(valid_snyk_put_input)
    nodes, successfull_create, aff = cve.create_pv_nodes()
    assert len(nodes) == 3
    assert successfull_create is True
    assert ('pypi', 'numpy', '1.1') in nodes
    assert ('pypi', 'numpy', '1.2') in nodes
    assert ('pypi', 'numpy', '1.3') in nodes
    assert 'numpy' not in aff
    assert len(aff) == 0

    cve = SnykCVEPut(valid_snyk_put_input2)
    nodes, successfull_create, aff = cve.create_pv_nodes()
    assert len(nodes) == 4
    assert successfull_create is True
    assert aff['numpy']['latest_version'] == "1.4"
    assert aff['numpy']['ecosystem'] == "pypi"
    assert 'latest_non_cve_version' not in aff['numpy']

    cve = SnykCVEPut(valid_snyk_put_input3)
    nodes, successfull_create, aff = cve.create_pv_nodes()
    assert len(nodes) == 5
    assert successfull_create is True
    assert ('golang', 'some_golang_pkg', '1.4') in nodes
    assert 'some_golang_pkg' not in aff
    assert len(aff) == 0
コード例 #2
0
def test_snyk_create_pv_nodes_fail(mock_bg, mock_gp):
    """Test SnykCVEPut.create_pv_nodes() fail."""
    mock_gp.return_value = 'query'
    mock_bg.return_value = (False, {'error': 'something happened'})

    cve = SnykCVEPut(valid_snyk_put_input)
    nodes, successfull_create, aff = cve.create_pv_nodes()
    assert len(nodes) == 0
    assert successfull_create is False
コード例 #3
0
def test_snyk_create_pv_nodes(mock_bg, mock_gp):
    """Test SnykCVEPut.create_pv_nodes()."""
    mock_gp.return_value = "query pkg.property('latest_version', '1.2.3');"
    mock_bg.return_value = True, {}

    cve = SnykCVEPut(valid_snyk_put_input)
    nodes, successfull_create, aff = cve.create_pv_nodes()
    assert len(nodes) == 3
    assert successfull_create is True
    assert ('pypi', 'numpy', '1.1') in nodes
    assert ('pypi', 'numpy', '1.2') in nodes
    assert ('pypi', 'numpy', '1.3') in nodes
    assert aff['numpy']['ecosystem'] == "pypi"
    assert aff['numpy']['latest_version'] == "1.2.3"