Index: extensions/browser/api/networking_private/networking_private_chromeos_unittest.cc |
diff --git a/extensions/browser/api/networking_private/networking_private_chromeos_unittest.cc b/extensions/browser/api/networking_private/networking_private_chromeos_unittest.cc |
index 2ad5b3f2c31ea4c5f5b463318bf3a3146767ec63..bf2827360277cc364ba268a51fe63d592323e6f4 100644 |
--- a/extensions/browser/api/networking_private/networking_private_chromeos_unittest.cc |
+++ b/extensions/browser/api/networking_private/networking_private_chromeos_unittest.cc |
@@ -465,4 +465,121 @@ TEST_F(NetworkingPrivateApiTest, |
network_hex_ssid.c_str()))); |
} |
+TEST_F(NetworkingPrivateApiTest, ForgetSharedNetwork) { |
+ EXPECT_EQ(networking_private::kErrorAccessToSharedConfig, |
+ RunFunctionAndReturnError( |
+ new NetworkingPrivateForgetNetworkFunction(), |
+ base::StringPrintf(R"(["%s"])", kSharedWifiGuid))); |
+ |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(kSharedWifiServicePath, &profile_path)); |
+ EXPECT_EQ(chromeos::ShillProfileClient::GetSharedProfilePath(), profile_path); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetPrivateNetwork) { |
+ RunFunction(new NetworkingPrivateForgetNetworkFunction(), |
+ base::StringPrintf(R"(["%s"])", kPrivateWifiGuid)); |
+ |
+ std::string profile_path; |
+ EXPECT_FALSE(GetServiceProfile(kPrivateWifiServicePath, &profile_path)); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetPrivateNetworkWebUI) { |
+ scoped_refptr<NetworkingPrivateForgetNetworkFunction> forget_network = |
+ new NetworkingPrivateForgetNetworkFunction(); |
+ forget_network->set_source_context_type(Feature::WEBUI_CONTEXT); |
+ |
+ RunFunction(forget_network.get(), |
+ base::StringPrintf(R"(["%s"])", kPrivateWifiGuid)); |
+ |
+ std::string profile_path; |
+ EXPECT_FALSE(GetServiceProfile(kPrivateWifiServicePath, &profile_path)); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetUserPolicyNetwork) { |
+ EXPECT_EQ(networking_private::kErrorPolicyControlled, |
+ RunFunctionAndReturnError( |
+ new NetworkingPrivateForgetNetworkFunction(), |
+ base::StringPrintf(R"(["%s"])", kManagedUserWifiGuid))); |
+ |
+ const chromeos::NetworkState* network = |
+ chromeos::NetworkHandler::Get() |
+ ->network_state_handler() |
+ ->GetNetworkStateFromGuid(kManagedUserWifiGuid); |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(network->path(), &profile_path)); |
+ EXPECT_EQ(kUserProfilePath, profile_path); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetUserPolicyNetworkWebUI) { |
+ scoped_refptr<NetworkingPrivateForgetNetworkFunction> forget_network = |
+ new NetworkingPrivateForgetNetworkFunction(); |
+ forget_network->set_source_context_type(Feature::WEBUI_CONTEXT); |
+ |
+ EXPECT_EQ(networking_private::kErrorPolicyControlled, |
+ RunFunctionAndReturnError( |
+ forget_network.get(), |
+ base::StringPrintf(R"(["%s"])", kManagedUserWifiGuid))); |
+ |
+ const chromeos::NetworkState* network = |
+ chromeos::NetworkHandler::Get() |
+ ->network_state_handler() |
+ ->GetNetworkStateFromGuid(kManagedUserWifiGuid); |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(network->path(), &profile_path)); |
+ EXPECT_EQ(kUserProfilePath, profile_path); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetDevicePolicyNetworkWebUI) { |
+ scoped_refptr<NetworkingPrivateForgetNetworkFunction> forget_network = |
+ new NetworkingPrivateForgetNetworkFunction(); |
+ forget_network->set_source_context_type(Feature::WEBUI_CONTEXT); |
+ |
+ EXPECT_EQ(networking_private::kErrorPolicyControlled, |
+ RunFunctionAndReturnError( |
+ forget_network.get(), |
+ base::StringPrintf(R"(["%s"])", kManagedDeviceWifiGuid))); |
+ |
+ const chromeos::NetworkState* network = |
+ chromeos::NetworkHandler::Get() |
+ ->network_state_handler() |
+ ->GetNetworkStateFromGuid(kManagedDeviceWifiGuid); |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(network->path(), &profile_path)); |
+ EXPECT_EQ(chromeos::ShillProfileClient::GetSharedProfilePath(), profile_path); |
+} |
+ |
+// Tests that forgetNetwork in case there is a network config in both user and |
+// shared profile - only config from the user profile is expected to be removed. |
+TEST_F(NetworkingPrivateApiTest, ForgetNetworkInMultipleProfiles) { |
+ AddSharedNetworkToUserProfile(); |
+ |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(kSharedWifiServicePath, &profile_path)); |
+ ASSERT_EQ(kUserProfilePath, profile_path); |
+ |
+ RunFunction(new NetworkingPrivateForgetNetworkFunction(), |
+ base::StringPrintf(R"(["%s"])", kSharedWifiGuid)); |
+ |
+ EXPECT_TRUE(GetServiceProfile(kSharedWifiServicePath, &profile_path)); |
+ EXPECT_EQ(chromeos::ShillProfileClient::GetSharedProfilePath(), profile_path); |
+} |
+ |
+TEST_F(NetworkingPrivateApiTest, ForgetNetworkInMultipleProfilesWebUI) { |
+ AddSharedNetworkToUserProfile(); |
+ |
+ std::string profile_path; |
+ EXPECT_TRUE(GetServiceProfile(kSharedWifiServicePath, &profile_path)); |
+ ASSERT_EQ(kUserProfilePath, profile_path); |
+ |
+ scoped_refptr<NetworkingPrivateForgetNetworkFunction> forget_network = |
+ new NetworkingPrivateForgetNetworkFunction(); |
+ forget_network->set_source_context_type(Feature::WEBUI_CONTEXT); |
+ |
+ RunFunction(forget_network.get(), |
+ base::StringPrintf(R"(["%s"])", kSharedWifiGuid)); |
+ |
+ EXPECT_FALSE(GetServiceProfile(kSharedWifiServicePath, &profile_path)); |
+} |
+ |
} // namespace extensions |