test:enhance certificate chain builder and mock build#2615
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the certificate chain builder by returning a dedicated CertificateChainFixture and introduces a new mock_extensions module with a MockBuilder tool for improved test configuration. Key changes include the refactoring of CertificateChainBuilder::build to return a CertificateChainFixture (with added utility methods) and updates to tests and related modules to work with this new fixture.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mithril-common/src/test_utils/mod.rs | Added module export for mock_extensions and updated re-export of certificate chain items. |
| mithril-common/src/test_utils/mock_extensions.rs | New module providing a MockBuilder tool for easier and isolated mock configuration. |
| mithril-common/src/test_utils/certificate_chain_builder.rs | Refactored CertificateChainBuilder to return CertificateChainFixture; added utility methods. |
| mithril-common/src/crypto_helper/tests_setup.rs | Updated setup_certificate_chain to match the new CertificateChainFixture signature. |
| mithril-common/src/certificate_chain/certificate_verifier.rs | Updated tests to use the new CertificateChainFixture instead of tuple-based certificate chain. |
| mithril-client/src/certificate_client/verify.rs | Adjusted tests to use the fixture’s fields (certificates_chained and genesis_verifier). |
| mithril-aggregator/* | Updated repository, record, and query modules to work with CertificateChainFixture accordingly. |
Alenar
force-pushed
the
djo/test/enhance-chain_builder-and-mock_build
branch
2 times, most recently
from
June 27, 2025 16:22
1c3eced to
22b4bd4
Compare
dlachaume
approved these changes
Jun 30, 2025
jpraynaud
approved these changes
Jun 30, 2025
Instead of a tuple, this allow to extend the returned value with usefull fstructeatures for test (i.e. immediate access to genesis certificate). Also update the builder so generated certificates have different, deterministic, signed entity type.
…rtificateChainFixture`
Alenar
force-pushed
the
djo/test/enhance-chain_builder-and-mock_build
branch
from
June 30, 2025 16:00
22b4bd4 to
89a6781
Compare
* mithril-aggregator from `0.7.68` to `0.7.69` * mithril-client from `0.12.17` to `0.12.18` * mithril-common from `0.6.2` to `0.6.3`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Content
This PR enhance the certificate chain builder and add propose a tooling to create mock in a standardized way.
Changes
CertificateChainBuilder:.build()return aCertificateChainFixturethat's contains the same data as the previous returned tuple (the chain ordered from latest to genesis and the genesis verifier)CertificateChainFixtureallow to attach utility methods related to the produced certificates:genesis_certificate(&self): shortcut to get the generated genesischain_reversed: return a copy of the generated chain reversedcertificate_path_to_genesis: return a list with the given certificate hash and all it's previous certificates, useful when testing certificate chain validationCertificateChainFixtureimplement:DerefandDerefMutto[Certificate]allowing to avoid directly operating on the storedcertificates_chainedlist most of the time.impl<C: From<Certificate>> From<CertificateChainFixture> for Vec<C>to allow conversion of the full list to a list of another type that can be converted fromCertificate(mostly useful in db layer when handlingCertificateRecord)mock_extensionsmodule with aMockBuildertool that allow to create mock instance with a block dedicated to the mock configuration, avoiding pollution of the test code, exemple:Pre-submit checklist
Issue(s)
Relates to #2534