@@ -444,33 +444,33 @@ def test_build_merkle_tree(self):
444
444
test_nodes = {}
445
445
test_nodes ['file1' ] = tuf .formats .make_metadata_fileinfo (5 , None , None )
446
446
447
- root_1 , leaves = repo_lib .build_merkle_tree (test_nodes )
448
- repo_lib .write_merkle_paths (root_1 , leaves , storage_backend ,
447
+ root_1 , leaves = repo_lib ._build_merkle_tree (test_nodes )
448
+ repo_lib ._write_merkle_paths (root_1 , leaves , storage_backend ,
449
449
temporary_directory )
450
450
451
451
file_path = os .path .join (temporary_directory , 'file1-snapshot.json' )
452
452
self .assertTrue (os .path .exists (file_path ))
453
453
454
454
test_nodes ['file2' ] = tuf .formats .make_metadata_fileinfo (5 , None , None )
455
- root_2 , leaves = repo_lib .build_merkle_tree (test_nodes )
455
+ root_2 , leaves = repo_lib ._build_merkle_tree (test_nodes )
456
456
457
- self .assertEqual (root_2 .left (). hash () , root_1 .hash () )
457
+ self .assertEqual (root_2 .left . digest , root_1 .digest )
458
458
459
459
test_nodes ['file3' ] = tuf .formats .make_metadata_fileinfo (5 , None , None )
460
460
test_nodes ['file4' ] = tuf .formats .make_metadata_fileinfo (5 , None , None )
461
461
462
- root_3 , leaves = repo_lib .build_merkle_tree (test_nodes )
462
+ root_3 , leaves = repo_lib ._build_merkle_tree (test_nodes )
463
463
464
- self .assertEqual (root_3 .left (). hash () , root_2 .hash () )
464
+ self .assertEqual (root_3 .left . digest , root_2 .digest )
465
465
466
466
test_nodes ['file5' ] = tuf .formats .make_metadata_fileinfo (5 , None , None )
467
467
468
- root_4 , leaves = repo_lib .build_merkle_tree (test_nodes )
468
+ root_4 , leaves = repo_lib ._build_merkle_tree (test_nodes )
469
469
470
- repo_lib .write_merkle_paths (root_4 , leaves , storage_backend ,
470
+ repo_lib ._write_merkle_paths (root_4 , leaves , storage_backend ,
471
471
temporary_directory )
472
472
473
- self .assertEqual (root_4 .left (). hash () , root_3 .hash () )
473
+ self .assertEqual (root_4 .left . digest , root_3 .digest )
474
474
475
475
# Ensure that the paths are written to the directory
476
476
file_path = os .path .join (temporary_directory , 'file1-snapshot.json' )
@@ -484,7 +484,7 @@ def test_build_merkle_tree(self):
484
484
test_nodes ['role1' ] = tuf .formats .make_metadata_fileinfo (1 , None , None )
485
485
test_nodes ['role2' ] = tuf .formats .make_metadata_fileinfo (1 , None , None )
486
486
487
- root , leaves = repo_lib .build_merkle_tree (test_nodes )
487
+ root , leaves = repo_lib ._build_merkle_tree (test_nodes )
488
488
489
489
490
490
@@ -534,7 +534,7 @@ def test_generate_snapshot_metadata(self):
534
534
repo_lib .generate_snapshot_metadata (metadata_directory , version ,
535
535
expiration_date ,
536
536
storage_backend ,
537
- consistent_snapshot = False )
537
+ consistent_snapshot = False )[ 0 ]
538
538
self .assertTrue (tuf .formats .SNAPSHOT_SCHEMA .matches (snapshot_metadata ))
539
539
540
540
@@ -563,7 +563,7 @@ def test_generate_snapshot_metadata_with_length(self):
563
563
expiration_date ,
564
564
storage_backend ,
565
565
consistent_snapshot = False ,
566
- use_length = True )
566
+ use_length = True )[ 0 ]
567
567
self .assertTrue (tuf .formats .SNAPSHOT_SCHEMA .matches (snapshot_metadata ))
568
568
569
569
metadata_files_info_dict = snapshot_metadata ['meta' ]
@@ -578,7 +578,8 @@ def test_generate_snapshot_metadata_with_length(self):
578
578
# In the repository, the file "role_file.xml" have been added to make
579
579
# sure that non-json files aren't loaded. This file should be filtered.
580
580
if stripped_filename .endswith ('.json' ):
581
- if stripped_filename not in TOP_LEVEL_METADATA_FILES :
581
+ if stripped_filename not in TOP_LEVEL_METADATA_FILES and \
582
+ not stripped_filename .endswith ('-snapshot.json' ):
582
583
# Check that length is not calculated but hashes is
583
584
self .assertIn ('length' , metadata_files_info_dict [stripped_filename ])
584
585
self .assertNotIn ('hashes' , metadata_files_info_dict [stripped_filename ])
@@ -594,7 +595,7 @@ def test_generate_snapshot_metadata_with_hashes(self):
594
595
expiration_date ,
595
596
storage_backend ,
596
597
consistent_snapshot = False ,
597
- use_hashes = True )
598
+ use_hashes = True )[ 0 ]
598
599
self .assertTrue (tuf .formats .SNAPSHOT_SCHEMA .matches (snapshot_metadata ))
599
600
600
601
metadata_files_info_dict = snapshot_metadata ['meta' ]
@@ -609,7 +610,8 @@ def test_generate_snapshot_metadata_with_hashes(self):
609
610
# In the repository, the file "role_file.xml" have been added to make
610
611
# sure that non-json files aren't loaded. This file should be filtered.
611
612
if stripped_filename .endswith ('.json' ):
612
- if stripped_filename not in TOP_LEVEL_METADATA_FILES :
613
+ if stripped_filename not in TOP_LEVEL_METADATA_FILES and \
614
+ not stripped_filename .endswith ('-snapshot.json' ):
613
615
# Check that hashes is not calculated but length is
614
616
self .assertNotIn ('length' , metadata_files_info_dict [stripped_filename ])
615
617
self .assertIn ('hashes' , metadata_files_info_dict [stripped_filename ])
@@ -626,7 +628,7 @@ def test_generate_snapshot_metadata_with_hashes_and_length(self):
626
628
storage_backend ,
627
629
consistent_snapshot = False ,
628
630
use_length = True ,
629
- use_hashes = True )
631
+ use_hashes = True )[ 0 ]
630
632
self .assertTrue (tuf .formats .SNAPSHOT_SCHEMA .matches (snapshot_metadata ))
631
633
632
634
metadata_files_info_dict = snapshot_metadata ['meta' ]
@@ -641,7 +643,8 @@ def test_generate_snapshot_metadata_with_hashes_and_length(self):
641
643
# In the repository, the file "role_file.xml" have been added to make
642
644
# sure that non-json files aren't loaded. This file should be filtered.
643
645
if stripped_filename .endswith ('.json' ):
644
- if stripped_filename not in TOP_LEVEL_METADATA_FILES :
646
+ if stripped_filename not in TOP_LEVEL_METADATA_FILES and \
647
+ not stripped_filename .endswith ('-snapshot.json' ):
645
648
# Check that both length and hashes are not are not calculated
646
649
self .assertIn ('length' , metadata_files_info_dict [stripped_filename ])
647
650
self .assertIn ('hashes' , metadata_files_info_dict [stripped_filename ])
0 commit comments