Skip to content

Commit

Permalink
fix(tee): lowercase enum tee types
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeza committed Sep 4, 2024
1 parent 87b02e3 commit f9e12bd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion core/lib/basic_types/src/tee_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@ use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};

#[derive(Debug, Clone, Copy, PartialEq, EnumString, Display, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum TeeType {
#[strum(serialize = "sgx")]
Sgx,
}

#[cfg(test)]
mod tests {
use serde_json;

use super::TeeType;

#[test]
fn test_deserialize_teetype() {
let json_str = "\"sgx\"";
let tee_type: TeeType = serde_json::from_str(json_str).unwrap();
assert_eq!(tee_type, TeeType::Sgx);

for json_str in &["\"Sgx\"", "\"SGX\""] {
let result: Result<TeeType, _> = serde_json::from_str(json_str);
assert!(result.is_err());
}
}
}

0 comments on commit f9e12bd

Please sign in to comment.