def test_cve_response(self): """Test if CVE API response is correct for correct JSON.""" response = self.cve.process_list(api_version=1, data=CVE_JSON) assert schemas.cves_schema.validate(response) assert CVE_NAME in response["cve_list"] assert tools.match(CORRECT_RESPONSE, response["cve_list"][CVE_NAME]) is True
def test_errata_response(self): """Test errata API response.""" response = self.errata_api.process_list(api_version="v1", data=ERRATA_JSON) assert schemas.errata_schema.validate(response) assert ERRATA_NAME in response["errata_list"] assert tools.match(CORRECT_RESPONSE, response["errata_list"][ERRATA_NAME]) is True
def test_non_existing_errata(self): """Test errata API repsonse for non-existent errata.""" response = self.errata_api.process_list(api_version="v1", data=ERRATA_JSON_NON_EXIST) assert tools.match(EMPTY_RESPONSE, response) is True
def test_empty_errata_list(self): """Test errata API with empty 'errata_list'.""" response = self.errata_api.process_list(api_version="v1", data=ERRATA_JSON_EMPTY_LIST) assert tools.match(EMPTY_RESPONSE, response) is True
def test_without_modified(self): """Test errata without modified date. In response {updated: None}.""" errata = ERRATA_JSON_MODIFIED.copy() errata["errata_list"] = ["RHSA-W/O:MODIFIED"] response = self.errata_api.process_list(api_version="v1", data=errata) assert tools.match(EMPTY_RESPONSE, response) is True
def test_modified_in_future(self): """Test CVE API with 'modified_since' property in future.""" errata = ERRATA_JSON_MODIFIED.copy() errata["modified_since"] = MODIFIED_IN_FUTURE response = self.errata_api.process_list(api_version="v1", data=errata) assert tools.match(EMPTY_RESPONSE, response) is True
def test_published_in_future(self): """Test CVE API with 'published_since' property with date in future""" cve = CVE_JSON_PUBLISHED.copy() cve["published_since"] = DATE_IN_FUTURE response = self.cve.process_list(api_version=1, data=cve) assert tools.match(EMPTY_RESPONSE, response) is True
def test_without_published(self): """Test CVEs without published date. In response {public_date: None}.""" cve = CVE_JSON_PUBLISHED.copy() cve["cve_list"] = ["CVE-W/O-PUBLISHED"] response = self.cve.process_list(api_version=1, data=cve) assert tools.match(EMPTY_RESPONSE, response) is True
def test_without_modified(self): """Test CVEs without modified date. In response {modified_date: None}.""" cve = CVE_JSON_MODIFIED.copy() cve["cve_list"] = ["CVE-W/O-MODIFIED"] response = self.cve.process_list(api_version=1, data=cve) assert tools.match(EMPTY_RESPONSE, response) is True
def test_modified_in_future(self): """Test CVE API with 'modified_since' property in future.""" cve = CVE_JSON_MODIFIED.copy() cve["modified_since"] = DATE_IN_FUTURE response = self.cve.process_list(api_version=1, data=cve) assert tools.match(EMPTY_RESPONSE, response) is True
def test_non_existing_pkg(self): """Test pkg api with non existing package.""" response = self.pkg_api.process_list(1, PKG_JSON_NON_EXIST) assert tools.match(NON_EXIST_RESPONSE, response) is True
def test_empty_pkg_list(self): """Test pkg api with empty package_list.""" response = self.pkg_api.process_list(1, PKG_JSON_EMPTY_LIST) assert tools.match(EMPTY_RESPONSE, response) is True
def test_modified_since(self): """Test repos API with 'modified_since' property.""" response = self.repo.process_list(api_version=1, data=REPO_JSON_MODIFIED_SINCE) assert tools.match(EMPTY_RESPONSE, response) is True