diff --git a/qpc/clicommand.py b/qpc/clicommand.py index 7b3d4405..a631a1f9 100644 --- a/qpc/clicommand.py +++ b/qpc/clicommand.py @@ -25,8 +25,7 @@ def __init__( # noqa: PLR0913 self.req_headers = None self.response = None - # If you add or change API, you must update these versions - # this includes self.min_server_version + # Minimum server version required by the CLI self.min_server_version = QPC_MIN_SERVER_VERSION def _validate_args(self): diff --git a/qpc/report/deployments.py b/qpc/report/deployments.py index caf7c6eb..fcc8a432 100644 --- a/qpc/report/deployments.py +++ b/qpc/report/deployments.py @@ -74,7 +74,6 @@ def __init__(self, subparsers): help=_(messages.REPORT_PATH_HELP), ) self.report_id = None - self.min_server_version = "0.9.2" def _validate_args(self): # noqa: PLR0912 CliCommand._validate_args(self) diff --git a/qpc/report/details.py b/qpc/report/details.py index e21464e3..e9db7a6e 100644 --- a/qpc/report/details.py +++ b/qpc/report/details.py @@ -74,7 +74,6 @@ def __init__(self, subparsers): help=_(messages.REPORT_PATH_HELP), ) self.report_id = None - self.min_server_version = "0.9.2" def _validate_args(self): # noqa: PLR0912 CliCommand._validate_args(self) diff --git a/qpc/report/download.py b/qpc/report/download.py index 5497d804..bd338d43 100644 --- a/qpc/report/download.py +++ b/qpc/report/download.py @@ -54,7 +54,6 @@ def __init__(self, subparsers): help=_(messages.DOWNLOAD_PATH_HELP), required=True, ) - self.min_server_version = "0.9.2" self.report_id = None def _validate_args(self): diff --git a/qpc/report/insights.py b/qpc/report/insights.py index f5a1dabf..f7a03261 100644 --- a/qpc/report/insights.py +++ b/qpc/report/insights.py @@ -55,8 +55,6 @@ def __init__(self, subparsers): metavar="PATH", help=_(messages.REPORT_PATH_HELP), ) - # Don't change this when you upgrade versions - self.min_server_version = "0.9.0" self.report_id = None def _insights_report_available(self, sources): diff --git a/qpc/tests/report/test_report_deployments.py b/qpc/tests/report/test_report_deployments.py index 196c2374..76f8eabd 100644 --- a/qpc/tests/report/test_report_deployments.py +++ b/qpc/tests/report/test_report_deployments.py @@ -14,12 +14,11 @@ from qpc import messages from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_URI from qpc.report.deployments import ReportDeploymentsCommand from qpc.scan import SCAN_JOB_URI from qpc.tests.utilities import redirect_stdout -from qpc.utils import create_tar_buffer, get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, create_tar_buffer, get_server_location @pytest.fixture @@ -66,7 +65,7 @@ def test_deployments_report_as_json(self, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -95,7 +94,7 @@ def test_deployments_report_as_json_report_id(self, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -126,7 +125,7 @@ def test_deployments_report_as_csv(self, faker, caplog, csv_file_path): get_report_url, status_code=200, content=get_report_response.encode("utf-8"), - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -241,7 +240,7 @@ def test_deployments_file_fails_to_write(self, file, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -342,7 +341,7 @@ def test_deployments_report_id_not_exist(self, caplog, json_file_path): get_report_url, status_code=400, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -372,7 +371,7 @@ def test_deployments_report_error_scan_job(self, caplog, json_file_path): get_report_url, status_code=400, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -411,7 +410,7 @@ def test_deployments_old_version(self, caplog, json_file_path): with pytest.raises(SystemExit): self.command.main(args) err_msg = messages.SERVER_TOO_OLD_FOR_CLI % { - "min_version": "0.9.2", + "min_version": QPC_MIN_SERVER_VERSION, "current_version": "0.0.45", } assert err_msg in caplog.text @@ -429,7 +428,7 @@ def test_deployments_report_as_json_no_output_file(caplog, capsys, requests_mock report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", diff --git a/qpc/tests/report/test_report_details.py b/qpc/tests/report/test_report_details.py index 6f0916d4..247135da 100644 --- a/qpc/tests/report/test_report_details.py +++ b/qpc/tests/report/test_report_details.py @@ -14,12 +14,11 @@ from qpc import messages from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_URI from qpc.report.details import ReportDetailsCommand from qpc.scan import SCAN_JOB_URI from qpc.tests.utilities import redirect_stdout -from qpc.utils import create_tar_buffer, get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, create_tar_buffer, get_server_location @pytest.fixture @@ -66,7 +65,7 @@ def test_detail_report_as_json(self, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -95,7 +94,7 @@ def test_detail_report_as_json_report_id(self, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -130,7 +129,7 @@ def test_detail_report_as_csv(self, caplog, csv_file_path): get_report_url, status_code=200, json=get_report_csv_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -231,7 +230,7 @@ def test_details_file_fails_to_write(self, file, caplog, json_file_path): get_report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -330,7 +329,7 @@ def test_details_report_id_not_exist(self, caplog, json_file_path): get_report_url, status_code=400, json=get_report_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -360,7 +359,7 @@ def test_detail_report_error_scan_job(self, caplog, json_file_path): get_report_url, status_code=400, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -399,7 +398,7 @@ def test_details_old_version(self, caplog, csv_file_path): with pytest.raises(SystemExit): self.command.main(args) err_msg = messages.SERVER_TOO_OLD_FOR_CLI % { - "min_version": "0.9.2", + "min_version": QPC_MIN_SERVER_VERSION, "current_version": "0.0.45", } assert err_msg in caplog.text @@ -417,7 +416,7 @@ def test_details_report_as_json_no_output_file(caplog, capsys, requests_mock): report_url, status_code=200, content=buffer_content, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", diff --git a/qpc/tests/report/test_report_download.py b/qpc/tests/report/test_report_download.py index f057eaae..634af91b 100644 --- a/qpc/tests/report/test_report_download.py +++ b/qpc/tests/report/test_report_download.py @@ -11,11 +11,10 @@ from qpc import messages from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_URI from qpc.report.download import ReportDownloadCommand from qpc.scan import SCAN_JOB_URI -from qpc.utils import create_tar_buffer, get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, create_tar_buffer, get_server_location @pytest.fixture @@ -56,7 +55,7 @@ def test_download_scan_job(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -79,7 +78,7 @@ def test_download_report_id(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -184,7 +183,7 @@ def test_file_fails_to_write(self, file, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -206,7 +205,7 @@ def test_download_report_id_not_exist(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=400, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, json=get_report_json_data, ) @@ -234,7 +233,7 @@ def test_download_from_server_with_old_version(self, caplog, fake_tarball): with pytest.raises(SystemExit): self.command.main(args) err_msg = messages.SERVER_TOO_OLD_FOR_CLI % { - "min_version": "0.9.2", + "min_version": QPC_MIN_SERVER_VERSION, "current_version": "0.0.45", } assert err_msg in caplog.text @@ -249,7 +248,7 @@ def test_download_bad_file_extension(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) diff --git a/qpc/tests/report/test_report_insights.py b/qpc/tests/report/test_report_insights.py index ef090ca0..6fdadc0a 100644 --- a/qpc/tests/report/test_report_insights.py +++ b/qpc/tests/report/test_report_insights.py @@ -14,12 +14,11 @@ from qpc import messages from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_URI from qpc.report.insights import ReportInsightsCommand from qpc.scan import SCAN_JOB_URI from qpc.tests.utilities import redirect_stdout -from qpc.utils import create_tar_buffer, get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, create_tar_buffer, get_server_location @pytest.fixture @@ -67,7 +66,7 @@ def test_insights_report_as_json(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -92,13 +91,13 @@ def test_insights_report_as_json_report_id(self, caplog, fake_tarball): mocker.get( scanjob_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, json=scanjob_data, ) mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -173,13 +172,13 @@ def test_insights_file_fails_to_write(self, file, caplog, fake_tarball): mocker.get( scanjob_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, json=scanjob_data, ) mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -223,7 +222,7 @@ def test_insights_tar_path(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=200, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -245,12 +244,12 @@ def test_insights_report_id_not_exist(self, caplog, fake_tarball): mocker.get( scanjob_report_url, status_code=404, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) mocker.get( get_report_url, status_code=400, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -274,7 +273,7 @@ def test_insights_report_error_scan_job(self, caplog, fake_tarball): mocker.get( get_report_url, status_code=400, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, content=buffer_content, ) @@ -295,7 +294,7 @@ def test_insights_report_as_json_no_output_file(caplog, capsys, requests_mock): scanjob_report_url, status_code=200, json=scanjob_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) report_url = get_server_location() + REPORT_URI + "1/insights/" report_json_data = { @@ -309,7 +308,7 @@ def test_insights_report_as_json_no_output_file(caplog, capsys, requests_mock): report_url, status_code=200, json=expected_json, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", @@ -370,7 +369,7 @@ def test_insights_not_available_report_id(caplog, capsys, requests_mock): scanjob_report_url, status_code=200, json=scanjob_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", @@ -414,7 +413,7 @@ def test_insights_mix_sources_scan_job(caplog, capsys, requests_mock): report_url, status_code=200, json=expected_json, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", @@ -447,7 +446,7 @@ def test_insights_mix_sources_report_id(caplog, capsys, requests_mock): scanjob_report_url, status_code=200, json=scanjob_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) report_url = get_server_location() + REPORT_URI + "1/insights/" report_json_data = { @@ -461,7 +460,7 @@ def test_insights_mix_sources_report_id(caplog, capsys, requests_mock): report_url, status_code=200, json=expected_json, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", diff --git a/qpc/tests/report/test_report_list.py b/qpc/tests/report/test_report_list.py index 0c9623ad..106d2343 100644 --- a/qpc/tests/report/test_report_list.py +++ b/qpc/tests/report/test_report_list.py @@ -9,11 +9,10 @@ import requests_mock from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_V2_URI from qpc.report.list import ReportListCommand from qpc.tests.utilities import redirect_stdout -from qpc.utils import get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, get_server_location @pytest.fixture @@ -58,7 +57,7 @@ def test_list_report_as_json_to_stdout(self, get_report_url, report_json_data): get_report_url, status_code=200, json=report_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace() @@ -79,7 +78,7 @@ def test_list_report_as_json( get_report_url, status_code=200, json=report_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", diff --git a/qpc/tests/report/test_report_show.py b/qpc/tests/report/test_report_show.py index 92efbb8c..2bc87d92 100644 --- a/qpc/tests/report/test_report_show.py +++ b/qpc/tests/report/test_report_show.py @@ -11,11 +11,10 @@ from qpc import messages from qpc.cli import CLI -from qpc.release import VERSION from qpc.report import REPORT_V2_URI from qpc.report.show import ReportShowCommand from qpc.tests.utilities import redirect_stdout -from qpc.utils import get_server_location +from qpc.utils import QPC_MIN_SERVER_VERSION, get_server_location @pytest.fixture @@ -51,7 +50,7 @@ def test_show_report_as_json_to_stdout(self, get_report1_url, report1_json_data) get_report1_url, status_code=200, json=report1_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -71,7 +70,7 @@ def test_show_report_id_not_exist(self, caplog, get_report1_url, report1_json_da get_report1_url, status_code=400, json=report1_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) args = Namespace( @@ -93,7 +92,7 @@ def test_show_report_as_json( get_report1_url, status_code=200, json=report1_json_data, - headers={"X-Server-Version": VERSION}, + headers={"X-Server-Version": QPC_MIN_SERVER_VERSION}, ) sys.argv = [ "/bin/qpc", diff --git a/qpc/utils.py b/qpc/utils.py index 32d720c9..238894b8 100644 --- a/qpc/utils.py +++ b/qpc/utils.py @@ -54,7 +54,7 @@ LOG_LEVEL_INFO = 0 -QPC_MIN_SERVER_VERSION = "2.4.0" +QPC_MIN_SERVER_VERSION = "2.5.0" logging.captureWarnings(True) logger = logging.getLogger(__name__)