diff options
| author | J08nY | 2023-04-11 17:47:37 +0200 |
|---|---|---|
| committer | J08nY | 2023-04-11 17:47:37 +0200 |
| commit | e8093d33870f96be17ca251726a295ae927d8dac (patch) | |
| tree | 7e6362c8bdfdc2a1550883d3f4f5e94a8df3e74d | |
| parent | 98c4f06c6ced66beab6f0c576542acbf15212416 (diff) | |
| download | sec-certs-e8093d33870f96be17ca251726a295ae927d8dac.tar.gz sec-certs-e8093d33870f96be17ca251726a295ae927d8dac.tar.zst sec-certs-e8093d33870f96be17ca251726a295ae927d8dac.zip | |
Add tests for IUT/MIP matching.
| -rw-r--r-- | tests/fips/test_fips_iut.py | 26 | ||||
| -rw-r--r-- | tests/fips/test_fips_mip.py | 27 |
2 files changed, 47 insertions, 6 deletions
diff --git a/tests/fips/test_fips_iut.py b/tests/fips/test_fips_iut.py index 1dca086c..81fc751e 100644 --- a/tests/fips/test_fips_iut.py +++ b/tests/fips/test_fips_iut.py @@ -1,10 +1,12 @@ +import datetime from pathlib import Path import pytest -import tests.data.fips.iut -from sec_certs.dataset import IUTDataset -from sec_certs.sample import IUTSnapshot +import tests.data.fips.iut +from sec_certs.dataset import FIPSDataset, IUTDataset +from sec_certs.model import FIPSProcessMatcher +from sec_certs.sample import IUTEntry, IUTSnapshot @pytest.fixture(scope="module") @@ -37,3 +39,21 @@ def test_iut_snapshot_from_web(): def test_iut_snapshot_from_web_latest(): assert IUTSnapshot.from_web_latest() + + +def test_iut_matching(processed_dataset: FIPSDataset): + entry = IUTEntry( + module_name="Red Hat Enterprise Linux 7.1 OpenSSL Module", + vendor_name="Red Hat(R), Inc.", + standard="FIPS 140-2", + iut_date=datetime.date(2014, 1, 1), + ) + matcher = FIPSProcessMatcher(entry) + scores = [matcher.match(cert) for cert in processed_dataset] + assert len(list(filter(lambda x: x > 90, scores))) == 1 + + +def test_iut_snapshot_match(processed_dataset: FIPSDataset, data_dump_path: Path): + snapshot = IUTSnapshot.from_dump(data_dump_path) + matches = FIPSProcessMatcher.match_snapshot(snapshot, processed_dataset) + assert matches diff --git a/tests/fips/test_fips_mip.py b/tests/fips/test_fips_mip.py index 4918a4c6..16b3b500 100644 --- a/tests/fips/test_fips_mip.py +++ b/tests/fips/test_fips_mip.py @@ -1,10 +1,12 @@ +import datetime from pathlib import Path import pytest -import tests.data.fips.mip -from sec_certs.dataset import MIPDataset -from sec_certs.sample import MIPSnapshot +import tests.data.fips.mip +from sec_certs.dataset import FIPSDataset, MIPDataset +from sec_certs.model import FIPSProcessMatcher +from sec_certs.sample import MIPEntry, MIPSnapshot, MIPStatus @pytest.fixture(scope="module") @@ -37,3 +39,22 @@ def test_from_web(): def test_from_web_latest(): assert MIPSnapshot.from_web_latest() + + +def test_mip_matching(processed_dataset: FIPSDataset): + entry = MIPEntry( + module_name="Red Hat Enterprise Linux 7.1 OpenSSL Module", + vendor_name="Red Hat(R), Inc.", + standard="FIPS 140-2", + status=MIPStatus.IN_REVIEW, + status_since=datetime.date(2014, 1, 1), + ) + matcher = FIPSProcessMatcher(entry) + scores = [matcher.match(cert) for cert in processed_dataset] + assert len(list(filter(lambda x: x > 90, scores))) == 1 + + +def test_mip_snapshot_match(processed_dataset: FIPSDataset, data_dump_path: Path): + snapshot = MIPSnapshot.from_dump(data_dump_path) + matches = FIPSProcessMatcher.match_snapshot(snapshot, processed_dataset) + assert matches |
