cargo fmt
This commit is contained in:
parent
a808fa1fe6
commit
52d247f102
4 changed files with 48 additions and 34 deletions
|
@ -8,7 +8,9 @@ use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
use steamguard::{steamapi, Confirmation, ConfirmationType, SteamGuardAccount, UserLogin, LoginError};
|
use steamguard::{
|
||||||
|
steamapi, Confirmation, ConfirmationType, LoginError, SteamGuardAccount, UserLogin,
|
||||||
|
};
|
||||||
use termion::{
|
use termion::{
|
||||||
event::{Event, Key},
|
event::{Event, Key},
|
||||||
input::TermRead,
|
input::TermRead,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
pub use confirmation::{Confirmation, ConfirmationType};
|
pub use confirmation::{Confirmation, ConfirmationType};
|
||||||
pub use userlogin::{LoginError, UserLogin};
|
|
||||||
use hmacsha1::hmac_sha1;
|
use hmacsha1::hmac_sha1;
|
||||||
use log::*;
|
use log::*;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
|
@ -11,6 +10,7 @@ use reqwest::{
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, convert::TryInto, thread, time};
|
use std::{collections::HashMap, convert::TryInto, thread, time};
|
||||||
|
pub use userlogin::{LoginError, UserLogin};
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use reqwest::{
|
||||||
header::{HeaderMap, HeaderName, HeaderValue, SET_COOKIE},
|
header::{HeaderMap, HeaderName, HeaderValue, SET_COOKIE},
|
||||||
Url,
|
Url,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize, Deserializer};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
@ -299,21 +299,33 @@ fn test_oauth_data_parse() {
|
||||||
assert_eq!(oauth.steamid, "78562647129469312");
|
assert_eq!(oauth.steamid, "78562647129469312");
|
||||||
assert_eq!(oauth.oauth_token, "fd2fdb3d0717bcd2220d98c7ec61c7bd");
|
assert_eq!(oauth.oauth_token, "fd2fdb3d0717bcd2220d98c7ec61c7bd");
|
||||||
assert_eq!(oauth.wgtoken, "72E7013D598A4F68C7E268F6FA3767D89D763732");
|
assert_eq!(oauth.wgtoken, "72E7013D598A4F68C7E268F6FA3767D89D763732");
|
||||||
assert_eq!(oauth.wgtoken_secure, "21061EA13C36D7C29812CAED900A215171AD13A2");
|
assert_eq!(
|
||||||
|
oauth.wgtoken_secure,
|
||||||
|
"21061EA13C36D7C29812CAED900A215171AD13A2"
|
||||||
|
);
|
||||||
assert_eq!(oauth.webcookie, "6298070A226E5DAD49938D78BCF36F7A7118FDD5");
|
assert_eq!(oauth.webcookie, "6298070A226E5DAD49938D78BCF36F7A7118FDD5");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_login_response_parse() {
|
fn test_login_response_parse() {
|
||||||
let result = serde_json::from_str::<LoginResponse>(include_str!("fixtures/api-responses/login-response1.json"));
|
let result = serde_json::from_str::<LoginResponse>(include_str!(
|
||||||
|
"fixtures/api-responses/login-response1.json"
|
||||||
|
));
|
||||||
|
|
||||||
assert!(matches!(result, Ok(_)), "got error: {}", result.unwrap_err());
|
assert!(
|
||||||
|
matches!(result, Ok(_)),
|
||||||
|
"got error: {}",
|
||||||
|
result.unwrap_err()
|
||||||
|
);
|
||||||
let resp = result.unwrap();
|
let resp = result.unwrap();
|
||||||
|
|
||||||
let oauth = resp.oauth.unwrap();
|
let oauth = resp.oauth.unwrap();
|
||||||
assert_eq!(oauth.steamid, "78562647129469312");
|
assert_eq!(oauth.steamid, "78562647129469312");
|
||||||
assert_eq!(oauth.oauth_token, "fd2fdb3d0717bad2220d98c7ec61c7bd");
|
assert_eq!(oauth.oauth_token, "fd2fdb3d0717bad2220d98c7ec61c7bd");
|
||||||
assert_eq!(oauth.wgtoken, "72E7013D598A4F68C7E268F6FA3767D89D763732");
|
assert_eq!(oauth.wgtoken, "72E7013D598A4F68C7E268F6FA3767D89D763732");
|
||||||
assert_eq!(oauth.wgtoken_secure, "21061EA13C36D7C29812CAED900A215171AD13A2");
|
assert_eq!(
|
||||||
|
oauth.wgtoken_secure,
|
||||||
|
"21061EA13C36D7C29812CAED900A215171AD13A2"
|
||||||
|
);
|
||||||
assert_eq!(oauth.webcookie, "6298070A226E5DAD49938D78BCF36F7A7118FDD5");
|
assert_eq!(oauth.webcookie, "6298070A226E5DAD49938D78BCF36F7A7118FDD5");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::steamapi::{LoginResponse, RsaResponse, Session, SteamApiClient};
|
||||||
use log::*;
|
use log::*;
|
||||||
use rsa::{PublicKey, RsaPublicKey};
|
use rsa::{PublicKey, RsaPublicKey};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use crate::steamapi::{SteamApiClient, LoginResponse, RsaResponse, Session};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum LoginError {
|
pub enum LoginError {
|
||||||
|
|
Loading…
Reference in a new issue