0

cros_healthd: Add HasSecureWiFiConnection routine

Add the HasSecureWiFiConnection routine to the ServiceConnection.

BUG=chromium:956783
TEST=1) chromeos_unittests --gtest_filter=CrosHealthdServiceConnectionTest.*
2) Applied HasSecureWiFiConnection changes and successfully ran the
HasSecureWiFiConnection routine on a DUT (verified using cros-health-tool diag
--action=run_routine --routine=has_secure_wifi_connection).

Change-Id: Ic7ed3429321a6a8fb991803207e5248a29680055
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2344804
Commit-Queue: Kartik Hegde <khegde@chromium.org>
Reviewed-by: Paul Moy <pmoy@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Oleh Lamzin <lamzin@google.com>
Cr-Commit-Position: refs/heads/master@{#817246}
This commit is contained in:
Kartik Hegde
2020-10-14 23:02:33 +00:00
committed by Commit Bot
parent cbdba99985
commit 3e311f8f53
8 changed files with 60 additions and 0 deletions

@ -521,6 +521,15 @@ void DeviceCommandRunRoutineJob::RunImpl(CallbackWithResult succeeded_callback,
std::move(failed_callback)));
break;
}
case chromeos::cros_healthd::mojom::DiagnosticRoutineEnum::
kHasSecureWiFiConnection: {
chromeos::cros_healthd::ServiceConnection::GetInstance()
->RunHasSecureWiFiConnectionRoutine(base::BindOnce(
&DeviceCommandRunRoutineJob::OnCrosHealthdResponseReceived,
weak_ptr_factory_.GetWeakPtr(), std::move(succeeded_callback),
std::move(failed_callback)));
break;
}
}
}

@ -222,6 +222,11 @@ void FakeCrosHealthdService::RunGatewayCanBePingedRoutine(
std::move(callback).Run(run_routine_response_.Clone());
}
void FakeCrosHealthdService::RunHasSecureWiFiConnectionRoutine(
RunHasSecureWiFiConnectionRoutineCallback callback) {
std::move(callback).Run(run_routine_response_.Clone());
}
void FakeCrosHealthdService::AddBluetoothObserver(
mojom::CrosHealthdBluetoothObserverPtr observer) {
bluetooth_observers_.Add(observer.PassInterface());

@ -104,6 +104,8 @@ class FakeCrosHealthdService final
RunSignalStrengthRoutineCallback callback) override;
void RunGatewayCanBePingedRoutine(
RunGatewayCanBePingedRoutineCallback callback) override;
void RunHasSecureWiFiConnectionRoutine(
RunHasSecureWiFiConnectionRoutineCallback callback) override;
// CrosHealthdEventService overrides:
void AddBluetoothObserver(

@ -113,6 +113,9 @@ class ServiceConnectionImpl : public ServiceConnection {
void RunGatewayCanBePingedRoutine(
mojom::CrosHealthdDiagnosticsService::RunGatewayCanBePingedRoutineCallback
callback) override;
void RunHasSecureWiFiConnectionRoutine(
mojom::CrosHealthdDiagnosticsService::
RunHasSecureWiFiConnectionRoutineCallback callback) override;
void AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer)
override;
@ -389,6 +392,15 @@ void ServiceConnectionImpl::RunGatewayCanBePingedRoutine(
std::move(callback));
}
void ServiceConnectionImpl::RunHasSecureWiFiConnectionRoutine(
mojom::CrosHealthdDiagnosticsService::
RunHasSecureWiFiConnectionRoutineCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
BindCrosHealthdDiagnosticsServiceIfNeeded();
cros_healthd_diagnostics_service_->RunHasSecureWiFiConnectionRoutine(
std::move(callback));
}
void ServiceConnectionImpl::AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

@ -200,6 +200,13 @@ class ServiceConnection {
mojom::CrosHealthdDiagnosticsService::RunGatewayCanBePingedRoutineCallback
callback) = 0;
// Requests that cros_healthd runs the has secure wifi routine. See
// src/chromeos/service/cros_healthd/public/mojom/cros_healthd.mojom for
// details.
virtual void RunHasSecureWiFiConnectionRoutine(
mojom::CrosHealthdDiagnosticsService::
RunHasSecureWiFiConnectionRoutineCallback callback) = 0;
// Subscribes to cros_healthd's Bluetooth-related events. See
// src/chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom for
// details.

@ -562,6 +562,19 @@ TEST_F(CrosHealthdServiceConnectionTest, RunGatewayCanBePingedRoutine) {
run_loop.Run();
}
// Test that we can run the has secure wifi connection routine.
TEST_F(CrosHealthdServiceConnectionTest, RunHasSecureWiFiConnectionRoutine) {
auto response = MakeRunRoutineResponse();
FakeCrosHealthdClient::Get()->SetRunRoutineResponseForTesting(response);
base::RunLoop run_loop;
ServiceConnection::GetInstance()->RunHasSecureWiFiConnectionRoutine(
base::BindLambdaForTesting([&](mojom::RunRoutineResponsePtr response) {
EXPECT_EQ(response, MakeRunRoutineResponse());
run_loop.Quit();
}));
run_loop.Run();
}
// Test that we can add a Bluetooth observer.
TEST_F(CrosHealthdServiceConnectionTest, AddBluetoothObserver) {
MockCrosHealthdBluetoothObserver observer;

@ -336,6 +336,17 @@ interface CrosHealthdDiagnosticsService {
// * |response| - contains a unique identifier and status for the created
// routine.
RunGatewayCanBePingedRoutine() => (RunRoutineResponse response);
// Requests that the HasSecureWiFiConnection routine is created and started
// on the platform. This routine checks whether the WiFi connection is
// secure. Note that if WiFi is not connected, the routine will not run. This
// routine is only available if GetAvailableRoutines returned
// kHasSecureWiFiConnection.
//
// The response:
// * |response| - contains a unique identifier and status for the created
// routine.
RunHasSecureWiFiConnectionRoutine() => (RunRoutineResponse response);
};
// Event interface exposed by the cros_healthd daemon.

@ -34,6 +34,7 @@ enum DiagnosticRoutineEnum {
kLanConnectivity = 15,
kSignalStrength = 16,
kGatewayCanBePinged = 17,
kHasSecureWiFiConnection = 18,
};
// Enumeration of the possible DiskRead routine's command type