spec/fetcher_spec.rb in lastpass-1.5.0 vs spec/fetcher_spec.rb in lastpass-1.6.0
- old
+ new
@@ -8,22 +8,22 @@
let(:password) { "password" }
let(:key_iteration_count) { 5000 }
let(:hash) { "7880a04588cfab954aa1a2da98fd9c0d2c6eba4c53e36a94510e6dbf30759256" }
let(:session_id) { "53ru,Hb713QnEVM5zWZ16jMvxS0" }
- let(:session) { LastPass::Session.new session_id, key_iteration_count }
+ let(:session) { LastPass::Session.new session_id, key_iteration_count, "DEADBEEF" }
let(:blob_response) { "TFBBVgAAAAMxMjJQUkVNAAAACjE0MTQ5" }
let(:blob_bytes) { blob_response.decode64 }
- let(:blob) { LastPass::Blob.new blob_bytes, key_iteration_count }
+ let(:blob) { LastPass::Blob.new blob_bytes, key_iteration_count, "DEADBEEF" }
- let(:login_post_data) { {method: "mobile",
- web: 1,
- xml: 1,
+ let(:login_post_data) { {method: "cli",
+ xml: 2,
username: username,
hash: hash,
- iterations: key_iteration_count} }
+ iterations: key_iteration_count,
+ includeprivatekeyenc: 1} }
let(:device_id) { "492378378052455" }
let(:login_post_data_with_device_id) { login_post_data.merge({imei: device_id}) }
let(:google_authenticator_code) { "123456" }
@@ -34,11 +34,11 @@
describe ".logout" do
it "makes a GET request" do
web_client = double "web_client"
expect(web_client).to receive(:get)
- .with("https://lastpass.com/logout.php?mobile=1", cookies: {"PHPSESSID" => session_id})
+ .with("https://lastpass.com/logout.php?method=cli&noredirect=1", cookies: {"PHPSESSID" => session_id})
.and_return(http_ok "")
LastPass::Fetcher.logout session, web_client
end
it "raises an exception on HTTP error" do
@@ -96,11 +96,11 @@
describe ".request_login" do
def verify_post_request multifactor_password, device_id, post_data
web_client = double("web_client")
expect(web_client).to receive(:post)
.with("https://lastpass.com/login.php", format: :xml, body: post_data)
- .and_return(http_ok("ok" => {"sessionid" => session_id}))
+ .and_return(http_ok("response" => {"ok" => {"sessionid" => session_id, "privatekeyenc" => "DEADBEEF"}}))
LastPass::Fetcher.request_login username,
password,
key_iteration_count,
multifactor_password,
@@ -123,11 +123,11 @@
it "makes a POST request with Yubikey password" do
verify_post_request yubikey_password, nil, login_post_data_with_yubikey_password
end
it "returns a session" do
- expect(request_login_with_xml "<ok sessionid='#{session_id}' />").to eq session
+ expect(request_login_with_xml "<response><ok sessionid='#{session_id}' /></response>").to eq session
end
it "raises an exception on HTTP error" do
expect { request_login_with_error }.to raise_error LastPass::NetworkError
end
@@ -175,11 +175,11 @@
end
it "raises an exception on missing/incorrect Yubikey password" do
message = "Your account settings have restricted you from logging in " +
"from mobile devices that do not support YubiKey authentication."
- expect { request_login_with_lastpass_error "yubikeyrestricted", message }
+ expect { request_login_with_lastpass_error "otprequired", message }
.to raise_error LastPass::LastPassIncorrectYubikeyPasswordError, message
end
it "raises an exception on unknown LastPass error with a message" do
message = "Unknow error message"
@@ -195,10 +195,10 @@
end
describe ".fetch" do
it "makes a GET request" do
expect(web_client = double("web_client")).to receive(:get)
- .with("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android",
+ .with("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=cli",
format: :plain,
cookies: {"PHPSESSID" => session_id})
.and_return(http_ok(blob_response))
LastPass::Fetcher.fetch session, web_client