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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
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 "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ptr_util.h"
7 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
8 #include "remoting/base/rsa_key_pair.h" 9 #include "remoting/base/rsa_key_pair.h"
9 #include "remoting/protocol/auth_util.h" 10 #include "remoting/protocol/auth_util.h"
10 #include "remoting/protocol/authenticator_test_base.h" 11 #include "remoting/protocol/authenticator_test_base.h"
11 #include "remoting/protocol/channel_authenticator.h" 12 #include "remoting/protocol/channel_authenticator.h"
12 #include "remoting/protocol/connection_tester.h" 13 #include "remoting/protocol/connection_tester.h"
13 #include "remoting/protocol/negotiating_authenticator_base.h" 14 #include "remoting/protocol/negotiating_authenticator_base.h"
14 #include "remoting/protocol/negotiating_client_authenticator.h" 15 #include "remoting/protocol/negotiating_client_authenticator.h"
15 #include "remoting/protocol/negotiating_host_authenticator.h" 16 #include "remoting/protocol/negotiating_host_authenticator.h"
16 #include "remoting/protocol/pairing_registry.h" 17 #include "remoting/protocol/pairing_registry.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 NegotiatingAuthenticatorTest() {} 53 NegotiatingAuthenticatorTest() {}
53 ~NegotiatingAuthenticatorTest() override {} 54 ~NegotiatingAuthenticatorTest() override {}
54 55
55 protected: 56 protected:
56 virtual void InitAuthenticators(const std::string& client_id, 57 virtual void InitAuthenticators(const std::string& client_id,
57 const std::string& client_paired_secret, 58 const std::string& client_paired_secret,
58 const std::string& client_interactive_pin, 59 const std::string& client_interactive_pin,
59 const std::string& host_secret) { 60 const std::string& host_secret) {
60 std::string host_secret_hash = 61 std::string host_secret_hash =
61 GetSharedSecretHash(kTestHostId, host_secret); 62 GetSharedSecretHash(kTestHostId, host_secret);
62 scoped_ptr<NegotiatingHostAuthenticator> host = 63 std::unique_ptr<NegotiatingHostAuthenticator> host =
63 NegotiatingHostAuthenticator::CreateWithSharedSecret( 64 NegotiatingHostAuthenticator::CreateWithSharedSecret(
64 kHostJid, kClientJid, host_cert_, key_pair_, host_secret_hash, 65 kHostJid, kClientJid, host_cert_, key_pair_, host_secret_hash,
65 pairing_registry_); 66 pairing_registry_);
66 host_as_negotiating_authenticator_ = host.get(); 67 host_as_negotiating_authenticator_ = host.get();
67 host_ = std::move(host); 68 host_ = std::move(host);
68 69
69 protocol::ClientAuthenticationConfig client_auth_config; 70 protocol::ClientAuthenticationConfig client_auth_config;
70 client_auth_config.host_id = kTestHostId; 71 client_auth_config.host_id = kTestHostId;
71 client_auth_config.pairing_client_id = client_id; 72 client_auth_config.pairing_client_id = client_id;
72 client_auth_config.pairing_secret = client_paired_secret; 73 client_auth_config.pairing_secret = client_paired_secret;
(...skipping 15 matching lines...) Expand all
88 89
89 void DisableMethodOnHost(NegotiatingAuthenticatorBase::Method method) { 90 void DisableMethodOnHost(NegotiatingAuthenticatorBase::Method method) {
90 auto* methods = &(host_as_negotiating_authenticator_->methods_); 91 auto* methods = &(host_as_negotiating_authenticator_->methods_);
91 auto iter = std::find(methods->begin(), methods->end(), method); 92 auto iter = std::find(methods->begin(), methods->end(), method);
92 ASSERT_TRUE(iter != methods->end()); 93 ASSERT_TRUE(iter != methods->end());
93 methods->erase(iter); 94 methods->erase(iter);
94 } 95 }
95 96
96 void CreatePairingRegistry(bool with_paired_client) { 97 void CreatePairingRegistry(bool with_paired_client) {
97 pairing_registry_ = new SynchronousPairingRegistry( 98 pairing_registry_ = new SynchronousPairingRegistry(
98 make_scoped_ptr(new MockPairingRegistryDelegate())); 99 base::WrapUnique(new MockPairingRegistryDelegate()));
99 if (with_paired_client) { 100 if (with_paired_client) {
100 PairingRegistry::Pairing pairing( 101 PairingRegistry::Pairing pairing(
101 base::Time(), kTestClientName, kTestClientId, kTestPairedSecret); 102 base::Time(), kTestClientName, kTestClientId, kTestPairedSecret);
102 pairing_registry_->AddPairing(pairing); 103 pairing_registry_->AddPairing(pairing);
103 } 104 }
104 } 105 }
105 106
106 static void FetchSecret( 107 static void FetchSecret(
107 const std::string& client_secret, 108 const std::string& client_secret,
108 bool pairing_supported, 109 bool pairing_supported,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 TEST_P(NegotiatingPairingAuthenticatorTest, PairingFailedInvalidSecretAndPin) { 309 TEST_P(NegotiatingPairingAuthenticatorTest, PairingFailedInvalidSecretAndPin) {
309 CreatePairingRegistry(true); 310 CreatePairingRegistry(true);
310 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( 311 ASSERT_NO_FATAL_FAILURE(InitAuthenticators(
311 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin)); 312 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin));
312 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); 313 ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
313 VerifyRejected(Authenticator::INVALID_CREDENTIALS); 314 VerifyRejected(Authenticator::INVALID_CREDENTIALS);
314 } 315 }
315 316
316 } // namespace protocol 317 } // namespace protocol
317 } // namespace remoting 318 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_authenticator_base.cc ('k') | remoting/protocol/negotiating_client_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698