keyhog-core 0.5.50

keyhog-core: shared data model and detector specifications for the KeyHog secret scanner
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Binary credentials fail closed on output and accept historical tagged input.

use keyhog_core::Credential;

#[test]
fn binary_credential_serde_output_fails_closed() {
    let credential = Credential::from(vec![0x00, 0x01, 0xFF, 0xFE]);
    let mut output = Vec::new();
    let error = serde_json::to_writer(&mut output, &credential)
        .expect_err("implicit binary credential output must fail closed")
        .to_string();
    assert!(output.is_empty());
    assert!(!error.contains("AAH//g=="));

    let back: Credential = serde_json::from_str(r#"{"b64":"AAH//g=="}"#).unwrap();
    assert_eq!(credential, back);
}