improve robustness of account migrations (#284)
- add an extreme test case for migrations - improve robustness of manifest migrations fixes #283
This commit is contained in:
parent
17d19c53c0
commit
eb51a7a2a7
17 changed files with 357 additions and 5 deletions
|
@ -143,17 +143,17 @@ pub struct SdaAccount {
|
|||
#[deprecated(note = "this is not used anymore, the closest equivalent is `Tokens`")]
|
||||
pub struct Session {
|
||||
#[serde(default, rename = "SessionID")]
|
||||
pub session_id: String,
|
||||
pub session_id: Option<String>,
|
||||
#[serde(default, rename = "SteamLogin")]
|
||||
pub steam_login: String,
|
||||
pub steam_login: Option<String>,
|
||||
#[serde(default, rename = "SteamLoginSecure")]
|
||||
pub steam_login_secure: String,
|
||||
pub steam_login_secure: Option<String>,
|
||||
#[serde(default, rename = "WebCookie")]
|
||||
pub web_cookie: Option<String>,
|
||||
#[serde(default, rename = "OAuthToken")]
|
||||
pub token: Option<String>,
|
||||
#[serde(rename = "SteamID")]
|
||||
pub steam_id: u64,
|
||||
pub steam_id: Option<u64>,
|
||||
}
|
||||
|
||||
impl CloneableSecret for Session {}
|
||||
|
@ -164,7 +164,7 @@ impl From<SdaAccount> for SteamGuardAccount {
|
|||
let steam_id = value
|
||||
.session
|
||||
.as_ref()
|
||||
.map(|s| s.expose_secret().steam_id)
|
||||
.and_then(|s| s.expose_secret().steam_id)
|
||||
.unwrap_or(0);
|
||||
Self {
|
||||
account_name: value.account_name,
|
||||
|
|
|
@ -304,6 +304,10 @@ mod tests {
|
|||
manifest: "src/fixtures/maFiles/compat/null-oauthtoken/manifest.json",
|
||||
passkey: None,
|
||||
},
|
||||
Test {
|
||||
manifest: "src/fixtures/maFiles/compat/difficult-migration/manifest.json",
|
||||
passkey: None,
|
||||
},
|
||||
];
|
||||
for case in cases {
|
||||
eprintln!("testing: {:?}", case);
|
||||
|
|
|
@ -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":";lkjsed;klfjas98093","OAuthToken":"asdk;lf;dsjlkfd","SteamID":1234}}
|
6
src/fixtures/maFiles/compat/difficult-migration/generate.sh
Executable file
6
src/fixtures/maFiles/compat/difficult-migration/generate.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
cat "1234.maFile" | jq -r '.Session | keys | .[]' | while read key; do
|
||||
cat "1234.maFile" | jq ".Session[\"$key\"] = null" > "null-$key.maFile"
|
||||
cat "1234.maFile" | jq ". | del(.Session.$key)" > "missing-$key.maFile"
|
||||
done
|
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"encrypted": false,
|
||||
"first_run": true,
|
||||
"entries": [
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-OAuthToken.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-SessionID.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-SteamID.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-SteamLogin.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-SteamLoginSecure.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "missing-WebCookie.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-OAuthToken.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-SessionID.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-SteamID.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-SteamLogin.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-SteamLoginSecure.maFile",
|
||||
"steamid": 1234
|
||||
},
|
||||
{
|
||||
"encryption_iv": null,
|
||||
"encryption_salt": null,
|
||||
"filename": "null-WebCookie.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,21 @@
|
|||
{
|
||||
"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": ";lkjsed;klfjas98093",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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": {
|
||||
"SteamLogin": "983498437543",
|
||||
"SteamLoginSecure": "dlkjdsl;j%7C%32984730298",
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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",
|
||||
"SteamLoginSecure": "dlkjdsl;j%7C%32984730298",
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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",
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"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",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": null,
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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": null,
|
||||
"SteamLogin": "983498437543",
|
||||
"SteamLoginSecure": "dlkjdsl;j%7C%32984730298",
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": null
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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": null,
|
||||
"SteamLoginSecure": "dlkjdsl;j%7C%32984730298",
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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": null,
|
||||
"WebCookie": ";lkjsed;klfjas98093",
|
||||
"OAuthToken": "asdk;lf;dsjlkfd",
|
||||
"SteamID": 1234
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue