aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authoradamjanovsky2022-06-22 20:40:57 +0200
committerGitHub2022-06-22 20:40:57 +0200
commit81d5a3e023ac30b63fb42f99588166d5052b5492 (patch)
tree22669e4f0cc8db87856f8327c2f9bd4316324bdc /tests
parent52ead1014c58a26509e5992089d735b199293384 (diff)
parenteca01edd4cc9f62ddae9bc400cea9a9f0ac51cd9 (diff)
downloadsec-certs-0.1.0.tar.gz
sec-certs-0.1.0.tar.zst
sec-certs-0.1.0.zip
Merge pull request #238 from crocs-muni:fix/document-hashes-constructors0.1.0
fix CommonCriteriaCert.InternalState constructor
Diffstat (limited to 'tests')
-rw-r--r--tests/data/test_cc_oop/fictional_cert.json6
-rw-r--r--tests/data/test_cc_oop/toy_dataset.json12
-rw-r--r--tests/test_cc_oop.py28
3 files changed, 26 insertions, 20 deletions
diff --git a/tests/data/test_cc_oop/fictional_cert.json b/tests/data/test_cc_oop/fictional_cert.json
index 441ae7d2..7d74759c 100644
--- a/tests/data/test_cc_oop/fictional_cert.json
+++ b/tests/data/test_cc_oop/fictional_cert.json
@@ -42,7 +42,11 @@
"report_convert_ok": true,
"st_extract_ok": true,
"report_extract_ok": true,
- "errors": []
+ "errors": [],
+ "st_pdf_hash": null,
+ "report_pdf_hash": null,
+ "st_txt_hash": null,
+ "report_txt_hash": null
},
"pdf_data": {
"_type": "PdfData",
diff --git a/tests/data/test_cc_oop/toy_dataset.json b/tests/data/test_cc_oop/toy_dataset.json
index 740ddf1b..91669453 100644
--- a/tests/data/test_cc_oop/toy_dataset.json
+++ b/tests/data/test_cc_oop/toy_dataset.json
@@ -49,7 +49,11 @@
"report_convert_ok": true,
"st_extract_ok": true,
"report_extract_ok": true,
- "errors": []
+ "errors": [],
+ "st_pdf_hash": null,
+ "report_pdf_hash": null,
+ "st_txt_hash": null,
+ "report_txt_hash": null
},
"pdf_data": {
"_type": "PdfData",
@@ -126,7 +130,11 @@
"report_convert_ok": true,
"st_extract_ok": true,
"report_extract_ok": true,
- "errors": []
+ "errors": [],
+ "st_pdf_hash": null,
+ "report_pdf_hash": null,
+ "st_txt_hash": null,
+ "report_txt_hash": null
},
"pdf_data": {
"_type": "PdfData",
diff --git a/tests/test_cc_oop.py b/tests/test_cc_oop.py
index d2809fbe..5e4d86dc 100644
--- a/tests/test_cc_oop.py
+++ b/tests/test_cc_oop.py
@@ -9,7 +9,6 @@ from typing import ClassVar
from unittest import TestCase
import sec_certs.constants as constants
-import sec_certs.helpers as helpers
import tests.data.test_cc_oop
from sec_certs.config.configuration import config
from sec_certs.dataset import CCDataset
@@ -129,23 +128,18 @@ class TestCommonCriteriaOOP(TestCase):
dset.download_all_pdfs()
dset.convert_all_pdfs()
- actual_report_pdf_hashes = {
- key: helpers.get_sha256_filepath(val.state.report_pdf_path) for key, val in dset.certs.items()
- }
- actual_target_pdf_hashes = {
- key: helpers.get_sha256_filepath(val.state.st_pdf_path) for key, val in dset.certs.items()
- }
+ for cert in dset:
+ self.assertEqual(
+ cert.state.report_pdf_hash,
+ self.template_report_pdf_hashes[cert.dgst],
+ f"Hash of PDF certification report for CommonCriteriaCert with digest {cert.dgst} deviates from template.",
+ )
- self.assertEqual(
- actual_report_pdf_hashes,
- self.template_report_pdf_hashes,
- "Hashes of downloaded pdfs (sample report) do not the template",
- )
- self.assertEqual(
- actual_target_pdf_hashes,
- self.template_target_pdf_hashes,
- "Hashes of downloaded pdfs (security target) do not match the template",
- )
+ self.assertEqual(
+ cert.state.st_pdf_hash,
+ self.template_target_pdf_hashes[cert.dgst],
+ f"Hash of PDF security target for CommonCriteriaCert with digest {cert.dgst} deviates from template.",
+ )
self.assertTrue(dset["309ac2fd7f2dcf17"].state.report_txt_path.exists())
self.assertTrue(dset["309ac2fd7f2dcf17"].state.st_txt_path.exists())