You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think teodoras current approach of mocking open (in #1593) is pretty good: just implementing this in the relevant tests is probably fine (so no test utilities needed).
The question is, which tests should test metadata file opens:
What I imagined while writing the issue is potentially having a class that tests all weird cases of loading cached metadata. This would mean at least:
Step 1: make a successful update of valid metadata which stores it in cache (by calling preferably Updater.get_targetinfo or in some special case Updater.refresh)
Step 2: Create a new updater and perform a second update while the metadata is already stored in cache (metadata dir)
Step 3:
test that a valid timestamp is loaded from cache (and is used to verify the new timestamp)
test that if a valid snapshot is loaded from cache a new snapshot is not downloaded
test that if a valid targets is loaded from cache a new targets is not downloaded
Step 4:
test that an expired timestamp when loaded from cache is not stored as final but is used to verify the new timestamp
test that an expired snapshot when loaded from cache is not stored as final but is used to verify the new downloaded snapshot
test that an expired targets when loaded from cache is not stored as final but is used to verify the new downloaded targets
expired targets is invalid and should be neither loaded, stored nor used.
Step 5:
test that an invalid (incorrectly signed) timestamp when loaded from cache IS NOT used to verify the new timestamp
test that an invalid (incorrectly signed) snapshot when loaded from cache IS NOT used to verify the new timestamp
test that an invalid (incorrectly signed) targets when loaded from cache IS NOT used to verify the new targets
Step 3 can be based on the test in #1593 but I think a separate test case will be more clear. I haven't thought out well steps 4 and 5 but I'm open for suggestions. Maybe start with 3 and re-scope the issue accordingly?
Forgot to mention that root as a special case should be already covered in test_updater_top_level_update.py but probably this claim should be confirmed.
oh yeah, validating that local metadata is actually used when downloaded metadata is verified (the second case in the issue description) is tricky. I think doing just the first case in the issue description (validate that correct files are read from disk the correct number of times) is a good first step -- so that would be roughly steps 1-3 in your comment. I would argue it's mostly just augmenting the test function you wrote, but a new one is fine too
What I imagined while writing the issue is potentially having a class that tests all weird cases of loading cached metadata. This would mean at least:
Step 1: make a successful update of valid metadata which stores it in cache (by calling preferably Updater.get_targetinfo or in some special case Updater.refresh)
@sechkova why it's preferable to call Updater.get_targetinfo instead of directly calling refresh?
Maybe I am missing some context here.
@sechkova why it's preferable to call Updater.get_targetinfo instead of directly calling refresh?
Maybe I am missing some context here.
Seems like I've had in mind refreshing both top-levels and delegated roles metadata when writing this. Updater.get_targetinfo calls refresh internally.
Activity
ivanayov commentedon Nov 24, 2021
Can I take this, please?
jku commentedon Nov 24, 2021
I think teodoras current approach of mocking open (in #1593) is pretty good: just implementing this in the relevant tests is probably fine (so no test utilities needed).
The question is, which tests should test metadata file opens:
Maybe this single test is enough? @sechkova opinions?
sechkova commentedon Nov 24, 2021
What I imagined while writing the issue is potentially having a class that tests all weird cases of loading cached metadata. This would mean at least:
Step 1: make a successful update of valid metadata which stores it in cache (by calling preferably Updater.get_targetinfo or in some special case Updater.refresh)
Step 2: Create a new updater and perform a second update while the metadata is already stored in cache (metadata dir)
Step 3:
Step 4:
test that an expired targets when loaded from cache is not stored as final but is used to verify the new downloaded targetsStep 5:
to verify the new targetsStep 3 can be based on the test in #1593 but I think a separate test case will be more clear. I haven't thought out well steps 4 and 5 but I'm open for suggestions. Maybe start with 3 and re-scope the issue accordingly?
sechkova commentedon Nov 24, 2021
Forgot to mention that root as a special case should be already covered in
test_updater_top_level_update.pybut probably this claim should be confirmed.jku commentedon Nov 24, 2021
oh yeah, validating that local metadata is actually used when downloaded metadata is verified (the second case in the issue description) is tricky. I think doing just the first case in the issue description (validate that correct files are read from disk the correct number of times) is a good first step -- so that would be roughly steps 1-3 in your comment. I would argue it's mostly just augmenting the test function you wrote, but a new one is fine too
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test expired metadata from cache
MVrachev commentedon Dec 6, 2021
@sechkova why it's preferable to call
Updater.get_targetinfoinstead of directly callingrefresh?Maybe I am missing some context here.
sechkova commentedon Dec 7, 2021
Seems like I've had in mind refreshing both top-levels and delegated roles metadata when writing this. Updater.get_targetinfo calls refresh internally.
7 remaining items
Test expired metadata from cache
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test expired metadata from cache
Test loading of cached metadata in ngclient
Test loading of cached metadata in ngclient
Test expired metadata from cache
Test expired metadata from cache
Test expired metadata from cache
Test expired metadata from cache
Dimitrovr/test permissions (#14)