Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions stdlib/tests/stdlib_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,23 +915,16 @@ fn test_async_and_channels() {
}

#[test]
fn test_crypto_hash_and_compression() {
fn test_hash_operations() {
let registry = StdlibRegistry::new();
let crypto = registry.get_module("std.crypto").unwrap();
let hash = registry.get_module("std.hash").unwrap();
let compress = registry.get_module("std.compress").unwrap();

let mut config_unprivileged = RuntimeConfig::default();
config_unprivileged
.capabilities
.remove(&Capability::FileSystem);
let mut ctx_unprivileged = RuntimeContext::new(config_unprivileged);

let mut config_fs = RuntimeConfig::default();
config_fs.capabilities.insert(Capability::FileSystem);
let mut ctx_fs = RuntimeContext::new(config_fs);

// 1. Test hash operations
let md5_fn = hash.exports.get("md5").unwrap();
let val = md5_fn
.call(
Expand Down Expand Up @@ -961,8 +954,19 @@ fn test_crypto_hash_and_compression() {
)
.unwrap();
assert!(val.as_int().is_some());
}

#[test]
fn test_crypto_operations() {
let registry = StdlibRegistry::new();
let crypto = registry.get_module("std.crypto").unwrap();

let mut config_unprivileged = RuntimeConfig::default();
config_unprivileged
.capabilities
.remove(&Capability::FileSystem);
let mut ctx_unprivileged = RuntimeContext::new(config_unprivileged);

// 2. Test crypto operations (AES-GCM & Bcrypt)
let aes_enc = crypto.exports.get("aes_encrypt").unwrap();
let aes_dec = crypto.exports.get("aes_decrypt").unwrap();

Expand Down Expand Up @@ -1010,8 +1014,23 @@ fn test_crypto_hash_and_compression() {
.call(&mut ctx_unprivileged, vec![pass, hashed.clone()])
.unwrap();
assert_eq!(is_valid.as_bool(), Some(true));
}

#[test]
fn test_compression_operations() {
let registry = StdlibRegistry::new();
let compress = registry.get_module("std.compress").unwrap();

let mut config_unprivileged = RuntimeConfig::default();
config_unprivileged
.capabilities
.remove(&Capability::FileSystem);
let mut ctx_unprivileged = RuntimeContext::new(config_unprivileged);

let mut config_fs = RuntimeConfig::default();
config_fs.capabilities.insert(Capability::FileSystem);
let mut ctx_fs = RuntimeContext::new(config_fs);

// 3. Test compression capabilities & operations
let temp_dir = std::env::temp_dir().join("techscript_archive_test");
std::fs::create_dir_all(&temp_dir).ok();

Expand Down
Loading