Commit 869381b8 authored by Omar Morsi's avatar Omar Morsi Committed by Commit Bot

Revert "Turn on enterprise network state reporting for affiliated users."

This reverts commit 5d5dad5b.

Reason for revert: This feature is targeting M-81 as shown in Bug: 1026612 and it will be included in M-80 if not reverted.

Original change's description:
> Turn on enterprise network state reporting for affiliated users.
> 
> Network state should be reported in three conditions.
> 1- Primary user signed in is affiliated.
> 2- Managed device is in kiosk mode.
> 3- Managed guest session is running.
> 
> Bug: 1027086
> Test: browser_tests --gtest_filter=DeviceStatusCollectorNetwork*
> Change-Id: I29aaad9f5e442ea164bd1afd28a3bca72c66e459
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928702
> Commit-Queue: Omar Morsi <omorsi@google.com>
> Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#720225}

TBR=emaxx@chromium.org,omorsi@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1027086
Change-Id: Id16de075fa98990d85f390f1c791917f4855fbe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947651Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Commit-Queue: Omar Morsi <omorsi@google.com>
Cr-Commit-Position: refs/heads/master@{#720915}
parent 24585da8
...@@ -1448,11 +1448,9 @@ bool DeviceStatusCollector::GetNetworkInterfaces( ...@@ -1448,11 +1448,9 @@ bool DeviceStatusCollector::GetNetworkInterfaces(
anything_reported = true; anything_reported = true;
} }
user_manager::UserManager* user_manager = user_manager::UserManager::Get(); // Don't write any network state if we aren't in a kiosk or public session.
const user_manager::User* const primary_user = user_manager->GetPrimaryUser(); if (!GetAutoLaunchedKioskSessionInfo() &&
// Don't write network state for unaffiliated users or when no user is signed !user_manager::UserManager::Get()->IsLoggedInAsPublicAccount()) {
// in.
if (!primary_user || !primary_user->IsAffiliated()) {
return anything_reported; return anything_reported;
} }
......
...@@ -2554,7 +2554,8 @@ static const FakeNetworkState kUnconfiguredNetwork = { ...@@ -2554,7 +2554,8 @@ static const FakeNetworkState kUnconfiguredNetwork = {
shill::kStateOffline, em::NetworkState::OFFLINE, "", "" shill::kStateOffline, em::NetworkState::OFFLINE, "", ""
}; };
class DeviceStatusCollectorNetworkTest : public DeviceStatusCollectorTest { class DeviceStatusCollectorNetworkInterfacesTest
: public DeviceStatusCollectorTest {
protected: protected:
void SetUp() override { void SetUp() override {
DeviceStatusCollectorTest::SetUp(); DeviceStatusCollectorTest::SetUp();
...@@ -2672,13 +2673,7 @@ class DeviceStatusCollectorNetworkTest : public DeviceStatusCollectorTest { ...@@ -2672,13 +2673,7 @@ class DeviceStatusCollectorNetworkTest : public DeviceStatusCollectorTest {
DeviceStatusCollectorTest::TearDown(); DeviceStatusCollectorTest::TearDown();
} }
virtual void VerifyReporting() = 0; void VerifyNetworkReporting() {
};
class DeviceStatusCollectorNetworkInterfacesTest
: public DeviceStatusCollectorNetworkTest {
protected:
void VerifyReporting() override {
int count = 0; int count = 0;
for (const FakeDeviceData& dev : kFakeDevices) { for (const FakeDeviceData& dev : kFakeDevices) {
if (dev.expected_type == -1) if (dev.expected_type == -1)
...@@ -2709,71 +2704,8 @@ class DeviceStatusCollectorNetworkInterfacesTest ...@@ -2709,71 +2704,8 @@ class DeviceStatusCollectorNetworkInterfacesTest
} }
EXPECT_EQ(count, device_status_.network_interfaces_size()); EXPECT_EQ(count, device_status_.network_interfaces_size());
}
};
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, Default) {
// Network interfaces should be reported by default.
GetStatus();
VerifyReporting();
// Network interfaces shouldn't be reported if the policy is off.
scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, false);
GetStatus();
EXPECT_EQ(0, device_status_.network_interfaces_size());
// Switch the policy on and verify the interface list is present.
scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, true);
GetStatus();
VerifyReporting();
}
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, IfUnaffiliatedUser) {
// Network interfaces should be reported for unaffiliated users.
const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com"));
user_manager_->AddUserWithAffiliationAndType(account_id0, false,
user_manager::USER_TYPE_REGULAR);
GetStatus();
VerifyReporting();
}
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, IfAffiliatedUser) {
// Network interfaces should be reported for affiliated users.
const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com"));
user_manager_->AddUserWithAffiliationAndType(account_id0, true,
user_manager::USER_TYPE_REGULAR);
GetStatus();
VerifyReporting();
}
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, IfPublicSession) {
// Network interfaces should be reported if in public session.
user_manager_->CreatePublicAccountUser(
AccountId::FromUserEmail(kPublicAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
.WillRepeatedly(Return(true));
GetStatus(); // Now make sure network state list is correct.
VerifyReporting();
}
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, IfKioskMode) {
// Network interfaces should be reported if in kiosk mode.
user_manager_->CreateKioskAppUser(AccountId::FromUserEmail(kKioskAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp())
.WillRepeatedly(Return(true));
GetStatus();
VerifyReporting();
}
class DeviceStatusCollectorNetworkStateTest
: public DeviceStatusCollectorNetworkTest {
protected:
void VerifyReporting() override {
EXPECT_EQ(base::size(kFakeNetworks), EXPECT_EQ(base::size(kFakeNetworks),
static_cast<size_t>(device_status_.network_states_size())); static_cast<size_t>(device_status_.network_states_size()));
for (const FakeNetworkState& state : kFakeNetworks) { for (const FakeNetworkState& state : kFakeNetworks) {
...@@ -2804,69 +2736,51 @@ class DeviceStatusCollectorNetworkStateTest ...@@ -2804,69 +2736,51 @@ class DeviceStatusCollectorNetworkStateTest
} }
}; };
TEST_F(DeviceStatusCollectorNetworkStateTest, Default) { TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NoNetworkStateIfNotKiosk) {
// Network state shouldn't be reported by default. // If not in an active kiosk session, there should be network interfaces
// reported, but no network state.
GetStatus(); GetStatus();
EXPECT_LT(0, device_status_.network_interfaces_size());
EXPECT_EQ(0, device_status_.network_states_size()); EXPECT_EQ(0, device_status_.network_states_size());
}
// Mock that the device is in kiosk mode to report network state. TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) {
user_manager_->CreateKioskAppUser(AccountId::FromUserEmail(kKioskAccountId)); // Mock that we are in kiosk mode so we report network state.
EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()) status_collector_->set_kiosk_account(
.WillRepeatedly(Return(true)); std::make_unique<policy::DeviceLocalAccount>(
fake_kiosk_device_local_account_));
// Interfaces should be reported by default.
GetStatus(); GetStatus();
VerifyReporting(); EXPECT_LT(0, device_status_.network_interfaces_size());
EXPECT_LT(0, device_status_.network_states_size());
// Network state shouldn't be reported if the policy is off. // No interfaces should be reported if the policy is off.
scoped_testing_cros_settings_.device_settings()->SetBoolean( scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, false); chromeos::kReportDeviceNetworkInterfaces, false);
GetStatus(); GetStatus();
EXPECT_EQ(0, device_status_.network_interfaces_size());
EXPECT_EQ(0, device_status_.network_states_size()); EXPECT_EQ(0, device_status_.network_states_size());
// Switch the policy on and verify that network state is reported // Switch the policy on and verify the interface list is present.
scoped_testing_cros_settings_.device_settings()->SetBoolean( scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, true); chromeos::kReportDeviceNetworkInterfaces, true);
GetStatus(); GetStatus();
VerifyReporting();
}
TEST_F(DeviceStatusCollectorNetworkStateTest, IfUnaffiliatedUser) {
// Network state shouldn't be reported for unaffiliated users.
const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com"));
user_manager_->AddUserWithAffiliationAndType(account_id0, false,
user_manager::USER_TYPE_REGULAR);
GetStatus();
EXPECT_EQ(0, device_status_.network_states_size());
}
TEST_F(DeviceStatusCollectorNetworkStateTest, IfAffiliatedUser) { VerifyNetworkReporting();
// Network state should be reported for affiliated users.
const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com"));
user_manager_->AddUserWithAffiliationAndType(account_id0, true,
user_manager::USER_TYPE_REGULAR);
GetStatus();
VerifyReporting();
} }
TEST_F(DeviceStatusCollectorNetworkStateTest, IfPublicSession) { TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) {
// Network state should be reported if in public session. // Report netowork state for public accounts.
user_manager_->CreatePublicAccountUser( user_manager_->CreatePublicAccountUser(
AccountId::FromUserEmail(kPublicAccountId)); AccountId::FromUserEmail(kPublicAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
.WillRepeatedly(Return(true)); .WillRepeatedly(Return(true));
scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, true);
GetStatus(); GetStatus();
VerifyReporting(); VerifyNetworkReporting();
}
TEST_F(DeviceStatusCollectorNetworkStateTest, IfKioskMode) {
// Network state should be reported if in kiosk mode.
user_manager_->CreateKioskAppUser(AccountId::FromUserEmail(kKioskAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp())
.WillRepeatedly(Return(true));
GetStatus();
VerifyReporting();
} }
} // namespace policy } // namespace policy
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