diff --git a/steamguard/src/confirmation.rs b/steamguard/src/confirmation.rs index faf3f71..69d448b 100644 --- a/steamguard/src/confirmation.rs +++ b/steamguard/src/confirmation.rs @@ -92,7 +92,7 @@ impl<'a> Confirmer<'a> { let mut deser = serde_json::Deserializer::from_str(text.as_str()); let body: ConfirmationListResponse = serde_path_to_error::deserialize(&mut deser)?; - if body.needsauth.unwrap_or(false) { + if body.needauth.unwrap_or(false) { return Err(ConfirmerError::InvalidTokens); } if !body.success { @@ -276,6 +276,7 @@ impl From for ConfirmationType { 1 => ConfirmationType::Generic, 2 => ConfirmationType::Trade, 3 => ConfirmationType::MarketSell, + 5 => ConfirmationType::AccountDetails, 6 => ConfirmationType::AccountRecovery, v => ConfirmationType::Unknown(v), } @@ -286,7 +287,8 @@ impl From for ConfirmationType { pub struct ConfirmationListResponse { pub success: bool, #[serde(default)] - pub needsauth: Option, + pub needauth: Option, + #[serde(default)] pub conf: Vec, } @@ -347,6 +349,24 @@ mod tests { Ok(()) } + #[test] + fn test_parse_confirmations_2() -> anyhow::Result<()> { + struct Test { + text: &'static str, + } + let cases = [Test { + text: include_str!("fixtures/confirmations/need-auth.json"), + }]; + for case in cases.iter() { + let confirmations = serde_json::from_str::(case.text)?; + + assert_eq!(confirmations.conf.len(), 0); + assert_eq!(confirmations.needauth, Some(true)); + } + + Ok(()) + } + #[test] fn test_generate_confirmation_hash_for_time() { assert_eq!( diff --git a/steamguard/src/fixtures/confirmations/need-auth.json b/steamguard/src/fixtures/confirmations/need-auth.json new file mode 100644 index 0000000..bc9286c --- /dev/null +++ b/steamguard/src/fixtures/confirmations/need-auth.json @@ -0,0 +1,4 @@ +{ + "success": false, + "needauth": true +} \ No newline at end of file