Skip to content

Commit ceabac0

Browse files
committed
fix: Update the tests
1 parent 8653d67 commit ceabac0

File tree

1 file changed

+52
-89
lines changed

1 file changed

+52
-89
lines changed

tests/test_unit_tests.py

Lines changed: 52 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ def test_stream_read_get_validation_state(self):
149149
reader = Reader("image/jpeg", file)
150150
validation_state = reader.get_validation_state()
151151
self.assertIsNotNone(validation_state)
152-
# Needs trust configuration to be set up to validate as Trusted, otherwise manifest is Invalid
153-
self.assertEqual(validation_state, "Invalid")
152+
self.assertEqual(validation_state, "Valid")
154153

155154
def test_stream_read_get_validation_state_with_trust_config(self):
156155
# Run in a separate thread to isolate thread-local settings
@@ -1012,10 +1011,7 @@ def test_streams_sign_with_es256_alg_v1_manifest(self):
10121011
reader = Reader("image/jpeg", output)
10131012
json_data = reader.json()
10141013
self.assertIn("Python Test", json_data)
1015-
# Needs trust configuration to be set up to validate as Trusted,
1016-
# or validation_status on read reports `signing certificate untrusted`
1017-
# which makes the manifest validation_state become Invalid.
1018-
self.assertIn("Invalid", json_data)
1014+
self.assertIn("Valid", json_data)
10191015

10201016
# Write buffer to file
10211017
# output.seek(0)
@@ -1040,10 +1036,7 @@ def test_streams_sign_with_es256_alg_v1_manifest_to_existing_empty_file(self):
10401036
reader = Reader("image/jpeg", target)
10411037
json_data = reader.json()
10421038
self.assertIn("Python Test", json_data)
1043-
# Needs trust configuration to be set up to validate as Trusted,
1044-
# or validation_status on read reports `signing certificate untrusted`
1045-
# which makes the manifest validation_state become Invalid.
1046-
self.assertIn("Invalid", json_data)
1039+
self.assertIn("Valid", json_data)
10471040

10481041
finally:
10491042
# Clean up...
@@ -1069,10 +1062,7 @@ def test_streams_sign_with_es256_alg_v1_manifest_to_new_dest_file(self):
10691062
reader = Reader("image/jpeg", target)
10701063
json_data = reader.json()
10711064
self.assertIn("Python Test", json_data)
1072-
# Needs trust configuration to be set up to validate as Trusted,
1073-
# or validation_status on read reports `signing certificate untrusted`
1074-
# which makes the manifest validation_state become Invalid.
1075-
self.assertIn("Invalid", json_data)
1065+
self.assertIn("Valid", json_data)
10761066

10771067
finally:
10781068
# Clean up...
@@ -1095,9 +1085,8 @@ def test_streams_sign_with_es256_alg(self):
10951085
json_data = reader.json()
10961086
self.assertIn("Python Test", json_data)
10971087
# Needs trust configuration to be set up to validate as Trusted,
1098-
# or validation_status on read reports `signing certificate untrusted`
1099-
# which makes the manifest validation_state become Invalid.
1100-
self.assertIn("Invalid", json_data)
1088+
# or validation_status on read reports `signing certificate untrusted`.
1089+
self.assertIn("Valid", json_data)
11011090
output.close()
11021091

11031092
def test_streams_sign_with_es256_alg_2(self):
@@ -1109,10 +1098,7 @@ def test_streams_sign_with_es256_alg_2(self):
11091098
reader = Reader("image/jpeg", output)
11101099
json_data = reader.json()
11111100
self.assertIn("Python Test", json_data)
1112-
# Needs trust configuration to be set up to validate as Trusted,
1113-
# or validation_status on read reports `signing certificate untrusted`
1114-
# which makes the manifest validation_state become Invalid.
1115-
self.assertIn("Invalid", json_data)
1101+
self.assertIn("Valid", json_data)
11161102
output.close()
11171103

11181104
def test_streams_sign_with_es256_alg_create_intent(self):
@@ -1162,9 +1148,8 @@ def test_streams_sign_with_es256_alg_create_intent(self):
11621148
self.assertEqual(len(created_actions), 1)
11631149

11641150
# Needs trust configuration to be set up to validate as Trusted,
1165-
# or validation_status on read reports `signing certificate untrusted`
1166-
# which makes the manifest validation_state become Invalid.
1167-
self.assertEqual(manifest_data["validation_state"], "Invalid")
1151+
# or validation_status on read reports `signing certificate untrusted`.
1152+
self.assertEqual(manifest_data["validation_state"], "Valid")
11681153
output.close()
11691154

11701155
def test_streams_sign_with_es256_alg_create_intent_2(self):
@@ -1242,9 +1227,8 @@ def test_streams_sign_with_es256_alg_create_intent_2(self):
12421227
self.assertIn("digitalCreation", created_action["digitalSourceType"])
12431228

12441229
# Needs trust configuration to be set up to validate as Trusted,
1245-
# or validation_status on read reports `signing certificate untrusted`
1246-
# which makes the manifest validation_state become Invalid.
1247-
self.assertEqual(manifest_data["validation_state"], "Invalid")
1230+
# or validation_status on read reports `signing certificate untrusted`.
1231+
self.assertEqual(manifest_data["validation_state"], "Valid")
12481232
output.close()
12491233

12501234
def test_streams_sign_with_es256_alg_edit_intent(self):
@@ -1319,9 +1303,8 @@ def test_streams_sign_with_es256_alg_edit_intent(self):
13191303
self.assertIn("hash", ingredient)
13201304

13211305
# Needs trust configuration to be set up to validate as Trusted,
1322-
# or validation_status on read reports `signing certificate untrusted`
1323-
# which makes the manifest validation_state become Invalid.
1324-
self.assertEqual(manifest_data["validation_state"], "Invalid")
1306+
# or validation_status on read reports `signing certificate untrusted`.
1307+
self.assertEqual(manifest_data["validation_state"], "Valid")
13251308
output.close()
13261309

13271310
def test_streams_sign_with_es256_alg_with_trust_config(self):
@@ -1394,9 +1377,8 @@ def test_sign_with_ed25519_alg(self):
13941377
json_data = reader.json()
13951378
self.assertIn("Python Test", json_data)
13961379
# Needs trust configuration to be set up to validate as Trusted,
1397-
# or validation_status on read reports `signing certificate untrusted`
1398-
# which makes the manifest validation_state become Invalid.
1399-
self.assertIn("Invalid", json_data)
1380+
# or validation_status on read reports `signing certificate untrusted`.
1381+
self.assertIn("Valid", json_data)
14001382
output.close()
14011383

14021384
def test_sign_with_ed25519_alg_with_trust_config(self):
@@ -1482,9 +1464,8 @@ def test_sign_with_ed25519_alg_2(self):
14821464
json_data = reader.json()
14831465
self.assertIn("Python Test", json_data)
14841466
# Needs trust configuration to be set up to validate as Trusted,
1485-
# or validation_status on read reports `signing certificate untrusted`
1486-
# which makes the manifest validation_state become Invalid.
1487-
self.assertIn("Invalid", json_data)
1467+
# or validation_status on read reports `signing certificate untrusted`.
1468+
self.assertIn("Valid", json_data)
14881469
output.close()
14891470

14901471
def test_sign_with_ps256_alg(self):
@@ -1510,9 +1491,8 @@ def test_sign_with_ps256_alg(self):
15101491
json_data = reader.json()
15111492
self.assertIn("Python Test", json_data)
15121493
# Needs trust configuration to be set up to validate as Trusted,
1513-
# or validation_status on read reports `signing certificate untrusted`
1514-
# which makes the manifest validation_state become Invalid.
1515-
self.assertIn("Invalid", json_data)
1494+
# or validation_status on read reports `signing certificate untrusted`.
1495+
self.assertIn("Valid", json_data)
15161496
output.close()
15171497

15181498
def test_sign_with_ps256_alg_2(self):
@@ -1614,9 +1594,8 @@ def test_archive_sign(self):
16141594
json_data = reader.json()
16151595
self.assertIn("Python Test", json_data)
16161596
# Needs trust configuration to be set up to validate as Trusted,
1617-
# or validation_status on read reports `signing certificate untrusted`
1618-
# which makes the manifest validation_state become Invalid.
1619-
self.assertIn("Invalid", json_data)
1597+
# or validation_status on read reports `signing certificate untrusted`.
1598+
self.assertIn("Valid", json_data)
16201599
archive.close()
16211600
output.close()
16221601

@@ -1687,9 +1666,8 @@ def test_archive_sign_with_added_ingredient(self):
16871666
json_data = reader.json()
16881667
self.assertIn("Python Test", json_data)
16891668
# Needs trust configuration to be set up to validate as Trusted,
1690-
# or validation_status on read reports `signing certificate untrusted`
1691-
# which makes the manifest validation_state become Invalid.
1692-
self.assertIn("Invalid", json_data)
1669+
# or validation_status on read reports `signing certificate untrusted`.
1670+
self.assertIn("Valid", json_data)
16931671
archive.close()
16941672
output.close()
16951673

@@ -1897,9 +1875,8 @@ def test_sign_all_files(self):
18971875
json_data = reader.json()
18981876
self.assertIn("Python Test", json_data)
18991877
# Needs trust configuration to be set up to validate as Trusted,
1900-
# or validation_status on read reports `signing certificate untrusted`
1901-
# which makes the manifest validation_state become Invalid.
1902-
self.assertIn("Invalid", json_data)
1878+
# or validation_status on read reports `signing certificate untrusted`.
1879+
self.assertIn("Valid", json_data)
19031880
reader.close()
19041881
output.close()
19051882
except Error.NotSupported:
@@ -1966,8 +1943,7 @@ def test_sign_all_files_V2(self):
19661943
self.assertIn("Python Test", json_data)
19671944
# Needs trust configuration to be set up to validate as Trusted,
19681945
# or validation_status on read reports `signing certificate untrusted`
1969-
# which makes the manifest validation_state become Invalid.
1970-
self.assertIn("Invalid", json_data)
1946+
self.assertIn("Valid", json_data)
19711947
reader.close()
19721948
output.close()
19731949
except Error.NotSupported:
@@ -2600,9 +2576,8 @@ def test_sign_single(self):
26002576
json_data = reader.json()
26012577
self.assertIn("Python Test", json_data)
26022578
# Needs trust configuration to be set up to validate as Trusted,
2603-
# or validation_status on read reports `signing certificate untrusted` (which makes the manifest Invalid)
2604-
# which makes the manifest validation_state become Invalid.
2605-
self.assertIn("Invalid", json_data)
2579+
# or validation_status on read reports `signing certificate untrusted`.
2580+
self.assertIn("Valid", json_data)
26062581
output.close()
26072582

26082583
def test_sign_mp4_video_file_single(self):
@@ -2618,9 +2593,8 @@ def test_sign_mp4_video_file_single(self):
26182593
json_data = reader.json()
26192594
self.assertIn("Python Test", json_data)
26202595
# Needs trust configuration to be set up to validate as Trusted,
2621-
# or validation_status on read reports `signing certificate untrusted`
2622-
# which makes the manifest validation_state become Invalid.
2623-
self.assertIn("Invalid", json_data)
2596+
# or validation_status on read reports `signing certificate untrusted`.
2597+
self.assertIn("Valid", json_data)
26242598
output.close()
26252599

26262600
def test_sign_mov_video_file_single(self):
@@ -2636,9 +2610,8 @@ def test_sign_mov_video_file_single(self):
26362610
json_data = reader.json()
26372611
self.assertIn("Python Test", json_data)
26382612
# Needs trust configuration to be set up to validate as Trusted,
2639-
# or validation_status on read reports `signing certificate untrusted`
2640-
# which makes the manifest validation_state become Invalid.
2641-
self.assertIn("Invalid", json_data)
2613+
# or validation_status on read reports `signing certificate untrusted`.
2614+
self.assertIn("Valid", json_data)
26422615
output.close()
26432616

26442617
def test_sign_file_video(self):
@@ -2664,9 +2637,8 @@ def test_sign_file_video(self):
26642637
json_data = reader.json()
26652638
self.assertIn("Python Test", json_data)
26662639
# Needs trust configuration to be set up to validate as Trusted,
2667-
# or validation_status on read reports `signing certificate untrusted`
2668-
# which makes the manifest validation_state become Invalid.
2669-
self.assertIn("Invalid", json_data)
2640+
# or validation_status on read reports `signing certificate untrusted`.
2641+
self.assertIn("Valid", json_data)
26702642

26712643
finally:
26722644
# Clean up the temporary directory
@@ -2719,9 +2691,8 @@ def test_builder_sign_file_callback_signer_from_callback(self):
27192691
json_data = reader.json()
27202692
self.assertIn("Python Test", json_data)
27212693
# Needs trust configuration to be set up to validate as Trusted,
2722-
# or validation_status on read reports `signing certificate untrusted`
2723-
# which makes the manifest validation_state become Invalid.
2724-
self.assertIn("Invalid", json_data)
2694+
# or validation_status on read reports `signing certificate untrusted`.
2695+
self.assertIn("Valid", json_data)
27252696

27262697
# Parse the JSON and verify the signature algorithm
27272698
manifest_data = json.loads(json_data)
@@ -2773,9 +2744,8 @@ def test_builder_sign_file_callback_signer_from_callback_V2(self):
27732744
json_data = reader.json()
27742745
self.assertIn("Python Test", json_data)
27752746
# Needs trust configuration to be set up to validate as Trusted,
2776-
# or validation_status on read reports `signing certificate untrusted`
2777-
# which makes the manifest validation_state become Invalid.
2778-
self.assertIn("Invalid", json_data)
2747+
# or validation_status on read reports `signing certificate untrusted`.
2748+
self.assertIn("Valid", json_data)
27792749

27802750
# Parse the JSON and verify the signature algorithm
27812751
manifest_data = json.loads(json_data)
@@ -2829,9 +2799,8 @@ def ed25519_callback(data: bytes) -> bytes:
28292799
json_data = reader.json()
28302800
self.assertIn("Python Test", json_data)
28312801
# Needs trust configuration to be set up to validate as Trusted,
2832-
# or validation_status on read reports `signing certificate untrusted`
2833-
# which makes the manifest validation_state become Invalid.
2834-
self.assertIn("Invalid", json_data)
2802+
# or validation_status on read reports `signing certificate untrusted`.
2803+
self.assertIn("Valid", json_data)
28352804
reader.close()
28362805
output.close()
28372806

@@ -2856,9 +2825,8 @@ def test_signing_manifest_v2(self):
28562825
# Basic verification of the manifest
28572826
self.assertIn("Python Test Image V2", json_data)
28582827
# Needs trust configuration to be set up to validate as Trusted,
2859-
# or validation_status on read reports `signing certificate untrusted`
2860-
# which makes the manifest validation_state become Invalid.
2861-
self.assertIn("Invalid", json_data)
2828+
# or validation_status on read reports `signing certificate untrusted`.
2829+
self.assertIn("Valid", json_data)
28622830

28632831
output.close()
28642832

@@ -2892,9 +2860,8 @@ def test_sign_file_mp4_video(self):
28922860
json_data = reader.json()
28932861
self.assertIn("Python Test", json_data)
28942862
# Needs trust configuration to be set up to validate as Trusted,
2895-
# or validation_status on read reports `signing certificate untrusted`
2896-
# which makes the manifest validation_state become Invalid.
2897-
self.assertIn("Invalid", json_data)
2863+
# or validation_status on read reports `signing certificate untrusted`.
2864+
self.assertIn("Valid", json_data)
28982865

28992866
finally:
29002867
# Clean up the temporary directory
@@ -2923,18 +2890,16 @@ def test_sign_file_mov_video(self):
29232890
json_data = reader.json()
29242891
self.assertIn("Python Test", json_data)
29252892
# Needs trust configuration to be set up to validate as Trusted,
2926-
# or validation_status on read reports `signing certificate untrusted`
2927-
# which makes the manifest validation_state become Invalid.
2928-
self.assertIn("Invalid", json_data)
2893+
# or validation_status on read reports `signing certificate untrusted`.
2894+
self.assertIn("Valid", json_data)
29292895

29302896
# Verify also signed file using manifest bytes
29312897
with Reader("mov", output_path, manifest_bytes) as reader:
29322898
json_data = reader.json()
29332899
self.assertIn("Python Test", json_data)
29342900
# Needs trust configuration to be set up to validate as Trusted,
2935-
# or validation_status on read reports `signing certificate untrusted`
2936-
# which makes the manifest validation_state become Invalid.
2937-
self.assertIn("Invalid", json_data)
2901+
# or validation_status on read reports `signing certificate untrusted`.
2902+
self.assertIn("Valid", json_data)
29382903

29392904
finally:
29402905
# Clean up the temporary directory
@@ -2963,18 +2928,16 @@ def test_sign_file_mov_video_V2(self):
29632928
json_data = reader.json()
29642929
self.assertIn("Python Test", json_data)
29652930
# Needs trust configuration to be set up to validate as Trusted,
2966-
# or validation_status on read reports `signing certificate untrusted`
2967-
# which makes the manifest validation_state become Invalid.
2968-
self.assertIn("Invalid", json_data)
2931+
# or validation_status on read reports `signing certificate untrusted`.
2932+
self.assertIn("Valid", json_data)
29692933

29702934
# Verify also signed file using manifest bytes
29712935
with Reader("mov", output_path, manifest_bytes) as reader:
29722936
json_data = reader.json()
29732937
self.assertIn("Python Test", json_data)
29742938
# Needs trust configuration to be set up to validate as Trusted,
2975-
# or validation_status on read reports `signing certificate untrusted`
2976-
# which makes the manifest validation_state become Invalid.
2977-
self.assertIn("Invalid", json_data)
2939+
# or validation_status on read reports `signing certificate untrusted`.
2940+
self.assertIn("Valid", json_data)
29782941

29792942
finally:
29802943
# Clean up the temporary directory

0 commit comments

Comments
 (0)