Commit 8b80186e authored by achuith@chromium.org's avatar achuith@chromium.org

Add stub passcode option to LoadOncNetworks.

Along with file contents, need to send in a passcode string for decrypting encrypted onc files. The decrypt implementation will be handled by gspencer@

BUG=chromium-os:19397
TEST=compiles.

Review URL: http://codereview.chromium.org/8759007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112783 0039d316-1c4b-4281-b951-d872f2087c98
parent 63a1b749
...@@ -155,7 +155,7 @@ class MockNetworkLibrary : public NetworkLibrary { ...@@ -155,7 +155,7 @@ class MockNetworkLibrary : public NetworkLibrary {
HardwareAddressFormat)); HardwareAddressFormat));
MOCK_METHOD1(SetIPConfig, void(const NetworkIPConfig&)); MOCK_METHOD1(SetIPConfig, void(const NetworkIPConfig&));
MOCK_METHOD0(SwitchToPreferredNetwork, void(void)); MOCK_METHOD0(SwitchToPreferredNetwork, void(void));
MOCK_METHOD1(LoadOncNetworks, bool(const std::string&)); MOCK_METHOD2(LoadOncNetworks, bool(const std::string&, const std::string&));
MOCK_METHOD2(SetActiveNetwork, bool(ConnectionType, const std::string&)); MOCK_METHOD2(SetActiveNetwork, bool(ConnectionType, const std::string&));
}; };
......
...@@ -1730,7 +1730,8 @@ class NetworkLibraryImplBase : public NetworkLibrary { ...@@ -1730,7 +1730,8 @@ class NetworkLibraryImplBase : public NetworkLibrary {
// virtual GetIPConfigs implemented in derived classes. // virtual GetIPConfigs implemented in derived classes.
// virtual SetIPConfig implemented in derived classes. // virtual SetIPConfig implemented in derived classes.
virtual void SwitchToPreferredNetwork() OVERRIDE; virtual void SwitchToPreferredNetwork() OVERRIDE;
virtual bool LoadOncNetworks(const std::string& onc_blob) OVERRIDE; virtual bool LoadOncNetworks(const std::string& onc_blob,
const std::string& passcode) OVERRIDE;
virtual bool SetActiveNetwork(ConnectionType type, virtual bool SetActiveNetwork(ConnectionType type,
const std::string& service_path) OVERRIDE; const std::string& service_path) OVERRIDE;
...@@ -2818,7 +2819,9 @@ void NetworkLibraryImplBase::SwitchToPreferredNetwork() { ...@@ -2818,7 +2819,9 @@ void NetworkLibraryImplBase::SwitchToPreferredNetwork() {
} }
} }
bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob) { bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
const std::string& passcode) {
// TODO(gspencer): Add support for decrypting onc files. crbug.com/19397
OncNetworkParser parser(onc_blob); OncNetworkParser parser(onc_blob);
for (int i = 0; i < parser.GetCertificatesSize(); i++) { for (int i = 0; i < parser.GetCertificatesSize(); i++) {
...@@ -5076,7 +5079,7 @@ void NetworkLibraryImplStub::Init() { ...@@ -5076,7 +5079,7 @@ void NetworkLibraryImplStub::Init() {
" ]," " ],"
" \"Certificates\": []" " \"Certificates\": []"
"}"); "}");
LoadOncNetworks(test_blob); LoadOncNetworks(test_blob, "");
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
......
...@@ -1367,7 +1367,7 @@ class NetworkLibrary { ...@@ -1367,7 +1367,7 @@ class NetworkLibrary {
// for example, networks have appeared or disappeared. // for example, networks have appeared or disappeared.
virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0;
protected: protected:
~NetworkManagerObserver() { } virtual ~NetworkManagerObserver() { }
}; };
class NetworkObserver { class NetworkObserver {
...@@ -1377,7 +1377,7 @@ class NetworkLibrary { ...@@ -1377,7 +1377,7 @@ class NetworkLibrary {
virtual void OnNetworkChanged(NetworkLibrary* cros, virtual void OnNetworkChanged(NetworkLibrary* cros,
const Network* network) = 0; const Network* network) = 0;
protected: protected:
~NetworkObserver() {} virtual ~NetworkObserver() {}
}; };
class NetworkDeviceObserver { class NetworkDeviceObserver {
...@@ -1394,7 +1394,7 @@ class NetworkLibrary { ...@@ -1394,7 +1394,7 @@ class NetworkLibrary {
virtual void OnNetworkDeviceSimLockChanged(NetworkLibrary* cros, virtual void OnNetworkDeviceSimLockChanged(NetworkLibrary* cros,
const NetworkDevice* device) {} const NetworkDevice* device) {}
protected: protected:
~NetworkDeviceObserver() {} virtual ~NetworkDeviceObserver() {}
}; };
class CellularDataPlanObserver { class CellularDataPlanObserver {
...@@ -1402,7 +1402,7 @@ class NetworkLibrary { ...@@ -1402,7 +1402,7 @@ class NetworkLibrary {
// Called when the cellular data plan has changed. // Called when the cellular data plan has changed.
virtual void OnCellularDataPlanChanged(NetworkLibrary* obj) = 0; virtual void OnCellularDataPlanChanged(NetworkLibrary* obj) = 0;
protected: protected:
~CellularDataPlanObserver() {} virtual ~CellularDataPlanObserver() {}
}; };
class PinOperationObserver { class PinOperationObserver {
...@@ -1412,7 +1412,7 @@ class NetworkLibrary { ...@@ -1412,7 +1412,7 @@ class NetworkLibrary {
virtual void OnPinOperationCompleted(NetworkLibrary* cros, virtual void OnPinOperationCompleted(NetworkLibrary* cros,
PinOperationError error) = 0; PinOperationError error) = 0;
protected: protected:
~PinOperationObserver() {} virtual ~PinOperationObserver() {}
}; };
class UserActionObserver { class UserActionObserver {
...@@ -1422,7 +1422,7 @@ class NetworkLibrary { ...@@ -1422,7 +1422,7 @@ class NetworkLibrary {
virtual void OnConnectionInitiated(NetworkLibrary* cros, virtual void OnConnectionInitiated(NetworkLibrary* cros,
const Network* network) = 0; const Network* network) = 0;
protected: protected:
~UserActionObserver() {} virtual ~UserActionObserver() {}
}; };
virtual ~NetworkLibrary() {} virtual ~NetworkLibrary() {}
...@@ -1743,7 +1743,8 @@ class NetworkLibrary { ...@@ -1743,7 +1743,8 @@ class NetworkLibrary {
virtual void SwitchToPreferredNetwork() = 0; virtual void SwitchToPreferredNetwork() = 0;
// Load networks from an Open Network Configuration blob. // Load networks from an Open Network Configuration blob.
virtual bool LoadOncNetworks(const std::string& onc_blob) = 0; virtual bool LoadOncNetworks(const std::string& onc_blob,
const std::string& passcode) = 0;
// This sets the active network for the network type. Note: priority order // This sets the active network for the network type. Note: priority order
// is unchanged (i.e. if a wifi network is set to active, but an ethernet // is unchanged (i.e. if a wifi network is set to active, but an ethernet
......
...@@ -56,7 +56,7 @@ void NetworkConfigurationUpdater::ApplyNetworkConfiguration( ...@@ -56,7 +56,7 @@ void NetworkConfigurationUpdater::ApplyNetworkConfiguration(
if (*cached_value != new_network_config) { if (*cached_value != new_network_config) {
*cached_value = new_network_config; *cached_value = new_network_config;
if (!network_library_->LoadOncNetworks(new_network_config)) if (!network_library_->LoadOncNetworks(new_network_config, ""))
LOG(WARNING) << "Network library failed to load ONC configuration."; LOG(WARNING) << "Network library failed to load ONC configuration.";
} }
} }
......
...@@ -26,7 +26,7 @@ class NetworkConfigurationUpdaterTest ...@@ -26,7 +26,7 @@ class NetworkConfigurationUpdaterTest
TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) { TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) {
provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC)); provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC)) EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, ""))
.WillRepeatedly(Return(true)); .WillRepeatedly(Return(true));
NetworkConfigurationUpdater updater(&provider_, &network_library_); NetworkConfigurationUpdater updater(&provider_, &network_library_);
...@@ -37,20 +37,20 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) { ...@@ -37,20 +37,20 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
NetworkConfigurationUpdater updater(&provider_, &network_library_); NetworkConfigurationUpdater updater(&provider_, &network_library_);
// We should update if policy changes. // We should update if policy changes.
EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC)) EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, ""))
.WillOnce(Return(true)); .WillOnce(Return(true));
provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC)); provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
provider_.NotifyPolicyUpdated(); provider_.NotifyPolicyUpdated();
Mock::VerifyAndClearExpectations(&network_library_); Mock::VerifyAndClearExpectations(&network_library_);
// No update if the set the same value again. // No update if the set the same value again.
EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC)) EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, ""))
.Times(0); .Times(0);
provider_.NotifyPolicyUpdated(); provider_.NotifyPolicyUpdated();
Mock::VerifyAndClearExpectations(&network_library_); Mock::VerifyAndClearExpectations(&network_library_);
// Another update is expected if the policy goes away. // Another update is expected if the policy goes away.
EXPECT_CALL(network_library_, LoadOncNetworks("")) EXPECT_CALL(network_library_, LoadOncNetworks("", ""))
.WillOnce(Return(true)); .WillOnce(Return(true));
provider_.RemovePolicy(GetParam()); provider_.RemovePolicy(GetParam());
provider_.NotifyPolicyUpdated(); provider_.NotifyPolicyUpdated();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment