-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
$ pytest -vs test_search.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.12.3, pytest-9.0.2, pluggy-1.6.0 -- /home/mark/myvenv/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/nvdlib
collected 16 items
test_search.py::test_get_cve FAILED
test_search.py::test_get_cve_v2 FAILED
test_search.py::test_search_cve FAILED
test_search.py::test_search_cve_v2 FAILED
test_search.py::test_paginated_search_cve FAILED
test_search.py::test_paginated_search_cve_v2 FAILED
test_search.py::test_search_cve_returns_a_cve FAILED
test_search.py::test_search_cve_returns_a_cve_v2 FAILED
test_search.py::test_cve_cwe FAILED
test_search.py::test_search_cve_handles_get_returning_none PASSED
test_search.py::test_search_cve_v2_handles_get_with_generator_returning_none PASSED
test_search.py::test_search_cve_handles_get_returning_none_with_parameters PASSED
test_search.py::test_search_cve_v2_handles_mixed_none_and_valid_batches PASSED
test_search.py::test_search_cve_handles_get_returning_empty_dict PASSED
test_search.py::test_search_cve_handles_get_returning_false PASSED
test_search.py::test_search_cve_v2_handles_empty_generator PASSED
================================================================================= FAILURES =================================================================================
_______________________________________________________________________________ test_get_cve _______________________________________________________________________________
@responses.activate
def test_get_cve():
"""Test a nvdlib.searchCVE() call for a single CVE."""
> mock_nvd()
test_search.py:45:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
_____________________________________________________________________________ test_get_cve_v2 ______________________________________________________________________________
@responses.activate
def test_get_cve_v2():
"""Test a nvdlib.searchCVE_V2() call for a single CVE."""
> mock_nvd()
test_search.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
_____________________________________________________________________________ test_search_cve ______________________________________________________________________________
@responses.activate
def test_search_cve():
"""Test a simple nvdlib.searchCVE() call."""
> mock_nvd()
test_search.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
____________________________________________________________________________ test_search_cve_v2 ____________________________________________________________________________
def test_search_cve_v2():
"""Test a simple nvdlib.searchCVE_V2() call."""
# Mock the generator function since it uses dynamic parameters
> with open("tests/data/simple_search.json") as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/simple_search.json'
test_search.py:91: FileNotFoundError
________________________________________________________________________ test_paginated_search_cve _________________________________________________________________________
@ responses.activate
def test_paginated_search_cve():
"""Test a nvdlib.searchCVE() call with paginated results."""
> mock_nvd()
test_search.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
_______________________________________________________________________ test_paginated_search_cve_v2 _______________________________________________________________________
def test_paginated_search_cve_v2():
"""Test a nvdlib.searchCVE_V2() call with paginated results."""
# Mock the generator function since it uses dynamic parameters
> with open("tests/data/search_page_1.json") as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/search_page_1.json'
test_search.py:118: FileNotFoundError
______________________________________________________________________ test_search_cve_returns_a_cve _______________________________________________________________________
@ responses.activate
def test_search_cve_returns_a_cve():
"""Test a nvdlib.searchCVE() result is actually a CVE object"""
> mock_nvd()
test_search.py:133:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
_____________________________________________________________________ test_search_cve_returns_a_cve_v2 _____________________________________________________________________
def test_search_cve_returns_a_cve_v2():
"""Test a nvdlib.searchCVE_V2() result is actually a CVE object"""
# Mock the generator function since it uses dynamic parameters
> with open("tests/data/search_page_1.json") as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/search_page_1.json'
test_search.py:143: FileNotFoundError
_______________________________________________________________________________ test_cve_cwe _______________________________________________________________________________
@responses.activate
def test_cve_cwe():
"""Test that `cwe` was correctly created from `weaknesses`."""
> mock_nvd()
test_search.py:158:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bad_json = False
def mock_nvd(bad_json=False):
for url, response_file in [
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2021-45357.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-26855",
"tests/data/CVE-2021-26855.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-45357",
"tests/data/CVE-2022-24646.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2017-7542",
"tests/data/CVE-2017-7542.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-10T12:00:00",
"tests/data/simple_search.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_page_1.json",
),
(
"https://services.nvd.nist.gov/rest/json/cves/2.0?pubStartDate=2022-02-10T00:00:00&pubEndDate=2022-02-11T00:00:00",
"tests/data/search_full_page.json",
),
]:
> with open(response_file) as _f:
^^^^^^^^^^^^^^^^^^^
E FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
test_search.py:38: FileNotFoundError
========================================================================= short test summary info ==========================================================================
FAILED test_search.py::test_get_cve - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
FAILED test_search.py::test_get_cve_v2 - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
FAILED test_search.py::test_search_cve - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
FAILED test_search.py::test_search_cve_v2 - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/simple_search.json'
FAILED test_search.py::test_paginated_search_cve - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
FAILED test_search.py::test_paginated_search_cve_v2 - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/search_page_1.json'
FAILED test_search.py::test_search_cve_returns_a_cve - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
FAILED test_search.py::test_search_cve_returns_a_cve_v2 - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/search_page_1.json'
FAILED test_search.py::test_cve_cwe - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/CVE-2021-45357.json'
======================================================================= 9 failed, 7 passed in 0.12s ========================================================================
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels