Skip to content

Commit

Permalink
Add test that crypto is off by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ewalk153 committed Jul 4, 2024
1 parent 12034e5 commit bd5848a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/javy/src/apis/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ mod tests {
Ok(())
}

#[test]
fn test_crypto_disabled_by_default() -> Result<()> {
let runtime = Runtime::new(Config::default())?;

runtime.context().with(|this| {
let result= this.eval::<Value<'_>, _>(
r#"
crypto.createHmac("sha256", "hello world");
"#,
);
assert!(result.is_err());
let e = result.map_err(|e| from_js_error(this.clone(), e)).unwrap_err();
assert_eq!("Error:2:21 'crypto' is not defined\n at <eval> (eval_script:2:21)\n", e.to_string());
Ok::<_, Error>(())
})?;
Ok(())
}

#[test]
fn test_crypto_digest_with_lossy_input() -> Result<()> {
let mut config = Config::default();
Expand Down

0 comments on commit bd5848a

Please sign in to comment.