shill: vpn: Register L2TP/IPSec properties.

Also, add some sanity tests for property store setup in VPNDriver subclasses.

BUG=chromium-os:29362,chromium-os:29363
TEST=unit tests

Change-Id: I144b9b810d201655e872558d29df2394ce5b345a
Reviewed-on: https://gerrit.chromium.org/gerrit/20839
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/l2tp_ipsec_driver.cc b/l2tp_ipsec_driver.cc
index 43eb31e..4feb427 100644
--- a/l2tp_ipsec_driver.cc
+++ b/l2tp_ipsec_driver.cc
@@ -35,12 +35,32 @@
 
 // static
 const char L2TPIPSecDriver::kPPPDPlugin[] = SCRIPTDIR "/libppp-plugin.so";
+// static
 const char L2TPIPSecDriver::kL2TPIPSecVPNPath[] = "/usr/sbin/l2tpipsec_vpn";
+// static
+const VPNDriver::Property L2TPIPSecDriver::kProperties[] = {
+  { flimflam::kL2tpIpsecCaCertNssProperty, 0 },
+  { flimflam::kL2tpIpsecClientCertIdProperty, 0 },
+  { flimflam::kL2tpIpsecClientCertSlotProperty, 0 },
+  { flimflam::kL2tpIpsecPasswordProperty, Property::kCrypted },
+  { flimflam::kL2tpIpsecPinProperty, Property::kEphemeral },
+  { flimflam::kL2tpIpsecPskProperty, Property::kCrypted },
+  { flimflam::kL2tpIpsecUserProperty, 0 },
+  { kL2TPIPSecIPSecTimeoutProperty, 0 },
+  { kL2TPIPSecLeftProtoPortProperty, 0 },
+  { kL2TPIPSecLengthBitProperty, 0 },
+  { kL2TPIPSecPFSProperty, 0 },
+  { kL2TPIPSecRefusePapProperty, 0 },
+  { kL2TPIPSecRekeyProperty, 0 },
+  { kL2TPIPSecRequireAuthProperty, 0 },
+  { kL2TPIPSecRequireChapProperty, 0 },
+  { kL2TPIPSecRightProtoPortProperty, 0 },
+};
 
 L2TPIPSecDriver::L2TPIPSecDriver(ControlInterface *control,
                                  Manager *manager,
                                  GLib *glib)
-    : VPNDriver(NULL, 0),
+    : VPNDriver(kProperties, arraysize(kProperties)),
       control_(control),
       manager_(manager),
       glib_(glib),
diff --git a/l2tp_ipsec_driver.h b/l2tp_ipsec_driver.h
index 26bca60..450e897 100644
--- a/l2tp_ipsec_driver.h
+++ b/l2tp_ipsec_driver.h
@@ -50,8 +50,10 @@
   FRIEND_TEST(L2TPIPSecDriverTest, InitPSKOptions);
   FRIEND_TEST(L2TPIPSecDriverTest, OnL2TPIPSecVPNDied);
   FRIEND_TEST(L2TPIPSecDriverTest, SpawnL2TPIPSecVPN);
+
   static const char kPPPDPlugin[];
   static const char kL2TPIPSecVPNPath[];
+  static const Property kProperties[];
 
   bool SpawnL2TPIPSecVPN(Error *error);
 
diff --git a/l2tp_ipsec_driver_unittest.cc b/l2tp_ipsec_driver_unittest.cc
index d3daa75..e231d92 100644
--- a/l2tp_ipsec_driver_unittest.cc
+++ b/l2tp_ipsec_driver_unittest.cc
@@ -59,6 +59,10 @@
     driver_->args_.SetString(arg, value);
   }
 
+  KeyValueStore *GetArgs() {
+    return driver_->args();
+  }
+
   // Used to assert that a flag appears in the options.
   void ExpectInFlags(const vector<string> &options, const string &flag,
                      const string &value);
@@ -363,4 +367,16 @@
   EXPECT_TRUE(error.IsSuccess());
 }
 
+TEST_F(L2TPIPSecDriverTest, InitPropertyStore) {
+  // Sanity test property store initialization.
+  PropertyStore store;
+  driver_->InitPropertyStore(&store);
+  const string kUser = "joe";
+  Error error;
+  EXPECT_TRUE(
+      store.SetStringProperty(flimflam::kL2tpIpsecUserProperty, kUser, &error));
+  EXPECT_TRUE(error.IsSuccess());
+  EXPECT_EQ(kUser, GetArgs()->GetString(flimflam::kL2tpIpsecUserProperty));
+}
+
 }  // namespace shill
diff --git a/openvpn_driver.cc b/openvpn_driver.cc
index 226fb78..a7bfe51 100644
--- a/openvpn_driver.cc
+++ b/openvpn_driver.cc
@@ -62,7 +62,7 @@
 // static
 const char OpenVPNDriver::kOpenVPNScript[] = SCRIPTDIR "/openvpn-script";
 // static
-const OpenVPNDriver::Property OpenVPNDriver::kProperties[] = {
+const VPNDriver::Property OpenVPNDriver::kProperties[] = {
   { flimflam::kOpenVPNAuthNoCacheProperty, 0 },
   { flimflam::kOpenVPNAuthProperty, 0 },
   { flimflam::kOpenVPNAuthRetryProperty, 0 },
diff --git a/openvpn_driver_unittest.cc b/openvpn_driver_unittest.cc
index cad9542..75ed2be 100644
--- a/openvpn_driver_unittest.cc
+++ b/openvpn_driver_unittest.cc
@@ -643,4 +643,16 @@
   EXPECT_TRUE(file_util::PathExists(FilePath(SYSROOT).Append(vpn_script)));
 }
 
+TEST_F(OpenVPNDriverTest, InitPropertyStore) {
+  // Sanity test property store initialization.
+  PropertyStore store;
+  driver_->InitPropertyStore(&store);
+  const string kUser = "joe";
+  Error error;
+  EXPECT_TRUE(
+      store.SetStringProperty(flimflam::kOpenVPNUserProperty, kUser, &error));
+  EXPECT_TRUE(error.IsSuccess());
+  EXPECT_EQ(kUser, GetArgs()->GetString(flimflam::kOpenVPNUserProperty));
+}
+
 }  // namespace shill