Skip to content

Commit 79e0bc6

Browse files
committed
update fixtures and clarify test comments.
1 parent 0f5fe0e commit 79e0bc6

File tree

504 files changed

+47
-21861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

504 files changed

+47
-21861
lines changed

client/client_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ func (s *ClientSuite) TestUpdateRoots(c *C) {
422422
expectedError error
423423
expectedVersions map[string]int
424424
}{
425+
<<<<<<< HEAD
425426
<<<<<<< HEAD
426427
// Succeeds when there is no root update.
427428
{"testdata/Published1Time", nil, map[string]int{"root": 1, "timestamp": 1, "snapshot": 1, "targets": 1}},
@@ -482,6 +483,52 @@ func (s *ClientSuite) TestUpdateRoots(c *C) {
482483
=======
483484
{"testdata/PublishedTwiceInvalidOldRootSignatureWithRotatedKeys_root", errors.New("tuf: signature verification failed"), map[string]int{}},
484485
>>>>>>> 0d6db4e (Avoid mocking IsExpired in the tests. Instead update test fixtured to have concerete timestamps (either expired or long exiring one))
486+
=======
487+
// Test cases for Client's root update:
488+
// (1) Succeeds when there is no root update.
489+
// (2) Succeeds updating root to version 2 when the client's initial root version is 1.
490+
// (3) Succeeds updating root to version 2 when the client's initial root version is 1 and version 1 is expired.
491+
// (4) Succeeds updating root to version 3 when the client's initial root version is 1 and root versions 1 and 2 are expired.
492+
// (5) Succeeds updating root to version 3 when the client's initial root version is 2.
493+
// (6) Fails updating root to version 3 when the client's initial root version is 1 and root versions 3 is expired.
494+
// (7) Fails updating root to version 2 when the root the old root's signature is invalid (nth root didn't sign off n+1).
495+
// (8) Fails updating root to version 2 when the root the new root's signature is invalid (n+1th root didn't sign off n+1).
496+
// (9) Fails updating root to 2.root.json when the value of the version field inside it is 1 (rollback attack prevention).
497+
// (10) Fails updating root to 2.root.json when the value of the version field inside it is 3 (rollforward attack prevention).
498+
499+
// Test (1)
500+
{"testdata/Published1Time", nil, map[string]int{"root": 1, "timestamp": 1, "snapshot": 1, "targets": 1}},
501+
// Test (2)
502+
{"testdata/Published2Times_keyrotated", nil, map[string]int{"root": 2, "timestamp": 1, "snapshot": 1, "targets": 1}},
503+
// Test (3)
504+
{"testdata/Published2Times_keyrotated_initialrootexpired", nil, map[string]int{"root": 2, "timestamp": 1, "snapshot": 1, "targets": 1}},
505+
// Test (4)
506+
{"testdata/Published3Times_keyrotated_initialrootsexpired", nil, map[string]int{"root": 3, "timestamp": 1, "snapshot": 1, "targets": 1}},
507+
// Test(5)
508+
{"testdata/Published3Times_keyrotated_initialrootsexpired_clientversionis2", nil, map[string]int{"root": 3, "timestamp": 1, "snapshot": 1, "targets": 1}},
509+
// Test (6)
510+
{"testdata/Published3Times_keyrotated_latestrootexpired", ErrDecodeFailed{File: "root.json", Err: verify.ErrExpired{}}, map[string]int{"root": 2, "timestamp": 1, "snapshot": 1, "targets": 1}},
511+
// Test (7)
512+
{"testdata/Published2Times_keyrotated_invalidOldRootSignature", errors.New("tuf: signature verification failed"), map[string]int{}},
513+
// Test (8)
514+
{"testdata/Published2Times_keyrotated_invalidNewRootSignature", errors.New("tuf: signature verification failed"), map[string]int{}},
515+
// Test (9)
516+
{"testdata/Published1Time_backwardRootVersion", verify.ErrWrongVersion(verify.ErrWrongVersion{Given: 1, Expected: 2}), map[string]int{}},
517+
// Test (10)
518+
{"testdata/Published3Times_keyrotated_forwardRootVersion", verify.ErrWrongVersion(verify.ErrWrongVersion{Given: 3, Expected: 2}), map[string]int{}},
519+
520+
// Test cases for checking the version of non-root metadata after their key is being rotated:
521+
// (i) snapshot role key rotation increase the snapshot and timestamp.
522+
// (ii) targets role key rotation increase the snapshot, timestamp, and targets.
523+
// (iii) timestamp role key rotation increase the timestamp.
524+
525+
// Test (i)
526+
{"testdata/Published2Times_snapshot_keyrotated", nil, map[string]int{"root": 2, "timestamp": 2, "snapshot": 2, "targets": 1}},
527+
// Test (ii)
528+
{"testdata/Published2Times_targets_keyrotated", nil, map[string]int{"root": 2, "timestamp": 2, "snapshot": 2, "targets": 2}},
529+
// Test (iii)
530+
{"testdata/Published2Times_timestamp_keyrotated", nil, map[string]int{"root": 2, "timestamp": 2, "snapshot": 1, "targets": 1}},
531+
>>>>>>> 68a35d0 (update fixtures and clarify test comments.)
485532
}
486533

487534
for _, test := range tests {

client/testdata/Published5TimesWithRotatedKeys_root/client/metadata/current/1.root.json

Lines changed: 0 additions & 87 deletions
This file was deleted.

client/testdata/Published5TimesWithRotatedKeys_root/client/metadata/current/1.snapshot.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

client/testdata/Published5TimesWithRotatedKeys_root/client/metadata/current/1.targets.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

client/testdata/Published5TimesWithRotatedKeys_root/client/metadata/current/1.timestamp.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

client/testdata/Published5TimesWithRotatedKeys_root/client/metadata/current/2.root.json

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)