shill: WiFiService: Report the security of the connected endpoint

Two recent changes have caused the security_ field of a WiFi
service to be the generic form (e.g., WPA -> PSK) to allow
for proper connectivity.  However it is useful to display the
exact form of security for an associated connection.  Change
WiFiService to report the security of the connected endpoint
if one is available.

BUG=chromium-os:39813
TEST=Unit tests + manual: Connect to a WPA2 AP and ensure that
the security type in list-services and the UI switches from
"psk" to "rsn".

Change-Id: I66efec3685c6a49275f91fa2b5e4af37db680de3
Reviewed-on: https://gerrit.chromium.org/gerrit/45378
Commit-Queue: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/wifi_service_unittest.cc b/wifi_service_unittest.cc
index 4eff667..4b18730 100644
--- a/wifi_service_unittest.cc
+++ b/wifi_service_unittest.cc
@@ -1440,6 +1440,19 @@
   service->RemoveEndpoint(ok_endpoint);
 }
 
+TEST_F(WiFiServiceTest, SecurityFromCurrentEndpoint) {
+  WiFiServiceRefPtr service(MakeSimpleService(flimflam::kSecurityPsk));
+  EXPECT_EQ(flimflam::kSecurityPsk, service->GetSecurity(NULL));
+  WiFiEndpoint *endpoint = MakeOpenEndpoint(
+        simple_ssid_string(), "00:00:00:00:00:00", 0, 0);
+  service->AddEndpoint(endpoint);
+  EXPECT_EQ(flimflam::kSecurityPsk, service->GetSecurity(NULL));
+  service->NotifyCurrentEndpoint(endpoint);
+  EXPECT_EQ(flimflam::kSecurityNone, service->GetSecurity(NULL));
+  service->NotifyCurrentEndpoint(NULL);
+  EXPECT_EQ(flimflam::kSecurityPsk, service->GetSecurity(NULL));
+}
+
 TEST_F(WiFiServiceTest, UpdateSecurity) {
   // Cleartext and pre-shared-key crypto.
   {