Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2153)

Unified Diff: chrome/browser/local_discovery/privetv3_session_unittest.cc

Issue 880373004: Implement of privet/v3/auth after pairing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patches
Patch Set: Fri Jan 30 02:24:45 PST 2015 Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/local_discovery/privetv3_session.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/privetv3_session_unittest.cc
diff --git a/chrome/browser/local_discovery/privetv3_session_unittest.cc b/chrome/browser/local_discovery/privetv3_session_unittest.cc
index 7b6f195dc5345328f1dca5f6eb03ff119bf55944..679684e261ac31ac5b9ecc8a2bdc2dee5c964bf3 100644
--- a/chrome/browser/local_discovery/privetv3_session_unittest.cc
+++ b/chrome/browser/local_discovery/privetv3_session_unittest.cc
@@ -19,6 +19,7 @@ namespace local_discovery {
namespace {
+using testing::InSequence;
using testing::Invoke;
using testing::SaveArg;
using testing::StrictMock;
@@ -182,7 +183,11 @@ TEST_F(PrivetV3SessionTest, Pairing) {
base::Unretained(this)));
base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(session_.fingerprint_.empty());
+ EXPECT_EQ("Privet anonymous", session_.privet_auth_token_);
+
EXPECT_CALL(*this, OnCodeConfirmed(Result::STATUS_SUCCESS)).Times(1);
+ InSequence in_sequence;
EXPECT_CALL(*this, OnPostData(_))
.WillOnce(
testing::Invoke([this, &spake](const base::DictionaryValue& data) {
@@ -220,10 +225,32 @@ TEST_F(PrivetV3SessionTest, Pairing) {
fingerprint_base64.c_str(), signature_base64.c_str()),
net::HTTP_OK, net::URLRequestStatus::SUCCESS);
}));
+ EXPECT_CALL(*this, OnPostData(_))
+ .WillOnce(
+ testing::Invoke([this, &spake](const base::DictionaryValue& data) {
+ std::string access_token_base64;
+ EXPECT_TRUE(data.GetString("authCode", &access_token_base64));
+ std::string access_token;
+ EXPECT_TRUE(base::Base64Decode(access_token_base64, &access_token));
+
+ crypto::HMAC hmac(crypto::HMAC::SHA256);
+ const std::string& key = spake.GetUnverifiedKey();
+ EXPECT_TRUE(hmac.Init(key));
+ EXPECT_TRUE(hmac.Verify("testId", access_token));
+
+ fetcher_factory_.SetFakeResponse(
+ GURL("http://host/privet/v3/auth"),
+ "{\"accessToken\":\"567\",\"tokenType\":\"testType\","
+ "\"scope\":\"owner\"}",
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+ }));
session_.ConfirmCode("testPin",
base::Bind(&PrivetV3SessionTest::OnCodeConfirmed,
base::Unretained(this)));
base::RunLoop().RunUntilIdle();
+
+ EXPECT_FALSE(session_.fingerprint_.empty());
+ EXPECT_EQ("testType 567", session_.privet_auth_token_);
}
// TODO(vitalybuka): replace PrivetHTTPClient with regular URL fetcher and
« no previous file with comments | « chrome/browser/local_discovery/privetv3_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698