| Index: remoting/protocol/negotiating_authenticator_unittest.cc
|
| diff --git a/remoting/protocol/negotiating_authenticator_unittest.cc b/remoting/protocol/negotiating_authenticator_unittest.cc
|
| index 73daf833286c1d6cce8655186bdf7aceba0d8a0e..b17fa6a1bfd8da621d435e81daee40636c8bf3ef 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) {
|
|
|