Add Cargo workspace + common crate with Mode and Method types
This commit is contained in:
2
common/src/lib.rs
Normal file
2
common/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod policy;
|
||||
pub mod types;
|
||||
1
common/src/policy.rs
Normal file
1
common/src/policy.rs
Normal file
@@ -0,0 +1 @@
|
||||
// Policy parsing implemented in Phase 2.
|
||||
35
common/src/types.rs
Normal file
35
common/src/types.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Mode {
|
||||
Disabled,
|
||||
Optional,
|
||||
Required,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Method {
|
||||
Fido2,
|
||||
Totp,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn mode_serializes_to_lowercase() {
|
||||
let m = Mode::Required;
|
||||
let s = serde_json::to_string(&m).unwrap();
|
||||
assert_eq!(s, "\"required\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn method_serializes_to_lowercase() {
|
||||
let m = Method::Fido2;
|
||||
let s = serde_json::to_string(&m).unwrap();
|
||||
assert_eq!(s, "\"fido2\"");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user