tmpltool 1.5.0

A fast and simple command-line template rendering tool using MiniJinja templates with environment variables
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
//! Tests for encoding functions.
//!
//! Tests both function syntax and filter syntax for migrated filter-functions,
//! and function-only tests for bcrypt, generate_secret, hmac_sha256.

use minijinja::value::Kwargs;
use minijinja::{Environment, Value};
use tmpltool::filter_functions::FilterFunction;
use tmpltool::filter_functions::encoding::{
    Base64Decode, Base64Encode, EscapeHtml, EscapeShell, EscapeXml, HexDecode, HexEncode,
};
use tmpltool::functions::Function;
use tmpltool::functions::encoding::{Bcrypt, GenerateSecret, HmacSha256};

// Helper to test both function and filter syntax produce the same result
fn assert_both_syntaxes_equal(env: &Environment, function_template: &str, filter_template: &str) {
    let fn_result = env
        .render_str(function_template, ())
        .expect("Function syntax should work");
    let filter_result = env
        .render_str(filter_template, ())
        .expect("Filter syntax should work");
    assert_eq!(
        fn_result, filter_result,
        "Function and filter syntax should produce identical results"
    );
}

fn setup_env() -> Environment<'static> {
    let mut env = Environment::new();
    Base64Encode::register(&mut env);
    Base64Decode::register(&mut env);
    HexEncode::register(&mut env);
    HexDecode::register(&mut env);
    EscapeHtml::register(&mut env);
    EscapeXml::register(&mut env);
    EscapeShell::register(&mut env);
    env
}

// ============ Base64 Encode Tests ============

#[test]
fn test_base64_encode_basic() {
    let result = Base64Encode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("Hello World"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "SGVsbG8gV29ybGQ=");
}

#[test]
fn test_base64_encode_filter() {
    let value = Value::from("Hello World");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = Base64Encode::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "SGVsbG8gV29ybGQ=");
}

#[test]
fn test_base64_encode_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ base64_encode(string="Hello World") }}"#,
        r#"{{ "Hello World" | base64_encode }}"#,
    );
}

#[test]
fn test_base64_encode_empty() {
    let result =
        Base64Encode::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "");
}

#[test]
fn test_base64_encode_special_chars() {
    let result = Base64Encode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("user:password"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "dXNlcjpwYXNzd29yZA==");
}

// ============ Base64 Decode Tests ============

#[test]
fn test_base64_decode_basic() {
    let result = Base64Decode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("SGVsbG8gV29ybGQ="),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "Hello World");
}

#[test]
fn test_base64_decode_filter() {
    let value = Value::from("SGVsbG8gV29ybGQ=");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = Base64Decode::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "Hello World");
}

#[test]
fn test_base64_decode_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ base64_decode(string="SGVsbG8gV29ybGQ=") }}"#,
        r#"{{ "SGVsbG8gV29ybGQ=" | base64_decode }}"#,
    );
}

#[test]
fn test_base64_decode_empty() {
    let result =
        Base64Decode::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "");
}

#[test]
fn test_base64_decode_invalid() {
    let result = Base64Decode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("invalid!@#$"),
    )]));
    assert!(result.is_err());
    assert!(result.unwrap_err().to_string().contains("Failed to decode"));
}

#[test]
fn test_base64_roundtrip() {
    let env = setup_env();
    let result = env
        .render_str(r#"{{ "Test string" | base64_encode | base64_decode }}"#, ())
        .unwrap();
    assert_eq!(result, "Test string");
}

// ============ Hex Encode Tests ============

#[test]
fn test_hex_encode_basic() {
    let result =
        HexEncode::call_as_function(Kwargs::from_iter(vec![("string", Value::from("Hello"))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "48656c6c6f");
}

#[test]
fn test_hex_encode_filter() {
    let value = Value::from("Hello");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = HexEncode::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "48656c6c6f");
}

#[test]
fn test_hex_encode_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ hex_encode(string="Hello") }}"#,
        r#"{{ "Hello" | hex_encode }}"#,
    );
}

#[test]
fn test_hex_encode_empty() {
    let result =
        HexEncode::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))])).unwrap();
    assert_eq!(result.as_str().unwrap(), "");
}

#[test]
fn test_hex_encode_numbers() {
    let result =
        HexEncode::call_as_function(Kwargs::from_iter(vec![("string", Value::from("123"))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "313233");
}

// ============ Hex Decode Tests ============

#[test]
fn test_hex_decode_basic() {
    let result = HexDecode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("48656c6c6f"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "Hello");
}

#[test]
fn test_hex_decode_filter() {
    let value = Value::from("48656c6c6f");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = HexDecode::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "Hello");
}

#[test]
fn test_hex_decode_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ hex_decode(string="48656c6c6f") }}"#,
        r#"{{ "48656c6c6f" | hex_decode }}"#,
    );
}

#[test]
fn test_hex_decode_uppercase() {
    let result = HexDecode::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("48656C6C6F"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "Hello");
}

#[test]
fn test_hex_decode_invalid() {
    let result =
        HexDecode::call_as_function(Kwargs::from_iter(vec![("string", Value::from("xyz"))]));
    assert!(result.is_err());
    assert!(result.unwrap_err().to_string().contains("Failed to decode"));
}

#[test]
fn test_hex_decode_odd_length() {
    let result =
        HexDecode::call_as_function(Kwargs::from_iter(vec![("string", Value::from("123"))]));
    assert!(result.is_err());
}

#[test]
fn test_hex_roundtrip() {
    let env = setup_env();
    let result = env
        .render_str(r#"{{ "Test 123" | hex_encode | hex_decode }}"#, ())
        .unwrap();
    assert_eq!(result, "Test 123");
}

// ============ Escape HTML Tests ============

#[test]
fn test_escape_html_basic() {
    let result = EscapeHtml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("<script>alert('XSS')</script>"),
    )]))
    .unwrap();
    assert_eq!(
        result.as_str().unwrap(),
        "&lt;script&gt;alert(&#x27;XSS&#x27;)&lt;/script&gt;"
    );
}

#[test]
fn test_escape_html_filter() {
    let value = Value::from("<b>bold</b>");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = EscapeHtml::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "&lt;b&gt;bold&lt;/b&gt;");
}

#[test]
fn test_escape_html_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ escape_html(string="<b>test</b>") }}"#,
        r#"{{ "<b>test</b>" | escape_html }}"#,
    );
}

#[test]
fn test_escape_html_ampersand() {
    let result =
        EscapeHtml::call_as_function(Kwargs::from_iter(vec![("string", Value::from("A & B"))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "A &amp; B");
}

#[test]
fn test_escape_html_quotes() {
    let result = EscapeHtml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from(r#"Say "hello""#),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "Say &quot;hello&quot;");
}

#[test]
fn test_escape_html_all_entities() {
    let result = EscapeHtml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from(r#"<tag attr="value">'text' & more</tag>"#),
    )]))
    .unwrap();
    assert_eq!(
        result.as_str().unwrap(),
        "&lt;tag attr=&quot;value&quot;&gt;&#x27;text&#x27; &amp; more&lt;/tag&gt;"
    );
}

#[test]
fn test_escape_html_empty() {
    let result =
        EscapeHtml::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))])).unwrap();
    assert_eq!(result.as_str().unwrap(), "");
}

// ============ Escape XML Tests ============

#[test]
fn test_escape_xml_basic() {
    let result = EscapeXml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("<tag>content</tag>"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "&lt;tag&gt;content&lt;/tag&gt;");
}

#[test]
fn test_escape_xml_filter() {
    let value = Value::from("<xml/>");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = EscapeXml::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "&lt;xml/&gt;");
}

#[test]
fn test_escape_xml_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ escape_xml(string="<xml/>") }}"#,
        r#"{{ "<xml/>" | escape_xml }}"#,
    );
}

#[test]
fn test_escape_xml_apostrophe() {
    let result = EscapeXml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("it's working"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "it&apos;s working");
}

#[test]
fn test_escape_xml_all_entities() {
    let result = EscapeXml::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from(r#"<tag attr="value">'text' & more</tag>"#),
    )]))
    .unwrap();
    assert_eq!(
        result.as_str().unwrap(),
        "&lt;tag attr=&quot;value&quot;&gt;&apos;text&apos; &amp; more&lt;/tag&gt;"
    );
}

// ============ Escape Shell Tests ============

#[test]
fn test_escape_shell_simple() {
    let result =
        EscapeShell::call_as_function(Kwargs::from_iter(vec![("string", Value::from("hello"))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "'hello'");
}

#[test]
fn test_escape_shell_filter() {
    let value = Value::from("hello");
    let kwargs = Kwargs::from_iter(std::iter::empty::<(&str, Value)>());
    let result = EscapeShell::call_as_filter(&value, kwargs).unwrap();
    assert_eq!(result.as_str().unwrap(), "'hello'");
}

#[test]
fn test_escape_shell_both_syntaxes() {
    let env = setup_env();
    assert_both_syntaxes_equal(
        &env,
        r#"{{ escape_shell(string="hello world") }}"#,
        r#"{{ "hello world" | escape_shell }}"#,
    );
}

#[test]
fn test_escape_shell_with_spaces() {
    let result = EscapeShell::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("hello world"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "'hello world'");
}

#[test]
fn test_escape_shell_with_quote() {
    let result = EscapeShell::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("it's working"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "'it'\\''s working'");
}

#[test]
fn test_escape_shell_special_chars() {
    let result = EscapeShell::call_as_function(Kwargs::from_iter(vec![(
        "string",
        Value::from("$VAR && rm -rf /"),
    )]))
    .unwrap();
    assert_eq!(result.as_str().unwrap(), "'$VAR && rm -rf /'");
}

#[test]
fn test_escape_shell_empty() {
    let result =
        EscapeShell::call_as_function(Kwargs::from_iter(vec![("string", Value::from(""))]))
            .unwrap();
    assert_eq!(result.as_str().unwrap(), "''");
}

// ============ Chaining Tests ============

#[test]
fn test_encoding_chaining() {
    let env = setup_env();
    // Chain: encode to base64 then to hex
    let result = env
        .render_str(r#"{{ "Hi" | base64_encode | hex_encode }}"#, ())
        .unwrap();
    // "Hi" -> base64 -> "SGk=" -> hex
    assert_eq!(result, "53476b3d");
}

// ============ Bcrypt Tests (function-only) ============

#[test]
fn test_bcrypt_basic() {
    let result = Bcrypt::call(Kwargs::from_iter(vec![(
        "password",
        Value::from("mypassword"),
    )]))
    .unwrap();
    let hash = result.as_str().unwrap();

    // Bcrypt hashes start with $2b$ or $2a$
    assert!(hash.starts_with("$2"));
    // Bcrypt hashes are 60 characters long
    assert_eq!(hash.len(), 60);
}

#[test]
fn test_bcrypt_with_rounds() {
    let result = Bcrypt::call(Kwargs::from_iter(vec![
        ("password", Value::from("test")),
        ("rounds", Value::from(10)),
    ]))
    .unwrap();
    let hash = result.as_str().unwrap();
    assert!(hash.starts_with("$2"));
}

#[test]
fn test_bcrypt_invalid_rounds_low() {
    let result = Bcrypt::call(Kwargs::from_iter(vec![
        ("password", Value::from("test")),
        ("rounds", Value::from(3)),
    ]));
    assert!(result.is_err());
    assert!(result.unwrap_err().to_string().contains("between 4 and 31"));
}

#[test]
fn test_bcrypt_invalid_rounds_high() {
    let result = Bcrypt::call(Kwargs::from_iter(vec![
        ("password", Value::from("test")),
        ("rounds", Value::from(32)),
    ]));
    assert!(result.is_err());
    assert!(result.unwrap_err().to_string().contains("between 4 and 31"));
}

#[test]
fn test_bcrypt_uniqueness() {
    // Same password should generate different hashes (due to random salt)
    let hash1 = Bcrypt::call(Kwargs::from_iter(vec![("password", Value::from("test"))])).unwrap();
    let hash2 = Bcrypt::call(Kwargs::from_iter(vec![("password", Value::from("test"))])).unwrap();

    assert_ne!(hash1.as_str().unwrap(), hash2.as_str().unwrap());
}

// ============ Generate Secret Tests (function-only) ============

#[test]
fn test_generate_secret_alphanumeric() {
    let result =
        GenerateSecret::call(Kwargs::from_iter(vec![("length", Value::from(32))])).unwrap();
    let secret = result.as_str().unwrap();

    assert_eq!(secret.len(), 32);
    // Check that it only contains alphanumeric characters
    assert!(secret.chars().all(|c| c.is_ascii_alphanumeric()));
}

#[test]
fn test_generate_secret_hex() {
    let result = GenerateSecret::call(Kwargs::from_iter(vec![
        ("length", Value::from(16)),
        ("charset", Value::from("hex")),
    ]))
    .unwrap();
    let secret = result.as_str().unwrap();

    assert_eq!(secret.len(), 16);
    // Check that it only contains hex characters
    assert!(secret.chars().all(|c| c.is_ascii_hexdigit()));
}

#[test]
fn test_generate_secret_base64() {
    let result = GenerateSecret::call(Kwargs::from_iter(vec![
        ("length", Value::from(24)),
        ("charset", Value::from("base64")),
    ]))
    .unwrap();
    let secret = result.as_str().unwrap();

    assert_eq!(secret.len(), 24);
}

#[test]
fn test_generate_secret_invalid_length_zero() {
    let result = GenerateSecret::call(Kwargs::from_iter(vec![("length", Value::from(0))]));
    assert!(result.is_err());
    assert!(
        result
            .unwrap_err()
            .to_string()
            .contains("between 1 and 1024")
    );
}

#[test]
fn test_generate_secret_invalid_length_large() {
    let result = GenerateSecret::call(Kwargs::from_iter(vec![("length", Value::from(2000))]));
    assert!(result.is_err());
    assert!(
        result
            .unwrap_err()
            .to_string()
            .contains("between 1 and 1024")
    );
}

#[test]
fn test_generate_secret_invalid_charset() {
    let result = GenerateSecret::call(Kwargs::from_iter(vec![
        ("length", Value::from(16)),
        ("charset", Value::from("invalid")),
    ]));
    assert!(result.is_err());
    assert!(result.unwrap_err().to_string().contains("Invalid charset"));
}

#[test]
fn test_generate_secret_uniqueness() {
    let secret1 =
        GenerateSecret::call(Kwargs::from_iter(vec![("length", Value::from(32))])).unwrap();
    let secret2 =
        GenerateSecret::call(Kwargs::from_iter(vec![("length", Value::from(32))])).unwrap();

    assert_ne!(secret1.as_str().unwrap(), secret2.as_str().unwrap());
}

// ============ HMAC-SHA256 Tests (function-only) ============

#[test]
fn test_hmac_sha256_basic() {
    let result = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    // HMAC-SHA256 produces a 64-character hex string (32 bytes)
    assert_eq!(result.as_str().unwrap().len(), 64);
}

#[test]
fn test_hmac_sha256_deterministic() {
    let result1 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    let result2 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    // Same key and message should produce same HMAC
    assert_eq!(result1.as_str().unwrap(), result2.as_str().unwrap());
}

#[test]
fn test_hmac_sha256_different_keys() {
    let result1 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret1")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    let result2 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret2")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    // Different keys should produce different HMACs
    assert_ne!(result1.as_str().unwrap(), result2.as_str().unwrap());
}

#[test]
fn test_hmac_sha256_different_messages() {
    let result1 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret")),
        ("message", Value::from("hello")),
    ]))
    .unwrap();

    let result2 = HmacSha256::call(Kwargs::from_iter(vec![
        ("key", Value::from("secret")),
        ("message", Value::from("world")),
    ]))
    .unwrap();

    // Different messages should produce different HMACs
    assert_ne!(result1.as_str().unwrap(), result2.as_str().unwrap());
}

// Note: base64_encode_fn, base64_decode_fn, hex_encode_fn, hex_decode_fn,
// escape_html_fn, escape_xml_fn, escape_shell_fn tests removed - these functions
// are now in filter_functions/encoding.rs with dual function+filter syntax support.
// See tests/test_filters_integration.rs for integration tests of these filters.

#[test]
fn test_generate_secret_missing_length() {
    let result = GenerateSecret::call(Kwargs::from_iter(Vec::<(&str, Value)>::new()));
    assert!(result.is_err());
}

#[test]
fn test_hmac_sha256_missing_key() {
    let result = HmacSha256::call(Kwargs::from_iter(vec![("message", Value::from("hello"))]));
    assert!(result.is_err());
}

#[test]
fn test_hmac_sha256_missing_message() {
    let result = HmacSha256::call(Kwargs::from_iter(vec![("key", Value::from("secret"))]));
    assert!(result.is_err());
}