Merge pull request #120 from gergesh/make-webcookie-optional
Make WebCookie optional in Session
This commit is contained in:
commit
743abea8bf
4 changed files with 38 additions and 2 deletions
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
1
src/fixtures/maFiles/compat/no-webcookie/manifest.json
Normal file
1
src/fixtures/maFiles/compat/no-webcookie/manifest.json
Normal file
|
@ -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}
|
|
@ -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}}
|
|
@ -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<String>,
|
||||
#[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()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue