libcutils \
libminijail \
libutils \
- libwifi-hal \
libwifi-system
LOCAL_STATIC_LIBRARIES := \
libwificond
LOCAL_SHARED_LIBRARIES := \
libbase \
libutils \
- libwifi-hal \
libwifi-system
LOCAL_WHOLE_STATIC_LIBRARIES := \
libwificond_ipc \
LOCAL_STATIC_LIBRARIES := \
libgmock \
libgtest \
- libwifi-hal-test \
libwifi-system-test \
libwificond \
libwificond_nl
libbinder \
liblog \
libutils \
- libwifi-hal \
libwifi-system
include $(BUILD_NATIVE_TEST)
libwificond_ipc \
libwificond_test_utils
include $(BUILD_NATIVE_TEST)
-
-###
-### wpa_supplicant binder integration tests.
-### (Compiled only when wpa_supplicant's binder interface is enabled)
-###
-ifeq ($(WPA_SUPPLICANT_USE_BINDER), y)
-include $(CLEAR_VARS)
-LOCAL_MODULE := wpa_supplicant_binder_test
-LOCAL_CPPFLAGS := $(wificond_cpp_flags)
-LOCAL_SRC_FILES := \
- tests/integration/wpa_supplicant_binder/connect_tests.cpp \
- tests/integration/wpa_supplicant_binder/main.cpp \
- tests/integration/wpa_supplicant_binder/network_params.cpp \
- tests/integration/wpa_supplicant_binder/test_base.cpp \
- tests/integration/wpa_supplicant_binder/tests.cpp
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libbinder \
- libcutils \
- libutils \
- libwifi-hal \
- libwifi-system
-LOCAL_STATIC_LIBRARIES := \
- libgmock \
- libjsoncpp \
- libwificond_test_utils \
- libwpa_binder_interface
-include $(BUILD_NATIVE_TEST)
-endif # WPA_SUPPLICANT_USE_BINDER == y
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <json/json.h>
-
-#include "network_params.h"
-#include "test_base.h"
-
-using testing::_;
-using testing::DoAll;
-using testing::Return;
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-
-// Base class for all connection related tests.
-class ConnectTestBase : public WpaSupplicantBinderTestBase {
- protected:
- // Set the provided networks params |params| on the provided INetwork binder
- // object |network|.
- void SetNetworkParams(const android::sp<INetwork> &network,
- const NetworkParams *network_params) {
- android::binder::Status status;
- status = network->SetSSID(network_params->ssid_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->SetKeyMgmt(network_params->key_mgmt_mask_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->SetProto(network_params->proto_mask_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->SetAuthAlg(network_params->auth_alg_mask_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->SetGroupCipher(network_params->group_cipher_mask_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->SetPairwiseCipher(network_params->pairwise_cipher_mask_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- if (!network_params->psk_passphrase_.empty()) {
- status = network->SetPskPassphrase(network_params->psk_passphrase_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
- if (!network_params->wep_key0_.empty()) {
- status = network->SetWepKey(0, network_params->wep_key0_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
- if (!network_params->wep_key1_.empty()) {
- status = network->SetWepKey(1, network_params->wep_key1_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
- if (!network_params->wep_key2_.empty()) {
- status = network->SetWepKey(2, network_params->wep_key2_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
- if (!network_params->wep_key3_.empty()) {
- status = network->SetWepKey(3, network_params->wep_key3_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
- status = network->SetWepTxKeyIdx(network_params->wep_tx_key_idx_);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
-};
-
-/**
- * Test Scenario:
- * 1. Creates the iface wlan0.
- * 2. Adds the specified network.
- * 3. Selects the network for connection.
- * 4. Waits for connection to the network.
- * 5. Disables the network.
- * 6. Waits for disconnection from the network.
- *
- * This verifies the |ISupplicant.CreateInterface|, |IIface.AddNetwork|,
- * |INetwork.SetSSID|, |INetwork.SetKeyMgmt|, |INetwork.Select|,
- * |INetwork.Disable|, |IIfaceCallback.OnStateChanged| binder methods.
- */
-TEST_F(ConnectTestBase, SimpleConnectDisconnect) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
- int network_id;
- android::binder::Status status = network->GetId(&network_id);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- android::sp<MockIfaceCallback> callback(new MockIfaceCallback);
- status = iface->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- NetworkParams *network_params = NetworkParams::GetNetworkParamsForTest();
- ASSERT_TRUE(network_params)
- << "Unable to parse network params from command line";
- SetNetworkParams(network, network_params);
-
- // Initiate connection to the network by selecting it.
- status = network->Select();
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Wait for the wpa_supplicant connection to complete.
- EXPECT_CALL(*callback, OnStateChanged(_, _, _, _))
- .WillRepeatedly(Return(android::binder::Status::ok()));
- EXPECT_CALL(*callback, OnStateChanged(MockIfaceCallback::STATE_COMPLETED, _,
- network_id, network_params->ssid_))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kConnectTimeoutMillis));
-
- // Now disable the network to trigger disconnection.
- status = network->Disable();
- EXPECT_TRUE(status.isOk()) << status.toString8();
- EXPECT_CALL(*callback,
- OnStateChanged(MockIfaceCallback::STATE_INACTIVE, _, _, _))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kConnectTimeoutMillis));
-}
-
-/**
- * Test Scenario:
- * 1. Creates the iface wlan0.
- * 2. Adds the specified network.
- * 3. Selects the network for connection.
- * 4. Waits for connection to the network.
- * 5. Disconnects from the network.
- * 6. Waits for disconnection from the network.
- * 7. Issues a reconnect to connect back.
- *
- * This verifies the |ISupplicant.CreateInterface|, |IIface.AddNetwork|,
- * |IIface.Disconnect|, |IIface.Reconnect|, |INetwork.SetSSID|,
- * |INetwork.SetKeyMgmt|, |INetwork.Select|,
- * |INetwork.Disable|, |IIfaceCallback.OnStateChanged| binder methods.
- */
-TEST_F(ConnectTestBase, SimpleReconnect) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
- int network_id;
- android::binder::Status status = network->GetId(&network_id);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- android::sp<MockIfaceCallback> callback(new MockIfaceCallback);
- status = iface->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- NetworkParams *network_params = NetworkParams::GetNetworkParamsForTest();
- ASSERT_TRUE(network_params)
- << "Unable to parse network params from command line";
- SetNetworkParams(network, network_params);
-
- // Initiate connection to the network by selecting it.
- status = network->Select();
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Wait for the wpa_supplicant connection to complete.
- EXPECT_CALL(*callback, OnStateChanged(_, _, _, _))
- .WillRepeatedly(Return(android::binder::Status::ok()));
- EXPECT_CALL(*callback, OnStateChanged(MockIfaceCallback::STATE_COMPLETED, _,
- network_id, network_params->ssid_))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kConnectTimeoutMillis));
-
- // Now disconnect the network.
- status = iface->Disconnect();
- EXPECT_TRUE(status.isOk()) << status.toString8();
- EXPECT_CALL(*callback,
- OnStateChanged(MockIfaceCallback::STATE_DISCONNECTED, _, _, _))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kConnectTimeoutMillis));
-
- // Issue reconnect again since we explicitly disconnected above.
- status = iface->Reconnect();
- EXPECT_TRUE(status.isOk()) << status.toString8();
- EXPECT_CALL(*callback, OnStateChanged(MockIfaceCallback::STATE_COMPLETED, _,
- network_id, network_params->ssid_))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kConnectTimeoutMillis));
-}
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android
+++ /dev/null
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <android-base/logging.h>
-
-#include "network_params.h"
-
-using android::wificond::wpa_supplicant_binder_test::NetworkParams;
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::InitGoogleMock(&argc, argv);
- // Force ourselves to always log to stderr
- android::base::InitLogging(argv, android::base::StderrLogger);
-
- // Parse out any network params sent as json string. This is used
- // for all the tests in connect_tests.cpp.
- for (int i = 0; i < argc; i++) {
- const std::string arg(argv[i]);
- if (NetworkParams::ParseFromJsonString(arg)) {
- break;
- }
- }
- return RUN_ALL_TESTS();
-}
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <json/json.h>
-
-#include <android-base/logging.h>
-#include <fi/w1/wpa_supplicant/INetwork.h>
-
-#include "network_params.h"
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-
-const char NetworkParams::kJsonHeader[] = "NetworkParams";
-const char NetworkParams::kJsonKeySSID[] = "ssid";
-const char NetworkParams::kJsonKeyKeyMgmt[] = "key_mgmt";
-const char NetworkParams::kJsonKeyPskPassphrase[] = "psk_passphrase";
-
-// List of default values assigned if not present in args.
-const int NetworkParams::kDefaultKeyMgmt =
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_NONE;
-const int NetworkParams::kDefaultProto =
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_WPA |
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_RSN;
-const int NetworkParams::kDefaultAuthAlg =
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_OPEN;
-const int NetworkParams::kDefaultGroupCipher =
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_TKIP |
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_CCMP;
-const int NetworkParams::kDefaultPairwiseCipher =
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_TKIP |
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_CCMP;
-
-std::unique_ptr<NetworkParams> NetworkParams::instance_;
-
-bool NetworkParams::ParseFromJsonString(const std::string &json_string) {
- // Check if the provided string contain a json formatted string with the
- // expected header |kJsonHeader|.
- Json::Value empty_json(Json::objectValue);
- Json::Value json_root;
- Json::Reader reader;
- if (!reader.parse(json_string, json_root)) {
- return false;
- }
- Json::Value json_value = json_root.get(kJsonHeader, empty_json);
- if (json_value == empty_json) {
- return false;
- }
- LOG(INFO) << "Network Params Json: " << json_value;
- std::string ssid = json_value.get(kJsonKeySSID, empty_json).asString();
- if (ssid.empty()) {
- return false;
- }
-
- std::vector<uint8_t> ssid_vec(ssid.begin(), ssid.end());
- instance_.reset(new NetworkParams(ssid_vec));
- if (!instance_.get()) {
- return false;
- }
-
- if (json_value.get(kJsonKeyKeyMgmt, empty_json) != empty_json) {
- instance_->key_mgmt_mask_ =
- json_value.get(kJsonKeyKeyMgmt, empty_json).asInt();
- }
- if (json_value.get(kJsonKeyPskPassphrase, empty_json) != empty_json) {
- instance_->psk_passphrase_ =
- json_value.get(kJsonKeyPskPassphrase, empty_json).asString();
- }
-
- // TODO: Add other params parsing as needed.
- return true;
-}
-
-NetworkParams *NetworkParams::GetNetworkParamsForTest() {
- return instance_.get();
-}
-
-NetworkParams::NetworkParams(const std::vector<uint8_t> &ssid)
- : ssid_(ssid),
- key_mgmt_mask_(kDefaultKeyMgmt),
- proto_mask_(kDefaultProto),
- auth_alg_mask_(kDefaultAuthAlg),
- group_cipher_mask_(kDefaultGroupCipher),
- pairwise_cipher_mask_(kDefaultPairwiseCipher),
- wep_tx_key_idx_(0) {}
-
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_NETWORK_PARAMS_H
-#define WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_NETWORK_PARAMS_H
-
-#include <json/json.h>
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-// Network params to be passed in for connection tests. This is passed in via
-// test command line args as json strings. This should atleast contain the
-// |ssid| key, all the other keys are optional and takes default values
-// if not specified.
-// {
-// "NetworkParams" : {
-// "ssid" : "blah",
-// "psk_passphrase" : "blah123",
-// ...
-// }
-// }
-class NetworkParams {
- public:
- // Parse a new instance of |NetworkParams| class from the json string
- // passed in via command line args.
- // Returns true if successfully parsed, false otherwise.
- static bool ParseFromJsonString(const std::string &json_string);
- // Retrieve the raw pointer of the instance of network params passed in
- // for this test run.
- static NetworkParams *GetNetworkParamsForTest();
-
- // List of fields that have parsed/default values.
- std::vector<uint8_t> ssid_;
- int key_mgmt_mask_;
- int proto_mask_;
- int auth_alg_mask_;
- int group_cipher_mask_;
- int pairwise_cipher_mask_;
- std::string psk_passphrase_;
- int wep_tx_key_idx_;
- std::vector<uint8_t> wep_key0_;
- std::vector<uint8_t> wep_key1_;
- std::vector<uint8_t> wep_key2_;
- std::vector<uint8_t> wep_key3_;
-
- private:
- // List of supported json keys.
- static const char kJsonHeader[];
- static const char kJsonKeySSID[];
- static const char kJsonKeyKeyMgmt[];
- static const char kJsonKeyPskPassphrase[];
-
- // List of default values assigned if not present in args.
- static const int kDefaultKeyMgmt;
- static const int kDefaultProto;
- static const int kDefaultAuthAlg;
- static const int kDefaultGroupCipher;
- static const int kDefaultPairwiseCipher;
-
- // The instance of network params for this test run.
- static std::unique_ptr<NetworkParams> instance_;
-
- NetworkParams(const std::vector<uint8_t> &ssid);
-
-}; // class NetworkParams
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_NETWORK_PARAMS_H
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "test_base.h"
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-
-const char WpaSupplicantBinderTestBase::kWlan0IfaceName[] = "wlan0";
-const char WpaSupplicantBinderTestBase::kP2p0IfaceName[] = "p2p0";
-const char WpaSupplicantBinderTestBase::kIfaceDriver[] = "nl80211";
-const char WpaSupplicantBinderTestBase::kIfaceConfigFile[] =
- "/data/misc/wifi/wpa_supplicant.conf";
-const char WpaSupplicantBinderTestBase::kNetworkSSID[] = "SSID123";
-const char WpaSupplicantBinderTestBase::kNetworkPassphrase[] = "Psk123#$%";
-const uint8_t WpaSupplicantBinderTestBase::kNetworkBSSID[] = {0xad, 0x76, 0x34,
- 0x87, 0x90, 0x0f};
-const int WpaSupplicantBinderTestBase::kCallbackTimeoutMillis = 5;
-const int WpaSupplicantBinderTestBase::kConnectTimeoutMillis = 20000;
-
-WpaSupplicantBinderTestBase::WpaSupplicantBinderTestBase()
- : ::testing::Test(),
- binder_dispatcher_(),
- iface_tool_(new InterfaceTool()),
- driver_tool_(new DriverTool()) {}
-
-void WpaSupplicantBinderTestBase::SetUp() {
- RunShellCommand("stop");
- RunShellCommand("stop wificond");
- EXPECT_TRUE(android::wifi_system::wifi_stop_supplicant(true) == 0);
- EXPECT_TRUE(driver_tool_->UnloadDriver());
- EXPECT_TRUE(driver_tool_->LoadDriver());
- EXPECT_TRUE(driver_tool_->ChangeFirmwareMode(DriverTool::kFirmwareModeSta));
- EXPECT_TRUE(iface_tool_->SetWifiUpState(true));
- EXPECT_TRUE(android::wifi_system::wifi_start_supplicant(true) == 0);
- waitForBinderServiceRegistration();
- removeAllInterfaces();
- setDebugLevelToExcessive();
-}
-
-void WpaSupplicantBinderTestBase::TearDown() {
- EXPECT_TRUE(android::wifi_system::wifi_stop_supplicant(true) == 0);
- EXPECT_TRUE(driver_tool_->UnloadDriver());
- RunShellCommand("start wificond");
- RunShellCommand("start");
-}
-
-android::sp<ISupplicant> WpaSupplicantBinderTestBase::getBinderService() {
- android::sp<android::IBinder> service =
- android::defaultServiceManager()->checkService(android::String16(
- wpa_supplicant_binder::binder_constants::kServiceName));
- return android::interface_cast<ISupplicant>(service);
-}
-
-bool WpaSupplicantBinderTestBase::IsBinderServiceRegistered() {
- return getBinderService().get() != nullptr;
-}
-
-android::sp<IIface> WpaSupplicantBinderTestBase::CreateInterfaceForTest() {
- ParcelableIfaceParams params;
- params.ifname_ = kWlan0IfaceName;
- params.driver_ = kIfaceDriver;
- params.config_file_ = kIfaceConfigFile;
-
- android::sp<IIface> iface;
- android::binder::Status status = service_->CreateInterface(params, &iface);
- EXPECT_TRUE((status.isOk()) && (iface.get() != nullptr));
- return iface;
-}
-
-void WpaSupplicantBinderTestBase::RemoveInterfaceForTest() {
- android::binder::Status status = service_->RemoveInterface(kWlan0IfaceName);
- EXPECT_TRUE(status.isOk());
-}
-
-android::sp<INetwork> WpaSupplicantBinderTestBase::AddNetworkForTest(
- const android::sp<IIface>& iface) {
- android::sp<INetwork> network;
- android::binder::Status status = iface->AddNetwork(&network);
- EXPECT_TRUE((status.isOk()) && (network.get() != nullptr));
- return network;
-}
-
-void WpaSupplicantBinderTestBase::RemoveNetworkForTest(
- const android::sp<IIface>& iface, int network_id) {
- android::binder::Status status = iface->RemoveNetwork(network_id);
- EXPECT_TRUE((status.isOk()));
-}
-
-void WpaSupplicantBinderTestBase::waitForBinderServiceRegistration() {
- for (int tries = 0; tries < 10; tries++) {
- if (IsBinderServiceRegistered()) {
- break;
- }
- usleep(1000);
- }
- service_ = getBinderService();
- EXPECT_TRUE(service_.get() != nullptr);
-}
-
-void WpaSupplicantBinderTestBase::removeAllInterfaces() {
- android::sp<IIface> iface;
- // TODO: Add a service->ListInterfaces() to retrieve all the available
- // interfaces.
- android::binder::Status status =
- service_->GetInterface(kWlan0IfaceName, &iface);
- if (status.isOk() && iface.get() != nullptr) {
- status = service_->RemoveInterface(kWlan0IfaceName);
- EXPECT_TRUE(status.isOk());
- }
- status = service_->GetInterface(kP2p0IfaceName, &iface);
- if (status.isOk() && iface.get() != nullptr) {
- status = service_->RemoveInterface(kP2p0IfaceName);
- EXPECT_TRUE(status.isOk());
- }
-}
-
-void WpaSupplicantBinderTestBase::setDebugLevelToExcessive() {
- android::binder::Status status =
- service_->SetDebugParams(ISupplicant::DEBUG_LEVEL_EXCESSIVE, true, true);
- EXPECT_TRUE(status.isOk());
-}
-
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_TEST_BASE_H
-#define WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_TEST_BASE_H
-
-#include <android-base/logging.h>
-#include <binder/IBinder.h>
-#include <binder/IServiceManager.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <utils/Errors.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-#include <wifi_hal/driver_tool.h>
-#include <wifi_system/interface_tool.h>
-#include <wifi_system/wifi.h>
-#include <wpa_supplicant_binder/binder_constants.h>
-#include <wpa_supplicant_binder/parcelable_iface_params.h>
-
-#include <fi/w1/wpa_supplicant/BnIfaceCallback.h>
-#include <fi/w1/wpa_supplicant/BnSupplicantCallback.h>
-#include <fi/w1/wpa_supplicant/IIface.h>
-#include <fi/w1/wpa_supplicant/INetwork.h>
-#include <fi/w1/wpa_supplicant/ISupplicant.h>
-
-#include "tests/integration/binder_dispatcher.h"
-#include "tests/shell_utils.h"
-
-using android::wifi_hal::DriverTool;
-using android::wifi_system::InterfaceTool;
-using android::wificond::tests::integration::RunShellCommand;
-using android::wificond::tests::integration::BinderDispatcher;
-
-using fi::w1::wpa_supplicant::BnIfaceCallback;
-using fi::w1::wpa_supplicant::BnSupplicantCallback;
-using fi::w1::wpa_supplicant::IIface;
-using fi::w1::wpa_supplicant::INetwork;
-using fi::w1::wpa_supplicant::ISupplicant;
-using fi::w1::wpa_supplicant::ParcelableIfaceParams;
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-
-// Interrupt the binder callback tracker once the desired callback is invoked.
-ACTION_P(InterrupBinderDispatcher, binder_dispatcher) {
- binder_dispatcher->InterruptDispatch();
-}
-
-// Used to get callbacks defined in |BnSupplicantCallback|.
-class MockSupplicantCallback : public BnSupplicantCallback {
- public:
- MOCK_METHOD1(OnInterfaceCreated,
- android::binder::Status(const std::string& ifname));
- MOCK_METHOD1(OnInterfaceRemoved,
- android::binder::Status(const std::string& ifname));
-};
-
-// Used to get callbacks defined in |BnIfaceCallback|.
-class MockIfaceCallback : public BnIfaceCallback {
- public:
- MOCK_METHOD1(OnNetworkAdded, android::binder::Status(int id));
- MOCK_METHOD1(OnNetworkRemoved, android::binder::Status(int id));
- MOCK_METHOD4(OnStateChanged, android::binder::Status(
- int state, const std::vector<uint8_t>& bssid,
- int id, const std::vector<uint8_t>& ssid));
-};
-
-// Base class for all wpa_supplicant binder interface testing.
-// All the test classes should inherit from this class and invoke this base
-// class |Setup| & |TearDown|.
-// The |SetUp| method prepares the device for wpa_supplicant binder testing by
-// stopping framework, reloading driver, restarting wpa_supplicant, etc.
-class WpaSupplicantBinderTestBase : public ::testing::Test {
- public:
- // Hardcoded values for Android wpa_supplicant testing.
- // These interfaces may not exist on non-Android devices!
- static const char kWlan0IfaceName[];
- static const char kP2p0IfaceName[];
- static const char kIfaceDriver[];
- static const char kIfaceConfigFile[];
- static const char kNetworkSSID[];
- static const char kNetworkPassphrase[];
- static const uint8_t kNetworkBSSID[];
- static const int kCallbackTimeoutMillis;
- static const int kConnectTimeoutMillis;
-
- protected:
- WpaSupplicantBinderTestBase();
-
- // Steps performed before each test:
- // 1. Stop android framework.
- // 2. Stop |wificond|.
- // 3. Stop |wpa_supplicant|.
- // 4. Unload the driver.
- // 5. Load the driver.
- // 6. Set the firmware in Sta mode. (TODO: Ap mode for some tests).
- // 7. Set the wlan0 interface up.
- // 8. Start wpa_supplicant.
- // 9. Wait for wpa_supplicant binder service to be registered.
- // 10. Remove the |wlan0| & |p2p0| interface from wpa_supplicant.
- // 11. Increase |wpa_supplicant| debug level.
- // TODO: We can't fully nuke the existing wpa_supplicant.conf file because
- // there are some device specific parameters stored there needed for
- // wpa_supplicant to work properly.
- void SetUp() override;
- // Steps performed after each test:
- // 1. Stop |wpa_supplicant|.
- // 2. Unload the driver.
- // 3. Start |wificond|.
- // 4. Start android framework.
- // Assuming that android framework will perform the necessary steps after
- // this to put the device in working state.
- void TearDown() override;
- // Retrieve reference to wpa_supplicant's binder service.
- android::sp<ISupplicant> getBinderService();
- // Checks if wpa_supplicant's binder service is registered and visible.
- bool IsBinderServiceRegistered();
- // Creates a network interface for test using the hardcoded params:
- // |kWlan0IfaceName|, |kIfaceDriver|, |kIfaceConfigFile|.
- android::sp<IIface> CreateInterfaceForTest();
- // Removes the network interface created using |CreateInterfaceForTest|.
- void RemoveInterfaceForTest();
- // Add a network to the |iface|.
- android::sp<INetwork> AddNetworkForTest(const android::sp<IIface>& iface);
- // Removes a network with provided |network_id| from |iface|.
- void RemoveNetworkForTest(const android::sp<IIface>& iface, int network_id);
-
- android::sp<ISupplicant> service_;
- BinderDispatcher binder_dispatcher_;
-
- private:
- // Waits in a loop for a maximum of 10 milliseconds for the binder service to
- // be registered.
- void waitForBinderServiceRegistration();
- // Removes all the interfaces (|wlan0| & |p2p0|) controlled by
- // |wpa_supplicant|.
- // wpa_supplicant is started with |wlan0| and |p2p0| assigned in init.rc.
- void removeAllInterfaces();
- // Increase wpa_supplicant debug level to |DEBUG_LEVEL_EXCESSIVE|.
- void setDebugLevelToExcessive();
-
- std::unique_ptr<InterfaceTool> iface_tool_;
- std::unique_ptr<DriverTool> driver_tool_;
-}; // class WpaSupplicantBinderTestBase
-
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android
-
-#endif // WIFICOND_TESTS_INTEGRATION_WPA_SUPPLICANT_BINDER_TEST_BASE_H
+++ /dev/null
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "test_base.h"
-
-using testing::_;
-using testing::DoAll;
-using testing::Return;
-
-namespace android {
-namespace wificond {
-namespace wpa_supplicant_binder_test {
-
-// Verifies the |ISupplicant.CreateInterface| binder call.
-TEST_F(WpaSupplicantBinderTestBase, CreateInterface) {
- // Create the interface.
- CreateInterfaceForTest();
-
- android::sp<IIface> iface;
- android::binder::Status status =
- service_->GetInterface(kWlan0IfaceName, &iface);
- EXPECT_TRUE((status.isOk()) && (iface.get() != nullptr));
-}
-
-// Verifies the |ISupplicant.RemoveInterface| binder call.
-TEST_F(WpaSupplicantBinderTestBase, RemoveInterface) {
- CreateInterfaceForTest();
-
- RemoveInterfaceForTest();
-
- // The interface should no longer be present now.
- android::sp<IIface> iface;
- android::binder::Status status =
- service_->GetInterface(kWlan0IfaceName, &iface);
- EXPECT_TRUE(status.serviceSpecificErrorCode() ==
- ISupplicant::ERROR_IFACE_UNKNOWN);
-}
-
-// Verifies the |ISupplicant.GetDebugLevel|,
-// |ISupplicant.GetDebugShowTimestamp|, |ISupplicant.GetDebugShowKeys| binder
-// calls.
-TEST_F(WpaSupplicantBinderTestBase, GetDebugParams) {
- int debug_level;
- android::binder::Status status = service_->GetDebugLevel(&debug_level);
- EXPECT_TRUE((status.isOk()) &&
- (debug_level == ISupplicant::DEBUG_LEVEL_EXCESSIVE));
-
- bool debug_show_timestamp;
- status = service_->GetDebugShowTimestamp(&debug_show_timestamp);
- EXPECT_TRUE((status.isOk()) && (debug_show_timestamp));
-
- bool debug_show_keys;
- status = service_->GetDebugShowKeys(&debug_show_keys);
- EXPECT_TRUE((status.isOk()) && (debug_show_keys));
-}
-
-// Verifies the |IIface.GetName| binder call.
-TEST_F(WpaSupplicantBinderTestBase, GetNameOnInterface) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- std::string ifaceName;
- android::binder::Status status = iface->GetName(&ifaceName);
- EXPECT_TRUE((status.isOk()) && (ifaceName == kWlan0IfaceName));
-}
-
-// Verifies the |IIface.GetName| binder call on an interface
-// which has been removed.
-TEST_F(WpaSupplicantBinderTestBase, GetNameOnRemovedInterface) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- std::string ifaceName;
- android::binder::Status status = iface->GetName(&ifaceName);
- EXPECT_TRUE(ifaceName == kWlan0IfaceName);
-
- RemoveInterfaceForTest();
-
- // Any method call on the iface object should return failure.
- status = iface->GetName(&ifaceName);
- EXPECT_TRUE(status.serviceSpecificErrorCode() == IIface::ERROR_IFACE_INVALID);
-}
-
-// Verifies the |IIface.AddNetwork| binder call.
-TEST_F(WpaSupplicantBinderTestBase, AddNetworkOnInterface) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- AddNetworkForTest(iface);
-}
-
-// Verifies the |IIface.RemoveNetwork| binder call.
-TEST_F(WpaSupplicantBinderTestBase, RemoveNetworkOnInterface) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int network_id;
- android::binder::Status status = network->GetId(&network_id);
- EXPECT_TRUE(status.isOk());
-
- RemoveNetworkForTest(iface, network_id);
-
- // The network should no longer be present now.
- status = iface->GetNetwork(network_id, &network);
- EXPECT_TRUE(status.serviceSpecificErrorCode() ==
- IIface::ERROR_NETWORK_UNKNOWN);
-}
-
-// Verifies the |INetwork.GetId| binder call.
-TEST_F(WpaSupplicantBinderTestBase, GetIdOnNetwork) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int network_id;
- android::binder::Status status = network->GetId(&network_id);
- EXPECT_TRUE((status.isOk()) && (network_id == 0));
-}
-
-// Verifies the |INetwork.GetInterfaceName| binder call.
-TEST_F(WpaSupplicantBinderTestBase, GetInterfaceNameOnNetwork) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- std::string ifaceName;
- android::binder::Status status = network->GetInterfaceName(&ifaceName);
- EXPECT_TRUE((status.isOk()) && (ifaceName == kWlan0IfaceName));
-}
-
-// Verifies the |INetwork.GetId| binder call on a network
-// which has been removed.
-TEST_F(WpaSupplicantBinderTestBase, GetIdOnRemovedNetwork) {
- android::sp<IIface> iface = CreateInterfaceForTest();
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int network_id;
- android::binder::Status status = network->GetId(&network_id);
- EXPECT_TRUE((status.isOk()) && (network_id == 0));
-
- RemoveNetworkForTest(iface, network_id);
-
- // Any method call on the network object should return failure.
- status = network->GetId(&network_id);
- EXPECT_TRUE(status.serviceSpecificErrorCode() ==
- INetwork::ERROR_NETWORK_INVALID);
-}
-
-// Verifies the |ISupplicantCallback.OnInterfaceCreated| callback is
-// invoked by wpa_supplicant.
-TEST_F(WpaSupplicantBinderTestBase, OnInterfaceCreated) {
- // Register for supplicant service level state changes
- // (e.g. interface creation)
- android::sp<MockSupplicantCallback> callback(new MockSupplicantCallback);
- android::binder::Status status = service_->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk());
-
- CreateInterfaceForTest();
-
- // All registered |ISupplicantCallback| listeners should be notified
- // of any interface adddition.
- EXPECT_CALL(*callback, OnInterfaceCreated(kWlan0IfaceName))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
-
- // Wait for callback.
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kCallbackTimeoutMillis));
-}
-
-// Verifies the |ISupplicantCallback.OnInterfaceRemoved| callback is
-// invoked by wpa_supplicant.
-TEST_F(WpaSupplicantBinderTestBase, OnInterfaceRemoved) {
- // Register for supplicant service level state changes
- // (e.g. interface creation)
- android::sp<MockSupplicantCallback> callback(new MockSupplicantCallback);
- android::binder::Status status = service_->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk());
-
- CreateInterfaceForTest();
-
- RemoveInterfaceForTest();
-
- // All registered |ISupplicantCallback| listeners should be notified
- // of any interface adddition followed by interface removal.
- EXPECT_CALL(*callback, OnInterfaceCreated(kWlan0IfaceName))
- .WillOnce(Return(android::binder::Status::ok()));
- EXPECT_CALL(*callback, OnInterfaceRemoved(kWlan0IfaceName))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
-
- // Wait for callback.
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kCallbackTimeoutMillis));
-}
-
-// Verifies the |IIfaceCallback.OnNetworkAdded| callback is
-// invoked by wpa_supplicant.
-TEST_F(WpaSupplicantBinderTestBase, OnNetworkAdded) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- // First Register for |IIfaceCallback| using the corresponding |IIface|
- // object.
- android::sp<MockIfaceCallback> callback(new MockIfaceCallback);
- android::binder::Status status = iface->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk());
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
- int network_id;
- status = network->GetId(&network_id);
- EXPECT_TRUE(status.isOk());
-
- // All registered |IIfaceCallback| listeners should be notified
- // of any network adddition.
- EXPECT_CALL(*callback, OnNetworkAdded(network_id))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
-
- // Wait for callback.
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kCallbackTimeoutMillis));
-}
-
-// Verifies the |IIfaceCallback.OnNetworkRemoved| callback is
-// invoked by wpa_supplicant.
-TEST_F(WpaSupplicantBinderTestBase, OnNetworkRemoved) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- // First Register for |IIfaceCallback| using the corresponding |IIface|
- // object.
- android::sp<MockIfaceCallback> callback(new MockIfaceCallback);
- android::binder::Status status = iface->RegisterCallback(callback);
- EXPECT_TRUE(status.isOk());
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
- int network_id;
- status = network->GetId(&network_id);
- EXPECT_TRUE(status.isOk());
-
- RemoveNetworkForTest(iface, network_id);
-
- // All registered |IIfaceCallback| listeners should be notified
- // of any network adddition folled by the network removal.
- EXPECT_CALL(*callback, OnNetworkAdded(network_id))
- .WillOnce(Return(android::binder::Status::ok()));
- EXPECT_CALL(*callback, OnNetworkRemoved(network_id))
- .WillOnce(DoAll(InterrupBinderDispatcher(&binder_dispatcher_),
- Return(android::binder::Status::ok())));
- // Wait for callback.
- EXPECT_TRUE(binder_dispatcher_.DispatchFor(kCallbackTimeoutMillis));
-}
-
-// Verifies the |INetwork.SetSSID| & |INetwork.GetSSID|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetSSID) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- // Now set the ssid converting to a hex vector.
- std::vector<uint8_t> set_ssid_vec;
- set_ssid_vec.assign(kNetworkSSID, kNetworkSSID + strlen(kNetworkSSID));
- android::binder::Status status = network->SetSSID(set_ssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- std::vector<uint8_t> get_ssid_vec;
- status = network->GetSSID(&get_ssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(set_ssid_vec, get_ssid_vec);
-}
-
-// Verifies the |INetwork.SetBSSID| & |INetwork.GetBSSID|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetBSSID) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- // Now set the bssid converting to a hex vector.
- std::vector<uint8_t> set_bssid_vec;
- set_bssid_vec.assign(kNetworkBSSID, kNetworkBSSID + INetwork::BSSID_LEN);
- android::binder::Status status = network->SetBSSID(set_bssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- std::vector<uint8_t> get_bssid_vec;
- status = network->GetBSSID(&get_bssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(set_bssid_vec, get_bssid_vec);
-
- // Clear the bssid now.
- set_bssid_vec.clear();
- status = network->SetBSSID(set_bssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- status = network->GetBSSID(&get_bssid_vec);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're cleared.
- EXPECT_TRUE(get_bssid_vec.empty());
-}
-
-// Verifies the |INetwork.SetScanSSID| & |INetwork.GetScanSSID|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetScanSSID) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- bool set_scan_ssid = true;
- android::binder::Status status = network->SetScanSSID(set_scan_ssid);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- bool get_scan_ssid;
- status = network->GetScanSSID(&get_scan_ssid);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(set_scan_ssid, get_scan_ssid);
-}
-
-// Verifies the |INetwork.SetRequirePMF| & |INetwork.GetRequirePMF|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetRequirePMF) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- bool set_require_pmf = true;
- android::binder::Status status = network->SetRequirePMF(set_require_pmf);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- bool get_require_pmf;
- status = network->GetRequirePMF(&get_require_pmf);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(set_require_pmf, get_require_pmf);
-}
-
-// Verifies the |INetwork.SetPskPassphrase| & |INetwork.GetPskPassphrase|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetPskPassphrase) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- android::binder::Status status =
- network->SetPskPassphrase(kNetworkPassphrase);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- std::string get_psk_passphrase;
- status = network->GetPskPassphrase(&get_psk_passphrase);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(kNetworkPassphrase, get_psk_passphrase);
-}
-
-// Verifies the |INetwork.SetWepTxKeyIdx| & |INetwork.GetWepTxKeyIdx|
-// binder calls on a network.
-TEST_F(WpaSupplicantBinderTestBase, NetworkSetGetWepTxKeyIdx) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- // Add network now.
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_idx = 1;
- android::binder::Status status = network->SetWepTxKeyIdx(set_idx);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_idx;
- status = network->GetWepTxKeyIdx(&get_idx);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(set_idx, get_idx);
-}
-
-// Verifies the |INetwork.SetWepKey| & |INetwork.GetWepKey|
-// binder calls on a network.
-class NetworkWepKeyTest
- : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<std::vector<uint8_t>> {};
-
-TEST_P(NetworkWepKeyTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- std::vector<uint8_t> set_wep_key = GetParam();
- android::binder::Status status;
- for (int i = 0; i < fi::w1::wpa_supplicant::INetwork::WEP_KEYS_MAX_NUM; i++) {
- status = network->SetWepKey(i, set_wep_key);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- }
-
- std::vector<uint8_t> get_wep_key;
- for (int i = 0; i < fi::w1::wpa_supplicant::INetwork::WEP_KEYS_MAX_NUM; i++) {
- status = network->GetWepKey(i, &get_wep_key);
- EXPECT_TRUE(status.isOk()) << status.toString8();
- // Ensure they're the same.
- EXPECT_EQ(get_wep_key, set_wep_key);
- }
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetWepKey, NetworkWepKeyTest,
- ::testing::Values(std::vector<uint8_t>({0x56, 0x67, 0x67, 0xf4, 0x56}),
- std::vector<uint8_t>({0x56, 0x67, 0x67, 0xf4, 0x56, 0x89,
- 0xad, 0x67, 0x78, 0x89, 0x97, 0xa5,
- 0xde})));
-
-// Verifies the |INetwork.SetKeyMgmt| & |INetwork.GetKeyMgmt|
-// binder calls on a network.
-class NetworkKeyMgmtTest : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<int> {};
-
-TEST_P(NetworkKeyMgmtTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_mask = GetParam();
- android::binder::Status status = network->SetKeyMgmt(set_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_mask;
- status = network->GetKeyMgmt(&get_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(get_mask, set_mask);
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetKeyMgmt, NetworkKeyMgmtTest,
- ::testing::Values(
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_NONE,
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_PSK,
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_WPA_PSK,
- fi::w1::wpa_supplicant::INetwork::KEY_MGMT_MASK_IEEE8021X));
-
-// Verifies the |INetwork.SetProto| & |INetwork.GetProto|
-// binder calls on a network.
-class NetworkProtoTest : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<int> {};
-
-TEST_P(NetworkProtoTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_mask = GetParam();
- android::binder::Status status = network->SetProto(set_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_mask;
- status = network->GetProto(&get_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(get_mask, set_mask);
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetProto, NetworkProtoTest,
- ::testing::Values(fi::w1::wpa_supplicant::INetwork::PROTO_MASK_WPA,
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_RSN,
- fi::w1::wpa_supplicant::INetwork::PROTO_MASK_OSEN));
-
-// Verifies the |INetwork.SetAuthAlg| & |INetwork.GetAuthAlg|
-// binder calls on a network.
-class NetworkAuthAlgTest : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<int> {};
-
-TEST_P(NetworkAuthAlgTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_mask = GetParam();
- android::binder::Status status = network->SetAuthAlg(set_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_mask;
- status = network->GetAuthAlg(&get_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(get_mask, set_mask);
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetAuthAlg, NetworkAuthAlgTest,
- ::testing::Values(fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_OPEN,
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_SHARED,
- fi::w1::wpa_supplicant::INetwork::AUTH_ALG_MASK_LEAP));
-
-// Verifies the |INetwork.SetGroupCipher| & |INetwork.GetGroupCipher|
-// binder calls on a network.
-class NetworkGroupCipherTest : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<int> {};
-
-TEST_P(NetworkGroupCipherTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_mask = GetParam();
- android::binder::Status status = network->SetGroupCipher(set_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_mask;
- status = network->GetGroupCipher(&get_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(get_mask, set_mask);
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetGroupCipher, NetworkGroupCipherTest,
- ::testing::Values(
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP40,
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_WEP104,
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_TKIP,
- fi::w1::wpa_supplicant::INetwork::GROUP_CIPHER_MASK_CCMP));
-
-// Verifies the |INetwork.SetPairwiseCipher| & |INetwork.GetPairwiseCipher|
-// binder calls on a network.
-class NetworkPairwiseCipherTest : public WpaSupplicantBinderTestBase,
- public ::testing::WithParamInterface<int> {};
-
-TEST_P(NetworkPairwiseCipherTest, SetGet) {
- android::sp<IIface> iface = CreateInterfaceForTest();
-
- // Add network now.
- android::sp<INetwork> network = AddNetworkForTest(iface);
-
- int set_mask = GetParam();
- android::binder::Status status = network->SetPairwiseCipher(set_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- int get_mask;
- status = network->GetPairwiseCipher(&get_mask);
- EXPECT_TRUE(status.isOk()) << status.toString8();
-
- // Ensure they're the same.
- EXPECT_EQ(get_mask, set_mask);
-}
-
-INSTANTIATE_TEST_CASE_P(
- NetworkSetGetPairwiseCipher, NetworkPairwiseCipherTest,
- ::testing::Values(
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_NONE,
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_TKIP,
- fi::w1::wpa_supplicant::INetwork::PAIRWISE_CIPHER_MASK_CCMP));
-
-} // namespace wpa_supplicant_binder_test
-} // namespace wificond
-} // namespace android