Reintroduce and fix test for Pkcs12StoreBuilder #595
Closed
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.
Describe your changes
I found the methods DoTestSupportedTypes and basicStoreTest in Pkcs12StoreTest, which performed some IMHO useful tests on Pkcs12Store, but weren't actually part of any test (and therefore never called).
I added some code to actually call them. For this, I refactored some code into the new method CreateTestCertificateAndKey from another test to accomplish the goal with the minimum of changes possible. The other tests do not behave different now, except for one constructor call which explicitly passes a parameter that was previously not passed and the default.
I had to explicitly add the Pkcs9LocalKeyId to the X509CertificateEntry, otherwise the test failed, because the PrivateKeyEntry will always have a Pkcs9LocalKeyId added by the Pkcs12Store. I found this confusing, but maybe I am missing some detail. I consider this issue outside the scope of this change, though.
Sorry for the whitespace/tab changes that might make this change more difficult to read... the code file had a mix of tab and space indentations to begin with, so there was no consistent way to make these modifications. I could make the file use a single type of indentation in a separate patch, if you want, to make this easier to read. I only need to know whether you prefer the tabs or how many spaces?
How has this been tested?
I ran the modified tests and they pass.
Checklist before requesting a review
See also Contributing Guidelines.