Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: regression test for 0 cve pdf report #4371

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
CVE-bin-tool CLI tests
"""
import importlib
import logging
import os
import re
Expand Down Expand Up @@ -730,6 +731,42 @@ def test_console_output_depending_reportlab_existence(self, caplog):
not_installed_msg,
) not in caplog.record_tuples

@pytest.mark.skipif(
not importlib.util.find_spec("reportlab"),
reason="Reportlab needed for pdf test",
)
def test_0_cve_pdf_report(self, caplog):
"""Tests to make sure --report behaves as expected when 0 cves are found.
We expect a short pdf file saying 0 cves were found."""

with tempfile.TemporaryDirectory() as emptytemp:
# Set a filename for report in tempdir, make sure it doesn't exist.
report_0 = Path(self.tempdir) / "0_cve_report.pdf"
if report_0.exists():
report_0.unlink()

# Call cve-bin-tool to scan empty dir and product pdf report.
cbt_command = [
"cve-bin-tool",
"--offline",
"--format",
"pdf",
"-o",
str(report_0),
"--report",
str(emptytemp),
]
main(cbt_command)

# Make sure the report was created and has something in it.
# Testing what's in the report would increase test execution time
# so we're leaving that out for now
assert report_0.exists()
assert report_0.stat().st_size > 0

# get rid of generated file
report_0.unlink()

yamls = [
[
"cve-bin-tool",
Expand Down
Loading