Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Gabriel Biren | bd150ea | 2022-11-04 21:45:53 +0000 | [diff] [blame] | 16 | #include <aidl/android/hardware/wifi/IWifi.h> |
Gabriel Biren | e80aabb | 2022-12-01 22:24:16 +0000 | [diff] [blame] | 17 | #include <android/hardware/wifi/1.0/IWifi.h> |
| 18 | #include <android/hardware/wifi/hostapd/1.3/IHostapd.h> |
Chris Ye | 02c7bb3 | 2022-01-13 12:13:48 -0800 | [diff] [blame] | 19 | |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 20 | #include <VtsCoreUtil.h> |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 21 | #include <aidl/Gtest.h> |
| 22 | #include <aidl/Vintf.h> |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 23 | #include <aidl/android/hardware/wifi/hostapd/BnHostapd.h> |
| 24 | #include <aidl/android/hardware/wifi/hostapd/BnHostapdCallback.h> |
| 25 | #include <android/binder_manager.h> |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 26 | #include <binder/IServiceManager.h> |
| 27 | #include <binder/ProcessState.h> |
Gabriel Biren | e80aabb | 2022-12-01 22:24:16 +0000 | [diff] [blame] | 28 | #include <hidl/ServiceManagement.h> |
| 29 | #include <hostapd_hidl_call_util.h> |
| 30 | #include <hostapd_hidl_test_utils.h> |
| 31 | #include <wifi_hidl_test_utils.h> |
| 32 | #include <wifi_hidl_test_utils_1_5.h> |
Gabriel Biren | cd6da07 | 2023-06-05 18:13:31 +0000 | [diff] [blame] | 33 | #include <wifi_hidl_test_utils_1_6.h> |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 34 | |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 35 | #include "hostapd_test_utils.h" |
Gabriel Biren | bd150ea | 2022-11-04 21:45:53 +0000 | [diff] [blame] | 36 | #include "wifi_aidl_test_utils.h" |
| 37 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 38 | using aidl::android::hardware::wifi::hostapd::BandMask; |
| 39 | using aidl::android::hardware::wifi::hostapd::BnHostapdCallback; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 40 | using aidl::android::hardware::wifi::hostapd::ChannelBandwidth; |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 41 | using aidl::android::hardware::wifi::hostapd::ChannelParams; |
| 42 | using aidl::android::hardware::wifi::hostapd::DebugLevel; |
| 43 | using aidl::android::hardware::wifi::hostapd::EncryptionType; |
| 44 | using aidl::android::hardware::wifi::hostapd::FrequencyRange; |
| 45 | using aidl::android::hardware::wifi::hostapd::Ieee80211ReasonCode; |
| 46 | using aidl::android::hardware::wifi::hostapd::IfaceParams; |
| 47 | using aidl::android::hardware::wifi::hostapd::IHostapd; |
| 48 | using aidl::android::hardware::wifi::hostapd::NetworkParams; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 49 | using android::ProcessState; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 50 | |
| 51 | namespace { |
| 52 | const unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', '2', '3', '4', '5'}; |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 53 | const std::string kPassphrase = "test12345"; |
| 54 | const std::string kInvalidMinPassphrase = "test"; |
| 55 | const std::string kInvalidMaxPassphrase = |
| 56 | "0123456789012345678901234567890123456789012345678901234567890123456789"; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 57 | const int kIfaceChannel = 6; |
| 58 | const int kIfaceInvalidChannel = 567; |
| 59 | const std::vector<uint8_t> kTestZeroMacAddr(6, 0x0); |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 60 | const Ieee80211ReasonCode kTestDisconnectReasonCode = Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 61 | |
| 62 | inline BandMask operator|(BandMask a, BandMask b) { |
| 63 | return static_cast<BandMask>(static_cast<int32_t>(a) | |
| 64 | static_cast<int32_t>(b)); |
| 65 | } |
| 66 | } // namespace |
| 67 | |
| 68 | class HostapdAidl : public testing::TestWithParam<std::string> { |
| 69 | public: |
| 70 | virtual void SetUp() override { |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 71 | disableHalsAndFramework(); |
| 72 | initializeHostapdAndVendorHal(GetParam()); |
| 73 | |
| 74 | hostapd = getHostapd(GetParam()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 75 | ASSERT_NE(hostapd, nullptr); |
| 76 | EXPECT_TRUE(hostapd->setDebugParams(DebugLevel::EXCESSIVE).isOk()); |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 77 | |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 78 | isAcsSupport = testing::checkSubstringInCommandOutput( |
| 79 | "/system/bin/cmd wifi get-softap-supported-features", |
| 80 | "wifi_softap_acs_supported"); |
| 81 | isWpa3SaeSupport = testing::checkSubstringInCommandOutput( |
| 82 | "/system/bin/cmd wifi get-softap-supported-features", |
| 83 | "wifi_softap_wpa3_sae_supported"); |
| 84 | isBridgedSupport = testing::checkSubstringInCommandOutput( |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 85 | "/system/bin/cmd wifi get-softap-supported-features", |
| 86 | "wifi_softap_bridged_ap_supported"); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | virtual void TearDown() override { |
| 90 | hostapd->terminate(); |
| 91 | // Wait 3 seconds to allow terminate to complete |
| 92 | sleep(3); |
Gabriel Biren | c6cacf6 | 2023-07-19 17:24:21 +0000 | [diff] [blame] | 93 | stopHostapdAndVendorHal(); |
| 94 | startWifiFramework(); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 97 | std::shared_ptr<IHostapd> hostapd; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 98 | bool isAcsSupport; |
| 99 | bool isWpa3SaeSupport; |
| 100 | bool isBridgedSupport; |
| 101 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 102 | IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 103 | IfaceParams iface_params; |
| 104 | ChannelParams channelParams; |
| 105 | std::vector<ChannelParams> vec_channelParams; |
| 106 | |
| 107 | iface_params.name = iface_name; |
| 108 | iface_params.hwModeParams.enable80211N = true; |
| 109 | iface_params.hwModeParams.enable80211AC = false; |
| 110 | iface_params.hwModeParams.enable80211AX = false; |
| 111 | iface_params.hwModeParams.enable6GhzBand = false; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 112 | iface_params.hwModeParams.maximumChannelBandwidth = ChannelBandwidth::BANDWIDTH_20; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 113 | |
| 114 | channelParams.enableAcs = false; |
| 115 | channelParams.acsShouldExcludeDfs = false; |
| 116 | channelParams.channel = kIfaceChannel; |
| 117 | channelParams.bandMask = BandMask::BAND_2_GHZ; |
| 118 | |
| 119 | vec_channelParams.push_back(channelParams); |
| 120 | iface_params.channelParams = vec_channelParams; |
| 121 | return iface_params; |
| 122 | } |
| 123 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 124 | IfaceParams getIfaceParamsWithBridgedModeACS(std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 125 | IfaceParams iface_params = getIfaceParamsWithoutAcs(iface_name); |
| 126 | iface_params.channelParams[0].enableAcs = true; |
| 127 | iface_params.channelParams[0].acsShouldExcludeDfs = true; |
| 128 | |
| 129 | std::vector<ChannelParams> vec_channelParams; |
| 130 | vec_channelParams.push_back(iface_params.channelParams[0]); |
| 131 | |
| 132 | ChannelParams second_channelParams; |
| 133 | second_channelParams.channel = 0; |
| 134 | second_channelParams.enableAcs = true; |
| 135 | second_channelParams.bandMask = BandMask::BAND_5_GHZ; |
| 136 | vec_channelParams.push_back(second_channelParams); |
| 137 | |
| 138 | iface_params.channelParams = vec_channelParams; |
| 139 | return iface_params; |
| 140 | } |
| 141 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 142 | IfaceParams getIfaceParamsWithAcs(std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 143 | IfaceParams iface_params = getIfaceParamsWithoutAcs(iface_name); |
| 144 | iface_params.channelParams[0].enableAcs = true; |
| 145 | iface_params.channelParams[0].acsShouldExcludeDfs = true; |
| 146 | iface_params.channelParams[0].channel = 0; |
| 147 | iface_params.channelParams[0].bandMask = |
| 148 | iface_params.channelParams[0].bandMask | BandMask::BAND_5_GHZ; |
| 149 | return iface_params; |
| 150 | } |
| 151 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 152 | IfaceParams getIfaceParamsWithAcsAndFreqRange(std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 153 | IfaceParams iface_params = getIfaceParamsWithAcs(iface_name); |
| 154 | FrequencyRange freqRange; |
| 155 | freqRange.startMhz = 2412; |
| 156 | freqRange.endMhz = 2462; |
| 157 | std::vector<FrequencyRange> vec_FrequencyRange; |
| 158 | vec_FrequencyRange.push_back(freqRange); |
| 159 | iface_params.channelParams[0].acsChannelFreqRangesMhz = |
| 160 | vec_FrequencyRange; |
| 161 | return iface_params; |
| 162 | } |
| 163 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 164 | IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange( |
| 165 | std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 166 | IfaceParams iface_params = |
| 167 | getIfaceParamsWithAcsAndFreqRange(iface_name); |
| 168 | iface_params.channelParams[0].acsChannelFreqRangesMhz[0].startMhz = |
| 169 | 222; |
| 170 | iface_params.channelParams[0].acsChannelFreqRangesMhz[0].endMhz = |
| 171 | 999; |
| 172 | return iface_params; |
| 173 | } |
| 174 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 175 | IfaceParams getIfaceParamsWithInvalidChannel(std::string iface_name) { |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 176 | IfaceParams iface_params = getIfaceParamsWithoutAcs(iface_name); |
| 177 | iface_params.channelParams[0].channel = kIfaceInvalidChannel; |
| 178 | return iface_params; |
| 179 | } |
| 180 | |
| 181 | NetworkParams getOpenNwParams() { |
| 182 | NetworkParams nw_params; |
| 183 | nw_params.ssid = |
| 184 | std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); |
| 185 | nw_params.isHidden = false; |
| 186 | nw_params.encryptionType = EncryptionType::NONE; |
| 187 | nw_params.isMetered = true; |
| 188 | return nw_params; |
| 189 | } |
| 190 | |
| 191 | NetworkParams getPskNwParamsWithNonMetered() { |
| 192 | NetworkParams nw_params = getOpenNwParams(); |
| 193 | nw_params.encryptionType = EncryptionType::WPA2; |
| 194 | nw_params.passphrase = kPassphrase; |
| 195 | nw_params.isMetered = false; |
| 196 | return nw_params; |
| 197 | } |
| 198 | |
| 199 | NetworkParams getPskNwParams() { |
| 200 | NetworkParams nw_params = getOpenNwParams(); |
| 201 | nw_params.encryptionType = EncryptionType::WPA2; |
| 202 | nw_params.passphrase = kPassphrase; |
| 203 | return nw_params; |
| 204 | } |
| 205 | |
| 206 | NetworkParams getInvalidPskNwParams() { |
| 207 | NetworkParams nw_params = getOpenNwParams(); |
| 208 | nw_params.encryptionType = EncryptionType::WPA2; |
| 209 | nw_params.passphrase = kInvalidMaxPassphrase; |
| 210 | return nw_params; |
| 211 | } |
| 212 | |
| 213 | NetworkParams getSaeTransitionNwParams() { |
| 214 | NetworkParams nw_params = getOpenNwParams(); |
| 215 | nw_params.encryptionType = EncryptionType::WPA3_SAE_TRANSITION; |
| 216 | nw_params.passphrase = kPassphrase; |
| 217 | return nw_params; |
| 218 | } |
| 219 | |
| 220 | NetworkParams getInvalidSaeTransitionNwParams() { |
| 221 | NetworkParams nw_params = getOpenNwParams(); |
| 222 | nw_params.encryptionType = EncryptionType::WPA2; |
| 223 | nw_params.passphrase = kInvalidMinPassphrase; |
| 224 | return nw_params; |
| 225 | } |
| 226 | |
| 227 | NetworkParams getSaeNwParams() { |
| 228 | NetworkParams nw_params = getOpenNwParams(); |
| 229 | nw_params.encryptionType = EncryptionType::WPA3_SAE; |
| 230 | nw_params.passphrase = kPassphrase; |
| 231 | return nw_params; |
| 232 | } |
| 233 | |
| 234 | NetworkParams getInvalidSaeNwParams() { |
| 235 | NetworkParams nw_params = getOpenNwParams(); |
| 236 | nw_params.encryptionType = EncryptionType::WPA3_SAE; |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 237 | nw_params.passphrase = ""; |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 238 | return nw_params; |
| 239 | } |
| 240 | }; |
| 241 | |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 242 | class HostapdCallback : public BnHostapdCallback { |
| 243 | public: |
| 244 | HostapdCallback() = default; |
| 245 | ::ndk::ScopedAStatus onApInstanceInfoChanged( |
| 246 | const ::aidl::android::hardware::wifi::hostapd::ApInfo &) override { |
| 247 | return ndk::ScopedAStatus::ok(); |
| 248 | } |
| 249 | ::ndk::ScopedAStatus onConnectedClientsChanged( |
| 250 | const ::aidl::android::hardware::wifi::hostapd::ClientInfo &) override { |
| 251 | return ndk::ScopedAStatus::ok(); |
| 252 | } |
Les Lee | 6645e9e | 2021-10-29 16:04:23 +0800 | [diff] [blame] | 253 | ::ndk::ScopedAStatus onFailure(const std::string&, const std::string&) override { |
Gabriel Biren | b3eb504 | 2021-11-03 19:40:44 +0000 | [diff] [blame] | 254 | return ndk::ScopedAStatus::ok(); |
| 255 | } |
| 256 | }; |
| 257 | |
| 258 | /** |
| 259 | * Register callback |
| 260 | */ |
| 261 | TEST_P(HostapdAidl, RegisterCallback) { |
| 262 | std::shared_ptr<HostapdCallback> callback = |
| 263 | ndk::SharedRefBase::make<HostapdCallback>(); |
| 264 | ASSERT_NE(callback, nullptr); |
| 265 | EXPECT_TRUE(hostapd->registerCallback(callback).isOk()); |
| 266 | } |
| 267 | |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 268 | /** |
| 269 | * Adds an access point with PSK network config & ACS enabled. |
| 270 | * Access point creation should pass. |
| 271 | */ |
| 272 | TEST_P(HostapdAidl, AddPskAccessPointWithAcs) { |
| 273 | if (!isAcsSupport) GTEST_SKIP() << "Missing ACS support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 274 | std::string ifname = setupApIfaceAndGetName(false); |
| 275 | auto status = hostapd->addAccessPoint(getIfaceParamsWithAcs(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 276 | EXPECT_TRUE(status.isOk()); |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Adds an access point with PSK network config, ACS enabled & frequency Range. |
| 281 | * Access point creation should pass. |
| 282 | */ |
| 283 | TEST_P(HostapdAidl, AddPskAccessPointWithAcsAndFreqRange) { |
| 284 | if (!isAcsSupport) GTEST_SKIP() << "Missing ACS support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 285 | std::string ifname = setupApIfaceAndGetName(false); |
| 286 | auto status = |
| 287 | hostapd->addAccessPoint(getIfaceParamsWithAcsAndFreqRange(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 288 | EXPECT_TRUE(status.isOk()); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Adds an access point with invalid channel range. |
| 293 | * Access point creation should fail. |
| 294 | */ |
| 295 | TEST_P(HostapdAidl, AddPskAccessPointWithAcsAndInvalidFreqRange) { |
| 296 | if (!isAcsSupport) GTEST_SKIP() << "Missing ACS support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 297 | std::string ifname = setupApIfaceAndGetName(false); |
| 298 | auto status = hostapd->addAccessPoint(getIfaceParamsWithAcsAndInvalidFreqRange(ifname), |
| 299 | getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 300 | EXPECT_FALSE(status.isOk()); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Adds an access point with Open network config & ACS enabled. |
| 305 | * Access point creation should pass. |
| 306 | */ |
| 307 | TEST_P(HostapdAidl, AddOpenAccessPointWithAcs) { |
| 308 | if (!isAcsSupport) GTEST_SKIP() << "Missing ACS support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 309 | std::string ifname = setupApIfaceAndGetName(false); |
| 310 | auto status = hostapd->addAccessPoint(getIfaceParamsWithAcs(ifname), getOpenNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 311 | EXPECT_TRUE(status.isOk()); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Adds an access point with PSK network config & ACS disabled. |
| 316 | * Access point creation should pass. |
| 317 | */ |
| 318 | TEST_P(HostapdAidl, AddPskAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 319 | std::string ifname = setupApIfaceAndGetName(false); |
| 320 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 321 | EXPECT_TRUE(status.isOk()); |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Adds an access point with PSK network config, ACS disabled & Non metered. |
| 326 | * Access point creation should pass. |
| 327 | */ |
| 328 | TEST_P(HostapdAidl, AddPskAccessPointWithoutAcsAndNonMetered) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 329 | std::string ifname = setupApIfaceAndGetName(false); |
| 330 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 331 | getPskNwParamsWithNonMetered()); |
| 332 | EXPECT_TRUE(status.isOk()); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Adds an access point with Open network config & ACS disabled. |
| 337 | * Access point creation should pass. |
| 338 | */ |
| 339 | TEST_P(HostapdAidl, AddOpenAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 340 | std::string ifname = setupApIfaceAndGetName(false); |
| 341 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getOpenNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 342 | EXPECT_TRUE(status.isOk()); |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Adds an access point with SAE Transition network config & ACS disabled. |
| 347 | * Access point creation should pass. |
| 348 | */ |
| 349 | TEST_P(HostapdAidl, AddSaeTransitionAccessPointWithoutAcs) { |
| 350 | if (!isWpa3SaeSupport) GTEST_SKIP() << "Missing SAE support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 351 | std::string ifname = setupApIfaceAndGetName(false); |
| 352 | auto status = |
| 353 | hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getSaeTransitionNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 354 | EXPECT_TRUE(status.isOk()); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Adds an access point with SAE network config & ACS disabled. |
| 359 | * Access point creation should pass. |
| 360 | */ |
| 361 | TEST_P(HostapdAidl, AddSAEAccessPointWithoutAcs) { |
| 362 | if (!isWpa3SaeSupport) GTEST_SKIP() << "Missing SAE support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 363 | std::string ifname = setupApIfaceAndGetName(false); |
| 364 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getSaeNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 365 | EXPECT_TRUE(status.isOk()); |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Adds & then removes an access point with PSK network config & ACS enabled. |
| 370 | * Access point creation & removal should pass. |
| 371 | */ |
| 372 | TEST_P(HostapdAidl, RemoveAccessPointWithAcs) { |
| 373 | if (!isAcsSupport) GTEST_SKIP() << "Missing ACS support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 374 | std::string ifname = setupApIfaceAndGetName(false); |
| 375 | auto status = hostapd->addAccessPoint(getIfaceParamsWithAcs(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 376 | EXPECT_TRUE(status.isOk()); |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 377 | EXPECT_TRUE(hostapd->removeAccessPoint(ifname).isOk()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Adds & then removes an access point with PSK network config & ACS disabled. |
| 382 | * Access point creation & removal should pass. |
| 383 | */ |
| 384 | TEST_P(HostapdAidl, RemoveAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 385 | std::string ifname = setupApIfaceAndGetName(false); |
| 386 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 387 | EXPECT_TRUE(status.isOk()); |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 388 | EXPECT_TRUE(hostapd->removeAccessPoint(ifname).isOk()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Adds an access point with invalid channel. |
| 393 | * Access point creation should fail. |
| 394 | */ |
| 395 | TEST_P(HostapdAidl, AddPskAccessPointWithInvalidChannel) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 396 | std::string ifname = setupApIfaceAndGetName(false); |
| 397 | auto status = |
| 398 | hostapd->addAccessPoint(getIfaceParamsWithInvalidChannel(ifname), getPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 399 | EXPECT_FALSE(status.isOk()); |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Adds an access point with invalid PSK network config. |
| 404 | * Access point creation should fail. |
| 405 | */ |
| 406 | TEST_P(HostapdAidl, AddInvalidPskAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 407 | std::string ifname = setupApIfaceAndGetName(false); |
| 408 | auto status = |
| 409 | hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getInvalidPskNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 410 | EXPECT_FALSE(status.isOk()); |
| 411 | } |
| 412 | |
| 413 | /** |
| 414 | * Adds an access point with invalid SAE transition network config. |
| 415 | * Access point creation should fail. |
| 416 | */ |
| 417 | TEST_P(HostapdAidl, AddInvalidSaeTransitionAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 418 | std::string ifname = setupApIfaceAndGetName(false); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 419 | if (!isWpa3SaeSupport) GTEST_SKIP() << "Missing SAE support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 420 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 421 | getInvalidSaeTransitionNwParams()); |
| 422 | EXPECT_FALSE(status.isOk()); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Adds an access point with invalid SAE network config. |
| 427 | * Access point creation should fail. |
| 428 | */ |
| 429 | TEST_P(HostapdAidl, AddInvalidSaeAccessPointWithoutAcs) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 430 | std::string ifname = setupApIfaceAndGetName(false); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 431 | if (!isWpa3SaeSupport) GTEST_SKIP() << "Missing SAE support"; |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 432 | auto status = |
| 433 | hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getInvalidSaeNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 434 | EXPECT_FALSE(status.isOk()); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * forceClientDisconnect should fail when hotspot interface available. |
| 439 | */ |
| 440 | TEST_P(HostapdAidl, DisconnectClientWhenIfacAvailable) { |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 441 | std::string ifname = setupApIfaceAndGetName(false); |
| 442 | auto status = hostapd->addAccessPoint(getIfaceParamsWithoutAcs(ifname), getOpenNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 443 | EXPECT_TRUE(status.isOk()); |
| 444 | |
Chris Ye | c04af1c | 2022-03-28 18:42:23 -0700 | [diff] [blame] | 445 | status = hostapd->forceClientDisconnect(ifname, kTestZeroMacAddr, kTestDisconnectReasonCode); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 446 | EXPECT_FALSE(status.isOk()); |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * AddAccessPointWithDualBandConfig should pass |
| 451 | */ |
| 452 | TEST_P(HostapdAidl, AddAccessPointWithDualBandConfig) { |
| 453 | if (!isBridgedSupport) GTEST_SKIP() << "Missing Bridged AP support"; |
Chris Ye | 02c7bb3 | 2022-01-13 12:13:48 -0800 | [diff] [blame] | 454 | std::string ifname = setupApIfaceAndGetName(true); |
| 455 | auto status = |
| 456 | hostapd->addAccessPoint(getIfaceParamsWithBridgedModeACS(ifname), getOpenNwParams()); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 457 | EXPECT_TRUE(status.isOk()); |
| 458 | } |
| 459 | |
Gabriel Biren | 962d5df | 2022-01-12 23:15:17 +0000 | [diff] [blame] | 460 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HostapdAidl); |
Chris Ye | d13f7b5 | 2021-06-24 12:52:55 -0700 | [diff] [blame] | 461 | INSTANTIATE_TEST_SUITE_P( |
| 462 | Hostapd, HostapdAidl, |
| 463 | testing::ValuesIn(android::getAidlHalInstanceNames(IHostapd::descriptor)), |
| 464 | android::PrintInstanceNameToString); |
| 465 | |
| 466 | int main(int argc, char **argv) { |
| 467 | ::testing::InitGoogleTest(&argc, argv); |
| 468 | ProcessState::self()->setThreadPoolMaxThreadCount(1); |
| 469 | ProcessState::self()->startThreadPool(); |
| 470 | return RUN_ALL_TESTS(); |
| 471 | } |