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

Side by Side Diff: remoting/protocol/negotiating_authenticator_unittest.cc

Issue 15685008: Show a 'remember me' checkbox in the web-app when connecting to a host that supports pairing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "net/base/net_errors.h" 6 #include "net/base/net_errors.h"
7 #include "remoting/base/rsa_key_pair.h" 7 #include "remoting/base/rsa_key_pair.h"
8 #include "remoting/protocol/authenticator_test_base.h" 8 #include "remoting/protocol/authenticator_test_base.h"
9 #include "remoting/protocol/channel_authenticator.h" 9 #include "remoting/protocol/channel_authenticator.h"
10 #include "remoting/protocol/connection_tester.h" 10 #include "remoting/protocol/connection_tester.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 pairing_registry); 62 pairing_registry);
63 63
64 std::vector<AuthenticationMethod> methods; 64 std::vector<AuthenticationMethod> methods;
65 methods.push_back(AuthenticationMethod::Spake2Pair()); 65 methods.push_back(AuthenticationMethod::Spake2Pair());
66 methods.push_back(AuthenticationMethod::Spake2( 66 methods.push_back(AuthenticationMethod::Spake2(
67 AuthenticationMethod::HMAC_SHA256)); 67 AuthenticationMethod::HMAC_SHA256));
68 if (!client_hmac_only) { 68 if (!client_hmac_only) {
69 methods.push_back(AuthenticationMethod::Spake2( 69 methods.push_back(AuthenticationMethod::Spake2(
70 AuthenticationMethod::NONE)); 70 AuthenticationMethod::NONE));
71 } 71 }
72 bool pairing_expected = pairing_registry != NULL;
73 FetchSecretCallback fetch_secret_callback = base::Bind(
74 &NegotiatingAuthenticatorTest::FetchSecret,
75 client_interactive_pin, pairing_expected);
72 client_as_negotiating_authenticator_ = new NegotiatingClientAuthenticator( 76 client_as_negotiating_authenticator_ = new NegotiatingClientAuthenticator(
73 client_id, client_paired_secret, 77 client_id, client_paired_secret,
74 kTestHostId, base::Bind(&NegotiatingAuthenticatorTest::FetchSecret, 78 kTestHostId, fetch_secret_callback,
75 client_interactive_pin),
76 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods); 79 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods);
77 client_.reset(client_as_negotiating_authenticator_); 80 client_.reset(client_as_negotiating_authenticator_);
78 } 81 }
79 82
80 scoped_refptr<PairingRegistry> CreatePairingRegistry( 83 scoped_refptr<PairingRegistry> CreatePairingRegistry(
81 PairingRegistry::Pairing* pairings, size_t num_pairings) { 84 PairingRegistry::Pairing* pairings, size_t num_pairings) {
82 PairingRegistry::PairedClients clients; 85 PairingRegistry::PairedClients clients;
83 for (size_t i = 0; i < num_pairings; ++i) { 86 for (size_t i = 0; i < num_pairings; ++i) {
84 clients[pairings[i].client_id] = pairings[i]; 87 clients[pairings[i].client_id] = pairings[i];
85 } 88 }
86 scoped_refptr<PairingRegistry> result( 89 scoped_refptr<PairingRegistry> result(
87 new PairingRegistry( 90 new PairingRegistry(
88 scoped_ptr<PairingRegistry::Delegate>( 91 scoped_ptr<PairingRegistry::Delegate>(
89 new NotImplementedPairingRegistryDelegate), 92 new NotImplementedPairingRegistryDelegate),
90 clients)); 93 clients));
91 return result; 94 return result;
92 } 95 }
93 96
94 static void FetchSecret( 97 static void FetchSecret(
95 const std::string& client_secret, 98 const std::string& client_secret,
99 bool pairing_supported,
100 bool pairing_expected,
96 const protocol::SecretFetchedCallback& secret_fetched_callback) { 101 const protocol::SecretFetchedCallback& secret_fetched_callback) {
97 secret_fetched_callback.Run(client_secret); 102 secret_fetched_callback.Run(client_secret);
103 ASSERT_EQ(pairing_supported, pairing_expected);
98 } 104 }
99 105
100 void VerifyRejected(Authenticator::RejectionReason reason) { 106 void VerifyRejected(Authenticator::RejectionReason reason) {
101 ASSERT_TRUE(client_->state() == Authenticator::REJECTED || 107 ASSERT_TRUE(client_->state() == Authenticator::REJECTED ||
102 host_->state() == Authenticator::REJECTED); 108 host_->state() == Authenticator::REJECTED);
103 if (client_->state() == Authenticator::REJECTED) { 109 if (client_->state() == Authenticator::REJECTED) {
104 ASSERT_EQ(client_->rejection_reason(), reason); 110 ASSERT_EQ(client_->rejection_reason(), reason);
105 } 111 }
106 if (host_->state() == Authenticator::REJECTED) { 112 if (host_->state() == Authenticator::REJECTED) {
107 ASSERT_EQ(host_->rejection_reason(), reason); 113 ASSERT_EQ(host_->rejection_reason(), reason);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( 254 ASSERT_NO_FATAL_FAILURE(InitAuthenticators(
249 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin, 255 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin,
250 AuthenticationMethod::HMAC_SHA256, false, 256 AuthenticationMethod::HMAC_SHA256, false,
251 CreatePairingRegistry(&pairing, 1))); 257 CreatePairingRegistry(&pairing, 1)));
252 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); 258 ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
253 VerifyRejected(Authenticator::INVALID_CREDENTIALS); 259 VerifyRejected(Authenticator::INVALID_CREDENTIALS);
254 } 260 }
255 261
256 } // namespace protocol 262 } // namespace protocol
257 } // namespace remoting 263 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/authenticator.h ('k') | remoting/protocol/negotiating_client_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698