Skip to content

Commit

Permalink
Fix deserialization for Algorithm::None (#624)
Browse files Browse the repository at this point in the history
* Bump ssi-jwk version
  • Loading branch information
cobward authored Oct 30, 2024
1 parent 3eaa9b0 commit 164ac45
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ssi-multicodec = { path = "./crates/multicodec", version = "0.2", default-featur
ssi-crypto = { path = "./crates/crypto", version = "0.2.1", default-features = false }
ssi-verification-methods-core = { path = "./crates/verification-methods/core", version = "0.1.1", default-features = false }
ssi-verification-methods = { path = "./crates/verification-methods", version = "0.1.1", default-features = false }
ssi-jwk = { path = "./crates/jwk", version = "0.3", default-features = false }
ssi-jwk = { path = "./crates/jwk", version = "0.3.1", default-features = false }
ssi-tzkey = { path = "./crates/tzkey", version = "0.2.1", default-features = false }
ssi-eip712 = { path = "./crates/eip712", version = "0.1", default-features = false }
ssi-rdf = { path = "./crates/rdf", version = "0.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/jwk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ssi-jwk"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = ["Spruce Systems, Inc."]
license = "Apache-2.0"
Expand Down
27 changes: 26 additions & 1 deletion crates/jwk/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! algorithms {
///
/// Per the specs it should only be `none` but `None` is kept for backwards
/// compatibility.
#[serde(alias = "None")]
#[serde(alias = "None", rename = "none")]
None
}

Expand Down Expand Up @@ -292,3 +292,28 @@ impl From<ES256OrES384> for Algorithm {
}
}
}

#[cfg(test)]
mod tests {
use super::Algorithm;

#[test]
fn none_serializes() {
assert_eq!(
serde_json::to_string(&Algorithm::None).unwrap(),
r#""none""#
)
}

#[test]
fn none_deserializes() {
assert_eq!(
serde_json::from_str::<Algorithm>(r#""none""#).unwrap(),
Algorithm::None
);
assert_eq!(
serde_json::from_str::<Algorithm>(r#""None""#).unwrap(),
Algorithm::None
)
}
}

0 comments on commit 164ac45

Please sign in to comment.