Skip to content

Commit 0d8cc04

Browse files
committed
Fix more nss initialization issues in tests
1 parent 662baa2 commit 0d8cc04

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

components/autofill/src/sync/credit_card/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fn test_last_4() {
255255

256256
#[test]
257257
fn test_to_from_payload() {
258+
nss::ensure_initialized();
258259
let key = crate::encryption::create_autofill_key().unwrap();
259260
let cc_number = "1234567812345678";
260261
let cc_number_enc =

components/support/rc_crypto/src/contentsignature.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ pub fn verify(
157157
#[cfg(test)]
158158
mod test {
159159
use super::*;
160-
use nss::ensure_initialized;
161160

162161
const ROOT_HASH: &str = "3C:01:44:6A:BE:90:36:CE:A9:A0:9A:CA:A3:A5:20:AC:62:8F:20:A7:AE:32:CE:86:1C:B2:EF:B7:0F:A0:C7:45";
163162
const VALID_CERT_CHAIN: &[u8] = b"\
@@ -284,7 +283,7 @@ IKdcFKAt3fFrpyMhlfIKkLfmm0iDjmfmIXbDGBJw9SE=
284283

285284
#[test]
286285
fn test_decode_root_hash() {
287-
ensure_initialized();
286+
nss::ensure_initialized();
288287
assert!(decode_root_hash("meh!").is_err());
289288
assert!(decode_root_hash("3C:rr:44").is_err());
290289

@@ -331,6 +330,7 @@ BAUG
331330

332331
#[test]
333332
fn test_verify_fails_if_invalid() {
333+
nss::ensure_initialized();
334334
assert!(verify(
335335
b"msg",
336336
b"sig",
@@ -346,6 +346,7 @@ fdfeff
346346

347347
#[test]
348348
fn test_verify_fails_if_cert_has_expired() {
349+
nss::ensure_initialized();
349350
assert!(verify(
350351
VALID_INPUT,
351352
VALID_SIGNATURE,
@@ -359,6 +360,7 @@ fdfeff
359360

360361
#[test]
361362
fn test_verify_fails_if_bad_certificate_chain() {
363+
nss::ensure_initialized();
362364
assert!(verify(
363365
VALID_INPUT,
364366
VALID_SIGNATURE,
@@ -372,6 +374,7 @@ fdfeff
372374

373375
#[test]
374376
fn test_verify_fails_if_mismatch() {
377+
nss::ensure_initialized();
375378
assert!(verify(
376379
b"msg",
377380
VALID_SIGNATURE,
@@ -385,6 +388,7 @@ fdfeff
385388

386389
#[test]
387390
fn test_verify_fails_if_bad_hostname() {
391+
nss::ensure_initialized();
388392
assert!(verify(
389393
VALID_INPUT,
390394
VALID_SIGNATURE,
@@ -398,6 +402,7 @@ fdfeff
398402

399403
#[test]
400404
fn test_verify_fails_if_bad_root_hash() {
405+
nss::ensure_initialized();
401406
assert!(verify(
402407
VALID_INPUT,
403408
VALID_SIGNATURE,
@@ -411,6 +416,7 @@ fdfeff
411416

412417
#[test]
413418
fn test_verify_succeeds_if_valid() {
419+
nss::ensure_initialized();
414420
verify(
415421
VALID_INPUT,
416422
VALID_SIGNATURE,

components/support/rc_crypto/src/digest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ mod tests {
6060

6161
#[test]
6262
fn sha256_digest() {
63+
nss::ensure_initialized();
6364
assert_eq!(hex::encode(digest(&SHA256, MESSAGE).unwrap()), DIGEST_HEX);
6465
assert_ne!(
6566
hex::encode(digest(&SHA256, b"notbobo").unwrap()),
@@ -69,6 +70,7 @@ mod tests {
6970

7071
#[test]
7172
fn digest_cleanly_rejects_gigantic_messages() {
73+
nss::ensure_initialized();
7274
let message = vec![0; (i32::MAX as usize) + 1];
7375
assert!(digest(&SHA256, &message).is_err());
7476
}

components/support/rc_crypto/src/ece_crypto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ mod tests {
181181

182182
#[test]
183183
fn test_cryptographer_backend() {
184+
nss::ensure_initialized();
184185
crate::ensure_initialized();
185186
ece::crypto::test_cryptographer(RcCryptoCryptographer);
186187
}

components/support/rc_crypto/src/hawk_crypto.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ mod test {
9393
// Based on rust-hawk's hash_consistency. This fails if we've messed up the hashing.
9494
#[test]
9595
fn test_hawk_hashing() {
96+
nss::ensure_initialized();
9697
crate::ensure_initialized();
9798

9899
let mut hasher1 = hawk::PayloadHasher::new("text/plain", hawk::SHA256).unwrap();
@@ -124,6 +125,7 @@ mod test {
124125
// Based on rust-hawk's test_make_mac. This fails if we've messed up the signing.
125126
#[test]
126127
fn test_hawk_signing() {
128+
nss::ensure_initialized();
127129
crate::ensure_initialized();
128130

129131
let key = hawk::Key::new(

0 commit comments

Comments
 (0)