diff --git a/src/accountmanager.rs b/src/accountmanager.rs index e389f7b..a9a0915 100644 --- a/src/accountmanager.rs +++ b/src/accountmanager.rs @@ -482,4 +482,38 @@ mod tests { .account_name ); } + + #[test] + fn test_sda_compatibility_no_webcookie() { + let path = Path::new("src/fixtures/maFiles/compat/no-webcookie/manifest.json"); + assert!(path.is_file()); + let result = Manifest::load(path); + assert!(matches!(result, Ok(_))); + let mut manifest = result.unwrap(); + assert!(matches!(manifest.entries.last().unwrap().encryption, None)); + assert!(matches!(manifest.load_accounts(&None), Ok(_))); + assert_eq!( + manifest.entries.last().unwrap().account_name, + manifest + .accounts + .last() + .unwrap() + .lock() + .unwrap() + .account_name + ); + assert_eq!( + manifest + .accounts + .last() + .unwrap() + .lock() + .unwrap() + .session + .as_ref() + .unwrap() + .web_cookie, + None + ); + } } diff --git a/src/fixtures/maFiles/compat/no-webcookie/manifest.json b/src/fixtures/maFiles/compat/no-webcookie/manifest.json new file mode 100644 index 0000000..0e6c961 --- /dev/null +++ b/src/fixtures/maFiles/compat/no-webcookie/manifest.json @@ -0,0 +1 @@ +{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"nowebcookie.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file diff --git a/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile b/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile new file mode 100644 index 0000000..038907a --- /dev/null +++ b/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile @@ -0,0 +1 @@ +{"shared_secret":"zvIayp3JPvtvX/QGHqsqKBk/44s=","serial_number":"kljasfhds","revocation_code":"R12345","uri":"otpauth://totp/Steam:example?secret=ASDF&issuer=Steam","server_time":1602522478,"account_name":"example","token_gid":"jkkjlhkhjgf","identity_secret":"kjsdlwowiqe=","secret_1":"sklduhfgsdlkjhf=","status":1,"device_id":"android:99d2ad0e-4bad-4247-b111-26393aae0be3","fully_enrolled":true,"Session":{"SessionID":"a;lskdjf","SteamLogin":"983498437543","SteamLoginSecure":"dlkjdsl;j%7C%32984730298","WebCookie":null,"OAuthToken":"asdk;lf;dsjlkfd","SteamID":1234}} \ No newline at end of file diff --git a/steamguard/src/steamapi.rs b/steamguard/src/steamapi.rs index 19ea1c1..d57d961 100644 --- a/steamguard/src/steamapi.rs +++ b/steamguard/src/steamapi.rs @@ -99,7 +99,7 @@ pub struct Session { #[serde(rename = "SteamLoginSecure")] pub steam_login_secure: String, #[serde(default, rename = "WebCookie")] - pub web_cookie: String, + pub web_cookie: Option, #[serde(rename = "OAuthToken")] pub token: String, #[serde(rename = "SteamID")] @@ -153,7 +153,7 @@ impl SteamApiClient { session_id: self .extract_session_id() .expect("failed to extract session id from cookies"), - web_cookie: data.webcookie.clone(), + web_cookie: Some(data.webcookie.clone()), }; }