Tests | Refactor and move CoreCryptoTests to UnitTests #3709
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.
Description
This picks up from a comment yesterday in #3660 from @mdaigle, moving CoreCryptoTests into the unit tests project.
The CEK-based tests (
TestRsaCryptoWithNativeBaseline) had already removed the use of reflection, so I've ported those across. There were also AEAD-based tests which still used reflection, so I removed those too.The old version of the tests contained the
TCECryptoNativeBaseline.txtandTCECryptoNativeBaselineRsa.txtfiles, with various parsing logic to convert the hexadecimal strings into byte arrays. I've turned these byte arrays into embedded resources because several of them are about 4KB in size and I wanted to load them in a consistent way. I'm not completely happy with the approach though, it leads to a lot of small files. I did consider putting them in one or more JSON files (so we'd eliminate the use of the custom parsing logic without adding so many files - perhaps one file for each of the 32 AEAD-based test cases and the 3 CEK-based test cases) but it seemed like an unnecessary layer of indirection. I'm happy to go with whichever option you'd prefer.It's also worth noting that this lifts a hardcoded certificate out of
TCECryptoNativeBaselineRsa.txt. This was always there, but it's technically a hardcoded credential and might be noticed as such. We use this to decrypt a CEK and verify its contents against the SQL Server native code, so it needs to remain in situ.Issues
Follows up #3660 comment.
Testing
New tests run successfully.