Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/openvpn_management_server.h" |
| 6 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 7 | #include <netinet/in.h> |
| 8 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 9 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 10 | #include <gtest/gtest.h> |
| 11 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 12 | #include "shill/glib.h" |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 13 | #include "shill/key_value_store.h" |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 14 | #include "shill/mock_event_dispatcher.h" |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 15 | #include "shill/mock_openvpn_driver.h" |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 16 | #include "shill/mock_sockets.h" |
| 17 | |
| 18 | using std::string; |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 19 | using std::vector; |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 20 | using testing::_; |
| 21 | using testing::Return; |
| 22 | using testing::ReturnNew; |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 23 | |
| 24 | namespace shill { |
| 25 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 26 | namespace { |
| 27 | MATCHER_P(CallbackEq, callback, "") { |
| 28 | return arg.Equals(callback); |
| 29 | } |
| 30 | |
| 31 | MATCHER_P(VoidStringEq, value, "") { |
| 32 | return value == reinterpret_cast<const char *>(arg); |
| 33 | } |
| 34 | } // namespace {} |
| 35 | |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 36 | class OpenVPNManagementServerTest : public testing::Test { |
| 37 | public: |
| 38 | OpenVPNManagementServerTest() |
Paul Stewart | 451aa7f | 2012-04-11 19:07:58 -0700 | [diff] [blame] | 39 | : server_(&driver_, &glib_) {} |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 40 | |
| 41 | virtual ~OpenVPNManagementServerTest() {} |
| 42 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 43 | void SetSockets() { server_.sockets_ = &sockets_; } |
| 44 | void SetDispatcher() { server_.dispatcher_ = &dispatcher_; } |
| 45 | void ExpectNotStarted() { EXPECT_TRUE(server_.sockets_ == NULL); } |
| 46 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 47 | void SetConnectedSocket() { |
| 48 | server_.connected_socket_ = kConnectedSocket; |
| 49 | SetSockets(); |
| 50 | } |
| 51 | |
| 52 | void ExpectSend(const string &value) { |
| 53 | EXPECT_CALL(sockets_, |
| 54 | Send(kConnectedSocket, VoidStringEq(value), value.size(), 0)) |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 55 | .WillOnce(Return(value.size())); |
| 56 | } |
| 57 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 58 | void ExpectStaticChallengeResponse() { |
| 59 | driver_.args()->SetString(flimflam::kOpenVPNUserProperty, "jojo"); |
| 60 | driver_.args()->SetString(flimflam::kOpenVPNPasswordProperty, "yoyo"); |
| 61 | driver_.args()->SetString(flimflam::kOpenVPNOTPProperty, "123456"); |
| 62 | SetConnectedSocket(); |
| 63 | ExpectSend("username \"Auth\" jojo\n"); |
| 64 | ExpectSend("password \"Auth\" \"SCRV1:eW95bw==:MTIzNDU2\"\n"); |
| 65 | } |
| 66 | |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 67 | void ExpectPINResponse() { |
| 68 | driver_.args()->SetString(flimflam::kOpenVPNPinProperty, "987654"); |
| 69 | SetConnectedSocket(); |
| 70 | ExpectSend("password \"User-Specific TPM Token FOO\" \"987654\"\n"); |
| 71 | } |
| 72 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 73 | InputData CreateInputDataFromString(const string &str) { |
| 74 | InputData data( |
| 75 | reinterpret_cast<unsigned char *>(const_cast<char *>(str.data())), |
| 76 | str.size()); |
| 77 | return data; |
| 78 | } |
| 79 | |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 80 | protected: |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 81 | static const int kConnectedSocket; |
| 82 | |
| 83 | GLib glib_; |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 84 | MockOpenVPNDriver driver_; |
| 85 | OpenVPNManagementServer server_; |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 86 | MockSockets sockets_; |
| 87 | MockEventDispatcher dispatcher_; |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 88 | }; |
| 89 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 90 | // static |
| 91 | const int OpenVPNManagementServerTest::kConnectedSocket = 555; |
| 92 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 93 | TEST_F(OpenVPNManagementServerTest, StartStarted) { |
| 94 | SetSockets(); |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 95 | EXPECT_TRUE(server_.Start(NULL, NULL, NULL)); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | TEST_F(OpenVPNManagementServerTest, StartSocketFail) { |
| 99 | EXPECT_CALL(sockets_, Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) |
| 100 | .WillOnce(Return(-1)); |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 101 | EXPECT_FALSE(server_.Start(NULL, &sockets_, NULL)); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 102 | ExpectNotStarted(); |
| 103 | } |
| 104 | |
| 105 | TEST_F(OpenVPNManagementServerTest, StartGetSockNameFail) { |
| 106 | const int kSocket = 123; |
| 107 | EXPECT_CALL(sockets_, Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) |
| 108 | .WillOnce(Return(kSocket)); |
| 109 | EXPECT_CALL(sockets_, Bind(kSocket, _, _)).WillOnce(Return(0)); |
| 110 | EXPECT_CALL(sockets_, Listen(kSocket, 1)).WillOnce(Return(0)); |
| 111 | EXPECT_CALL(sockets_, GetSockName(kSocket, _, _)).WillOnce(Return(-1)); |
| 112 | EXPECT_CALL(sockets_, Close(kSocket)).WillOnce(Return(0)); |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 113 | EXPECT_FALSE(server_.Start(NULL, &sockets_, NULL)); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 114 | ExpectNotStarted(); |
| 115 | } |
| 116 | |
Darin Petkov | 78f6326 | 2012-03-26 01:30:24 +0200 | [diff] [blame] | 117 | TEST_F(OpenVPNManagementServerTest, Start) { |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 118 | const int kSocket = 123; |
| 119 | EXPECT_CALL(sockets_, Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) |
| 120 | .WillOnce(Return(kSocket)); |
| 121 | EXPECT_CALL(sockets_, Bind(kSocket, _, _)).WillOnce(Return(0)); |
| 122 | EXPECT_CALL(sockets_, Listen(kSocket, 1)).WillOnce(Return(0)); |
| 123 | EXPECT_CALL(sockets_, GetSockName(kSocket, _, _)).WillOnce(Return(0)); |
| 124 | EXPECT_CALL(dispatcher_, |
| 125 | CreateReadyHandler(kSocket, IOHandler::kModeInput, |
| 126 | CallbackEq(server_.ready_callback_))) |
| 127 | .WillOnce(ReturnNew<IOHandler>()); |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 128 | vector<string> options; |
| 129 | EXPECT_TRUE(server_.Start(&dispatcher_, &sockets_, &options)); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 130 | EXPECT_EQ(&sockets_, server_.sockets_); |
| 131 | EXPECT_EQ(kSocket, server_.socket_); |
| 132 | EXPECT_TRUE(server_.ready_handler_.get()); |
| 133 | EXPECT_EQ(&dispatcher_, server_.dispatcher_); |
Darin Petkov | 4646302 | 2012-03-29 14:57:32 +0200 | [diff] [blame] | 134 | EXPECT_FALSE(options.empty()); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | TEST_F(OpenVPNManagementServerTest, Stop) { |
| 138 | SetSockets(); |
| 139 | server_.input_handler_.reset(new IOHandler()); |
| 140 | const int kConnectedSocket = 234; |
| 141 | server_.connected_socket_ = kConnectedSocket; |
| 142 | EXPECT_CALL(sockets_, Close(kConnectedSocket)).WillOnce(Return(0)); |
| 143 | SetDispatcher(); |
| 144 | server_.ready_handler_.reset(new IOHandler()); |
| 145 | const int kSocket = 345; |
| 146 | server_.socket_ = kSocket; |
| 147 | EXPECT_CALL(sockets_, Close(kSocket)).WillOnce(Return(0)); |
| 148 | server_.Stop(); |
| 149 | EXPECT_FALSE(server_.input_handler_.get()); |
| 150 | EXPECT_EQ(-1, server_.connected_socket_); |
| 151 | EXPECT_FALSE(server_.dispatcher_); |
| 152 | EXPECT_FALSE(server_.ready_handler_.get()); |
| 153 | EXPECT_EQ(-1, server_.socket_); |
| 154 | ExpectNotStarted(); |
| 155 | } |
| 156 | |
| 157 | TEST_F(OpenVPNManagementServerTest, OnReadyAcceptFail) { |
| 158 | const int kSocket = 333; |
| 159 | SetSockets(); |
| 160 | EXPECT_CALL(sockets_, Accept(kSocket, NULL, NULL)).WillOnce(Return(-1)); |
| 161 | server_.OnReady(kSocket); |
| 162 | EXPECT_EQ(-1, server_.connected_socket_); |
| 163 | } |
| 164 | |
| 165 | TEST_F(OpenVPNManagementServerTest, OnReady) { |
| 166 | const int kSocket = 111; |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 167 | SetConnectedSocket(); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 168 | SetDispatcher(); |
| 169 | EXPECT_CALL(sockets_, Accept(kSocket, NULL, NULL)) |
| 170 | .WillOnce(Return(kConnectedSocket)); |
| 171 | server_.ready_handler_.reset(new IOHandler()); |
| 172 | EXPECT_CALL(dispatcher_, |
| 173 | CreateInputHandler(kConnectedSocket, |
| 174 | CallbackEq(server_.input_callback_))) |
| 175 | .WillOnce(ReturnNew<IOHandler>()); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 176 | ExpectSend("state on\n"); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 177 | server_.OnReady(kSocket); |
| 178 | EXPECT_EQ(kConnectedSocket, server_.connected_socket_); |
| 179 | EXPECT_FALSE(server_.ready_handler_.get()); |
| 180 | EXPECT_TRUE(server_.input_handler_.get()); |
| 181 | } |
| 182 | |
| 183 | TEST_F(OpenVPNManagementServerTest, OnInput) { |
| 184 | { |
| 185 | string s; |
| 186 | InputData data = CreateInputDataFromString(s); |
| 187 | server_.OnInput(&data); |
| 188 | } |
| 189 | { |
| 190 | string s = "foo\n" |
| 191 | ">INFO:...\n" |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 192 | ">PASSWORD:Need 'Auth' SC:user/password/otp\n" |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 193 | ">PASSWORD:Need 'User-Specific TPM Token FOO' ...\n" |
Darin Petkov | 0440b9b | 2012-04-17 16:11:56 +0200 | [diff] [blame^] | 194 | ">PASSWORD:Verification Failed: .\n" |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 195 | ">STATE:123,RECONNECTING,detail,...,..."; |
| 196 | InputData data = CreateInputDataFromString(s); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 197 | ExpectStaticChallengeResponse(); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 198 | ExpectPINResponse(); |
Darin Petkov | 0440b9b | 2012-04-17 16:11:56 +0200 | [diff] [blame^] | 199 | EXPECT_CALL(driver_, Cleanup(Service::kStateFailure)); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 200 | EXPECT_CALL(driver_, OnReconnecting()); |
| 201 | server_.OnInput(&data); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | TEST_F(OpenVPNManagementServerTest, ProcessMessage) { |
| 206 | server_.ProcessMessage("foo"); |
| 207 | server_.ProcessMessage(">INFO:"); |
| 208 | |
| 209 | EXPECT_CALL(driver_, OnReconnecting()); |
| 210 | server_.ProcessMessage(">STATE:123,RECONNECTING,detail,...,..."); |
| 211 | } |
| 212 | |
| 213 | TEST_F(OpenVPNManagementServerTest, ProcessInfoMessage) { |
| 214 | EXPECT_FALSE(server_.ProcessInfoMessage("foo")); |
| 215 | EXPECT_TRUE(server_.ProcessInfoMessage(">INFO:")); |
| 216 | } |
| 217 | |
| 218 | TEST_F(OpenVPNManagementServerTest, ProcessStateMessage) { |
| 219 | EXPECT_FALSE(server_.ProcessStateMessage("foo")); |
| 220 | EXPECT_TRUE(server_.ProcessStateMessage(">STATE:123,WAIT,detail,...,...")); |
| 221 | EXPECT_CALL(driver_, OnReconnecting()); |
| 222 | EXPECT_TRUE( |
| 223 | server_.ProcessStateMessage(">STATE:123,RECONNECTING,detail,...,...")); |
| 224 | } |
| 225 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 226 | TEST_F(OpenVPNManagementServerTest, ProcessNeedPasswordMessageAuthSC) { |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 227 | ExpectStaticChallengeResponse(); |
| 228 | EXPECT_TRUE( |
| 229 | server_.ProcessNeedPasswordMessage( |
| 230 | ">PASSWORD:Need 'Auth' SC:user/password/otp")); |
| 231 | EXPECT_FALSE(driver_.args()->ContainsString(flimflam::kOpenVPNOTPProperty)); |
| 232 | } |
| 233 | |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 234 | TEST_F(OpenVPNManagementServerTest, ProcessNeedPasswordMessageTPMToken) { |
| 235 | ExpectPINResponse(); |
| 236 | EXPECT_TRUE( |
| 237 | server_.ProcessNeedPasswordMessage( |
| 238 | ">PASSWORD:Need 'User-Specific TPM Token FOO' ...")); |
| 239 | } |
| 240 | |
| 241 | TEST_F(OpenVPNManagementServerTest, ProcessNeedPasswordMessageUnknown) { |
| 242 | EXPECT_FALSE(server_.ProcessNeedPasswordMessage("foo")); |
| 243 | } |
| 244 | |
| 245 | TEST_F(OpenVPNManagementServerTest, ParseNeedPasswordTag) { |
| 246 | EXPECT_EQ("", OpenVPNManagementServer::ParseNeedPasswordTag("")); |
| 247 | EXPECT_EQ("", OpenVPNManagementServer::ParseNeedPasswordTag(" ")); |
| 248 | EXPECT_EQ("", OpenVPNManagementServer::ParseNeedPasswordTag("'")); |
| 249 | EXPECT_EQ("", OpenVPNManagementServer::ParseNeedPasswordTag("''")); |
| 250 | EXPECT_EQ("bar", |
| 251 | OpenVPNManagementServer::ParseNeedPasswordTag("foo'bar'zoo")); |
| 252 | EXPECT_EQ("bar", OpenVPNManagementServer::ParseNeedPasswordTag("foo'bar'")); |
| 253 | EXPECT_EQ("bar", OpenVPNManagementServer::ParseNeedPasswordTag("'bar'zoo")); |
| 254 | EXPECT_EQ("bar", |
| 255 | OpenVPNManagementServer::ParseNeedPasswordTag("foo'bar'zoo'moo")); |
| 256 | } |
| 257 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 258 | TEST_F(OpenVPNManagementServerTest, PerformStaticChallengeNoCreds) { |
Darin Petkov | 0440b9b | 2012-04-17 16:11:56 +0200 | [diff] [blame^] | 259 | EXPECT_CALL(driver_, Cleanup(Service::kStateFailure)).Times(3); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 260 | server_.PerformStaticChallenge("Auth"); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 261 | driver_.args()->SetString(flimflam::kOpenVPNUserProperty, "jojo"); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 262 | server_.PerformStaticChallenge("Auth"); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 263 | driver_.args()->SetString(flimflam::kOpenVPNPasswordProperty, "yoyo"); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 264 | server_.PerformStaticChallenge("Auth"); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | TEST_F(OpenVPNManagementServerTest, PerformStaticChallenge) { |
| 268 | ExpectStaticChallengeResponse(); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 269 | server_.PerformStaticChallenge("Auth"); |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 270 | EXPECT_FALSE(driver_.args()->ContainsString(flimflam::kOpenVPNOTPProperty)); |
| 271 | } |
| 272 | |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 273 | TEST_F(OpenVPNManagementServerTest, SupplyTPMTokenNoPIN) { |
Darin Petkov | 0440b9b | 2012-04-17 16:11:56 +0200 | [diff] [blame^] | 274 | EXPECT_CALL(driver_, Cleanup(Service::kStateFailure)); |
Darin Petkov | e0d5dd1 | 2012-04-04 16:10:48 +0200 | [diff] [blame] | 275 | server_.SupplyTPMToken("User-Specific TPM Token FOO"); |
| 276 | } |
| 277 | |
| 278 | TEST_F(OpenVPNManagementServerTest, SupplyTPMToken) { |
| 279 | ExpectPINResponse(); |
| 280 | server_.SupplyTPMToken("User-Specific TPM Token FOO"); |
| 281 | } |
| 282 | |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 283 | TEST_F(OpenVPNManagementServerTest, Send) { |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 284 | const char kMessage[] = "foo\n"; |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 285 | SetConnectedSocket(); |
| 286 | ExpectSend(kMessage); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 287 | server_.Send(kMessage); |
| 288 | } |
| 289 | |
| 290 | TEST_F(OpenVPNManagementServerTest, SendState) { |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 291 | SetConnectedSocket(); |
| 292 | ExpectSend("state off\n"); |
Darin Petkov | 271fe52 | 2012-03-27 13:47:29 +0200 | [diff] [blame] | 293 | server_.SendState("off"); |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 294 | } |
| 295 | |
Darin Petkov | 683942b | 2012-03-27 18:00:04 +0200 | [diff] [blame] | 296 | TEST_F(OpenVPNManagementServerTest, SendUsername) { |
| 297 | SetConnectedSocket(); |
| 298 | ExpectSend("username \"Auth\" joesmith\n"); |
| 299 | server_.SendUsername("Auth", "joesmith"); |
| 300 | } |
| 301 | |
| 302 | TEST_F(OpenVPNManagementServerTest, SendPassword) { |
| 303 | SetConnectedSocket(); |
| 304 | ExpectSend("password \"Auth\" \"foobar\"\n"); |
| 305 | server_.SendPassword("Auth", "foobar"); |
| 306 | } |
| 307 | |
Darin Petkov | 0440b9b | 2012-04-17 16:11:56 +0200 | [diff] [blame^] | 308 | TEST_F(OpenVPNManagementServerTest, ProcessFailedPasswordMessage) { |
| 309 | EXPECT_FALSE(server_.ProcessFailedPasswordMessage("foo")); |
| 310 | EXPECT_CALL(driver_, Cleanup(Service::kStateFailure)); |
| 311 | EXPECT_TRUE( |
| 312 | server_.ProcessFailedPasswordMessage(">PASSWORD:Verification Failed: .")); |
| 313 | } |
| 314 | |
Darin Petkov | 1c11520 | 2012-03-22 15:35:47 +0100 | [diff] [blame] | 315 | } // namespace shill |