-
Notifications
You must be signed in to change notification settings - Fork 45
test:enhance certificate chain builder and mock build #2615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
1c3eced
to
22b4bd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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`
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`
Content
This PR enhance the certificate chain builder and add propose a tooling to create mock in a standardized way.
Changes
CertificateChainBuilder
:.build()
return aCertificateChainFixture
that's contains the same data as the previous returned tuple (the chain ordered from latest to genesis and the genesis verifier)CertificateChainFixture
allow 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 validationCertificateChainFixture
implement:Deref
andDerefMut
to[Certificate]
allowing to avoid directly operating on the storedcertificates_chained
list 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_extensions
module with aMockBuilder
tool 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