fix: replace CryptoAlgorithms audit wrap instanceof chain with Java 21

switch

Replace the AUDIT_MODE == WRAP dispatch in
zeroecho.core.CryptoAlgorithms#create(...) with an exhaustive Java 21
pattern switch over the sealed CryptoContext hierarchy. This removes the
repeated instanceof chain, keeps unchecked casts localized in a single
internal helper, and closes the missing audit-wrap gap for
AgreementContext.

Add focused JUnit 5 coverage for audited proxy wrapping using
Mockito-based tests for representative context interfaces and wrapper
lifecycle delegation.

Closes #20
Time-Spent: 45m
This commit is contained in:
2026-04-05 22:17:14 +02:00
parent a4b9eeffe1
commit 14fbf31989
3 changed files with 156 additions and 22 deletions

View File

@@ -5,9 +5,20 @@ plugins {
group='org.egothor'
configurations {
mockitoAgent
}
dependencies {
api 'org.bouncycastle:bcpkix-jdk18on'
implementation 'org.egothor:conflux'
testImplementation "org.mockito:mockito-core:5.23.0"
testImplementation "org.mockito:mockito-inline:5.2.0"
mockitoAgent("org.mockito:mockito-core:5.23.0") {
transitive = false
}
}
@@ -53,3 +64,8 @@ javadoc {
options.links("https://www.egothor.org/javadoc/conflux")
// options.overview = file("src/main/javadoc/overview.html")
}
test {
useJUnitPlatform()
jvmArgs("-javaagent:${configurations.mockitoAgent.singleFile}")
}