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(
anything_reported = true;
}
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
const user_manager::User* const primary_user = user_manager->GetPrimaryUser();
// Don't write network state for unaffiliated users or when no user is signed
// in.
if (!primary_user || !primary_user->IsAffiliated()) {
// Don't write any network state if we aren't in a kiosk or public session.
if (!GetAutoLaunchedKioskSessionInfo() &&
!user_manager::UserManager::Get()->IsLoggedInAsPublicAccount()) {
return anything_reported;
}
......
......@@ -2554,7 +2554,8 @@ static const FakeNetworkState kUnconfiguredNetwork = {
shill::kStateOffline, em::NetworkState::OFFLINE, "", ""
};
class DeviceStatusCollectorNetworkTest : public DeviceStatusCollectorTest {
class DeviceStatusCollectorNetworkInterfacesTest
: public DeviceStatusCollectorTest {
protected:
void SetUp() override {
DeviceStatusCollectorTest::SetUp();
......@@ -2672,13 +2673,7 @@ class DeviceStatusCollectorNetworkTest : public DeviceStatusCollectorTest {
DeviceStatusCollectorTest::TearDown();
}
virtual void VerifyReporting() = 0;
};
class DeviceStatusCollectorNetworkInterfacesTest
: public DeviceStatusCollectorNetworkTest {
protected:
void VerifyReporting() override {
void VerifyNetworkReporting() {
int count = 0;
for (const FakeDeviceData& dev : kFakeDevices) {
if (dev.expected_type == -1)
......@@ -2709,71 +2704,8 @@ class DeviceStatusCollectorNetworkInterfacesTest
}
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();
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 {
// Now make sure network state list is correct.
EXPECT_EQ(base::size(kFakeNetworks),
static_cast<size_t>(device_status_.network_states_size()));
for (const FakeNetworkState& state : kFakeNetworks) {
......@@ -2804,69 +2736,51 @@ class DeviceStatusCollectorNetworkStateTest
}
};
TEST_F(DeviceStatusCollectorNetworkStateTest, Default) {
// Network state shouldn't be reported by default.
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NoNetworkStateIfNotKiosk) {
// If not in an active kiosk session, there should be network interfaces
// reported, but no network state.
GetStatus();
EXPECT_LT(0, device_status_.network_interfaces_size());
EXPECT_EQ(0, device_status_.network_states_size());
}
// Mock that the device is in kiosk mode to report network state.
user_manager_->CreateKioskAppUser(AccountId::FromUserEmail(kKioskAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp())
.WillRepeatedly(Return(true));
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) {
// Mock that we are in kiosk mode so we report network state.
status_collector_->set_kiosk_account(
std::make_unique<policy::DeviceLocalAccount>(
fake_kiosk_device_local_account_));
// Interfaces should be reported by default.
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(
chromeos::kReportDeviceNetworkInterfaces, false);
GetStatus();
EXPECT_EQ(0, device_status_.network_interfaces_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(
chromeos::kReportDeviceNetworkInterfaces, true);
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) {
// 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();
VerifyNetworkReporting();
}
TEST_F(DeviceStatusCollectorNetworkStateTest, IfPublicSession) {
// Network state should be reported if in public session.
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) {
// Report netowork state for public accounts.
user_manager_->CreatePublicAccountUser(
AccountId::FromUserEmail(kPublicAccountId));
EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
.WillRepeatedly(Return(true));
scoped_testing_cros_settings_.device_settings()->SetBoolean(
chromeos::kReportDeviceNetworkInterfaces, true);
GetStatus();
VerifyReporting();
}
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();
VerifyNetworkReporting();
}
} // 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