File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,10 @@ pub enum KeyAlgorithm {
190190 /// RSAES-OAEP-256 using SHA-2
191191 #[ serde( rename = "RSA-OAEP-256" ) ]
192192 RSA_OAEP_256 ,
193+
194+ /// Catch-All for when the key algorithm can not be determined or is not supported
195+ #[ serde( other) ]
196+ UNKNOWN_ALGORITHM ,
193197}
194198
195199impl FromStr for KeyAlgorithm {
@@ -443,7 +447,7 @@ mod tests {
443447 use serde_json:: json;
444448 use wasm_bindgen_test:: wasm_bindgen_test;
445449
446- use crate :: jwk:: { AlgorithmParameters , JwkSet , OctetKeyType } ;
450+ use crate :: jwk:: { AlgorithmParameters , JwkSet , KeyAlgorithm , OctetKeyType } ;
447451 use crate :: serialization:: b64_encode;
448452 use crate :: Algorithm ;
449453
@@ -477,4 +481,12 @@ mod tests {
477481 _ => panic ! ( "Unexpected key algorithm" ) ,
478482 }
479483 }
484+
485+ #[ test]
486+ fn deserialize_unknown_key_algorithm ( ) {
487+ let key_alg_json = json ! ( "" ) ;
488+ let key_alg_result: KeyAlgorithm =
489+ serde_json:: from_value ( key_alg_json) . expect ( "Could not deserialize json" ) ;
490+ assert_eq ! ( key_alg_result, KeyAlgorithm :: UNKNOWN_ALGORITHM ) ;
491+ }
480492}
You can’t perform that action at this time.
0 commit comments