Skip to content

Commit b8d2906

Browse files
committed
Re-enable the HMAC sign & verify test cases
1 parent 903ecff commit b8d2906

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

tests/hmac.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@ use wasm_bindgen_test::wasm_bindgen_test;
66
use jsonwebtoken::errors::ErrorKind;
77
use jsonwebtoken::jwk::Jwk;
88
use jsonwebtoken::{
9-
// crypto::{sign, verify},
10-
decode,
11-
decode_header,
12-
encode,
13-
Algorithm,
14-
DecodingKey,
15-
EncodingKey,
16-
Header,
17-
Validation,
9+
crypto::{sign, verify},
10+
decode, decode_header, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation,
1811
};
1912

2013
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
@@ -24,23 +17,23 @@ pub struct Claims {
2417
exp: i64,
2518
}
2619

27-
// #[test]
28-
// #[wasm_bindgen_test]
29-
// fn sign_hs256() {
30-
// let result =
31-
// sign(b"hello world", &EncodingKey::from_secret(b"secret"), Algorithm::HS256).unwrap();
32-
// let expected = "c0zGLzKEFWj0VxWuufTXiRMk5tlI5MbGDAYhzaxIYjo";
33-
// assert_eq!(result, expected);
34-
// }
20+
#[test]
21+
#[wasm_bindgen_test]
22+
fn sign_hs256() {
23+
let result =
24+
sign(b"hello world", &EncodingKey::from_secret(b"secret"), Algorithm::HS256).unwrap();
25+
let expected = "c0zGLzKEFWj0VxWuufTXiRMk5tlI5MbGDAYhzaxIYjo";
26+
assert_eq!(result, expected);
27+
}
3528

36-
// #[test]
37-
// #[wasm_bindgen_test]
38-
// fn verify_hs256() {
39-
// let sig = "c0zGLzKEFWj0VxWuufTXiRMk5tlI5MbGDAYhzaxIYjo";
40-
// let valid = verify(sig, b"hello world", &DecodingKey::from_secret(b"secret"), Algorithm::HS256)
41-
// .unwrap();
42-
// assert!(valid);
43-
// }
29+
#[test]
30+
#[wasm_bindgen_test]
31+
fn verify_hs256() {
32+
let sig = "c0zGLzKEFWj0VxWuufTXiRMk5tlI5MbGDAYhzaxIYjo";
33+
let valid = verify(sig, b"hello world", &DecodingKey::from_secret(b"secret"), Algorithm::HS256)
34+
.unwrap();
35+
assert!(valid);
36+
}
4437

4538
#[test]
4639
#[wasm_bindgen_test]

tests/rsa/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ pub struct Claims {
2626
exp: i64,
2727
}
2828

29-
// Todo: These no longer apply because `verify` does not exist, would probably need to convert it to test the factory for getting signers and verifiers. But I would rather this not be part of the public facing API.
30-
3129
#[cfg(feature = "use_pem")]
3230
#[test]
3331
#[wasm_bindgen_test]

0 commit comments

Comments
 (0)