feat(core): flesh out SecureNoteCore (Zeroizing body)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,30 @@
|
|||||||
|
//! Secure note: just a multiline body, Zeroizing.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct SecureNoteCore {}
|
pub struct SecureNoteCore {
|
||||||
|
pub body: Zeroizing<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn secure_note_round_trips() {
|
||||||
|
let note = SecureNoteCore { body: Zeroizing::new("a multi\nline note".into()) };
|
||||||
|
let json = serde_json::to_string(¬e).unwrap();
|
||||||
|
let parsed: SecureNoteCore = serde_json::from_str(&json).unwrap();
|
||||||
|
assert_eq!(parsed.body.as_str(), "a multi\nline note");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_body_round_trips() {
|
||||||
|
let note = SecureNoteCore::default();
|
||||||
|
let json = serde_json::to_string(¬e).unwrap();
|
||||||
|
let parsed: SecureNoteCore = serde_json::from_str(&json).unwrap();
|
||||||
|
assert!(parsed.body.is_empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user