shill: L2TPIPSecDriver: Don't croak due to intermediate PPPD phases

There are two intermediate pppd phases ("authenticating",
"authenticated") which are non-fatal, but not an indicator of
success either.  Fix the L2TPIPSecDriver to ignore notification
of transitions into these states.

BUG=chromium:271717
TEST=Unit tests

Change-Id: I4ad6f29a37ebc09da034c759b5da1cb1f874fc61
Reviewed-on: https://gerrit.chromium.org/gerrit/65631
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/l2tp_ipsec_driver.cc b/l2tp_ipsec_driver.cc
index 8f6950d..699f007 100644
--- a/l2tp_ipsec_driver.cc
+++ b/l2tp_ipsec_driver.cc
@@ -386,6 +386,12 @@
     const string &reason, const map<string, string> &dict) {
   LOG(INFO) << "IP configuration received: " << reason;
 
+  if (reason == kPPPReasonAuthenticating ||
+      reason == kPPPReasonAuthenticated) {
+    // These are uninteresting intermediate states that do not indicate failure.
+    return;
+  }
+
   if (reason != kPPPReasonConnect) {
     DCHECK_EQ(kPPPReasonDisconnect, reason);
     // DestroyLater, rather than while on stack.
diff --git a/l2tp_ipsec_driver_unittest.cc b/l2tp_ipsec_driver_unittest.cc
index 12831f4..23c5e66 100644
--- a/l2tp_ipsec_driver_unittest.cc
+++ b/l2tp_ipsec_driver_unittest.cc
@@ -572,6 +572,16 @@
   EXPECT_CALL(*mock_ppp_device_factory,
               CreatePPPDevice(_, _, _, _, kInterfaceName, kInterfaceIndex))
       .WillOnce(Return(device_));
+
+  // Make sure that a notification of an intermediate state doesn't cause
+  // the driver to fail the connection.
+  ASSERT_TRUE(driver_->service_);
+  VPNServiceConstRefPtr service = driver_->service_;
+  InvokeNotify(kPPPReasonAuthenticating, config);
+  InvokeNotify(kPPPReasonAuthenticated, config);
+  EXPECT_TRUE(driver_->service_);
+  EXPECT_FALSE(service->IsFailed());
+
   ExpectDeviceConnected(config);
   ExpectMetricsReported();
   InvokeNotify(kPPPReasonConnect, config);