Skip to content

Commit eb21840

Browse files
committed
Updated the test cases for jni 0.21
1 parent b26f0bc commit eb21840

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

2.08 KB
Binary file not shown.

rustls-platform-verifier/src/tests/ffi.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod android {
2929
const SUCCESS_MARKER: &str = "success";
3030

3131
fn run_android_test<'a>(
32-
env: &'a JNIEnv,
32+
env: &'a mut JNIEnv,
3333
cx: JObject,
3434
suite_name: &'static str,
3535
test_cases: &'static [fn()],
@@ -86,53 +86,53 @@ mod android {
8686

8787
#[export_name = "Java_org_rustls_platformverifier_CertificateVerifierTests_mockTests"]
8888
pub extern "C" fn rustls_platform_verifier_mock_test_suite(
89-
env: JNIEnv,
89+
mut env: JNIEnv,
9090
_class: JClass,
9191
cx: JObject,
9292
) -> jstring {
9393
log::info!("running mock test suite...");
9494

9595
run_android_test(
96-
&env,
96+
&mut env,
9797
cx,
9898
"mock tests",
9999
tests::verification_mock::ALL_TEST_CASES,
100100
)
101-
.into_inner()
101+
.into_raw()
102102
}
103103

104104
#[export_name = "Java_org_rustls_platformverifier_CertificateVerifierTests_verifyMockRootUsage"]
105105
pub extern "C" fn rustls_platform_verifier_verify_mock_root_usage(
106-
env: JNIEnv,
106+
mut env: JNIEnv,
107107
_class: JClass,
108108
cx: JObject,
109109
) -> jstring {
110110
log::info!("verifying mock roots are not used by default...");
111111

112112
run_android_test(
113-
&env,
113+
&mut env,
114114
cx,
115115
"mock root verification",
116116
&[tests::verification_mock::verification_without_mock_root],
117117
)
118-
.into_inner()
118+
.into_raw()
119119
}
120120

121121
#[export_name = "Java_org_rustls_platformverifier_CertificateVerifierTests_realWorldTests"]
122122
pub extern "C" fn rustls_platform_verifier_real_world_test_suite(
123-
env: JNIEnv,
123+
mut env: JNIEnv,
124124
_class: JClass,
125125
cx: JObject,
126126
) -> jstring {
127127
log::info!("running real world suite...");
128128

129129
run_android_test(
130-
&env,
130+
&mut env,
131131
cx,
132132
"real world",
133133
tests::verification_real_world::ALL_TEST_CASES,
134134
)
135-
.into_inner()
135+
.into_raw()
136136
}
137137
}
138138

rustls-platform-verifier/src/verification/android.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ impl Default for Verifier {
5858
#[cfg(any(test, feature = "ffi-testing"))]
5959
impl Drop for Verifier {
6060
fn drop(&mut self) {
61-
with_context::<_, ()>(|cx| {
62-
let env = cx.env();
61+
with_context::<_, ()>(|cx, env| {
6362
env.call_static_method(CERT_VERIFIER_CLASS.get(cx)?, "clearMockRoots", "()V", &[])?
6463
.v()?;
6564
Ok(())
@@ -160,7 +159,7 @@ impl Verifier {
160159
CERT_VERIFIER_CLASS.get(cx)?,
161160
"addMockRoot",
162161
"([B)V",
163-
&[JValue::from(mock_root)],
162+
&[JValue::from(&mock_root)],
164163
)?
165164
.v()
166165
.expect("failed to add test root")

0 commit comments

Comments
 (0)