diff options
author | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 18:39:13 +0000 |
---|---|---|
committer | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 18:39:13 +0000 |
commit | 21257525cd0e90c87d1f94e8c18c3204229d9651 (patch) | |
tree | 0a00ca66eb7943607c100f4eb838d3ce19f5feda /remoting/protocol/negotiating_authenticator_unittest.cc | |
parent | 2d401ff88410a222791306b4410d1d3ee60f6f20 (diff) | |
download | chromium_src-21257525cd0e90c87d1f94e8c18c3204229d9651.zip chromium_src-21257525cd0e90c87d1f94e8c18c3204229d9651.tar.gz chromium_src-21257525cd0e90c87d1f94e8c18c3204229d9651.tar.bz2 |
Protocol / client plugin changes to support interactively asking for a PIN.
This has a few special cases, to be able to deal with all sorts of combinations of Me2Me/It2Me/old-plugin/old-webapp/old-host.
The idea is: A webapp that supports asking for PINs asynchronously will explicitly notify the plugin of that. Older webapps (or It2Me) will send the passphrase directly on connect.
The negotiating authenticator, instead of immediately trying to send the first SPAKE message, first sends a message with the supported methods to the host, and only when the host replies with the specific method it tries to create the authenticator. If there is a PinFetcher interface, it tries to use a PinClientAuthenticator (a thin layer on top of V2Authenticator that takes care of asynchronously asking for PIN), otherwise it uses V2Authenticator directly with the pre-provided pass phrase.
This also adds support for authenticators that can't be created in a particular state (e.g. ones for which the first message must go in one particular direction). The NegotiatingAuthenticator takes care of sending blank messages/ignoring those messages as appropriate.
BUG=115899
Review URL: https://chromiumcodereview.appspot.com/12518027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/negotiating_authenticator_unittest.cc')
-rw-r--r-- | remoting/protocol/negotiating_authenticator_unittest.cc | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/remoting/protocol/negotiating_authenticator_unittest.cc b/remoting/protocol/negotiating_authenticator_unittest.cc index 73daf83..b17fa6a 100644 --- a/remoting/protocol/negotiating_authenticator_unittest.cc +++ b/remoting/protocol/negotiating_authenticator_unittest.cc @@ -59,9 +59,15 @@ class NegotiatingAuthenticatorTest : public AuthenticatorTestBase { AuthenticationMethod::NONE)); } client_ = NegotiatingAuthenticator::CreateForClient( - kTestHostId, client_secret, methods); + kTestHostId, base::Bind(&NegotiatingAuthenticatorTest::FetchSecret, + client_secret), methods); } + static void FetchSecret( + const std::string& client_secret, + const protocol::SecretFetchedCallback& secret_fetched_callback) { + secret_fetched_callback.Run(client_secret); + } void VerifyRejected(Authenticator::RejectionReason reason) { ASSERT_TRUE((client_->state() == Authenticator::REJECTED && (client_->rejection_reason() == reason)) || @@ -69,6 +75,28 @@ class NegotiatingAuthenticatorTest : public AuthenticatorTestBase { (host_->rejection_reason() == reason))); } + void VerifyAccepted() { + ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); + + ASSERT_EQ(Authenticator::ACCEPTED, host_->state()); + ASSERT_EQ(Authenticator::ACCEPTED, client_->state()); + + client_auth_ = client_->CreateChannelAuthenticator(); + host_auth_ = host_->CreateChannelAuthenticator(); + RunChannelAuth(false); + + EXPECT_TRUE(client_socket_.get() != NULL); + EXPECT_TRUE(host_socket_.get() != NULL); + + StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), + kMessageSize, kMessages); + + tester.Start(); + message_loop_.Run(); + tester.CheckResults(); + } + + private: DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticatorTest); }; @@ -76,48 +104,14 @@ TEST_F(NegotiatingAuthenticatorTest, SuccessfulAuthHmac) { ASSERT_NO_FATAL_FAILURE(InitAuthenticators( kTestSharedSecret, kTestSharedSecret, AuthenticationMethod::HMAC_SHA256, false)); - ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); - - ASSERT_EQ(Authenticator::ACCEPTED, host_->state()); - ASSERT_EQ(Authenticator::ACCEPTED, client_->state()); - - client_auth_ = client_->CreateChannelAuthenticator(); - host_auth_ = host_->CreateChannelAuthenticator(); - RunChannelAuth(false); - - EXPECT_TRUE(client_socket_.get() != NULL); - EXPECT_TRUE(host_socket_.get() != NULL); - - StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), - kMessageSize, kMessages); - - tester.Start(); - message_loop_.Run(); - tester.CheckResults(); + VerifyAccepted(); } TEST_F(NegotiatingAuthenticatorTest, SuccessfulAuthPlain) { ASSERT_NO_FATAL_FAILURE(InitAuthenticators( kTestSharedSecret, kTestSharedSecret, AuthenticationMethod::NONE, false)); - ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); - - ASSERT_EQ(Authenticator::ACCEPTED, host_->state()); - ASSERT_EQ(Authenticator::ACCEPTED, client_->state()); - - client_auth_ = client_->CreateChannelAuthenticator(); - host_auth_ = host_->CreateChannelAuthenticator(); - RunChannelAuth(false); - - EXPECT_TRUE(client_socket_.get() != NULL); - EXPECT_TRUE(host_socket_.get() != NULL); - - StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), - kMessageSize, kMessages); - - tester.Start(); - message_loop_.Run(); - tester.CheckResults(); + VerifyAccepted(); } TEST_F(NegotiatingAuthenticatorTest, InvalidSecretHmac) { |