1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci#include <gtest/gtest.h>
16094332d3Sopenharmony_ci#include <servmgr_hdi.h>
17094332d3Sopenharmony_ci#include <osal_mem.h>
18094332d3Sopenharmony_ci#include "v1_1/iwpa_interface.h"
19094332d3Sopenharmony_ci#include "wpa_callback_impl.h"
20094332d3Sopenharmony_ci#include "securec.h"
21094332d3Sopenharmony_ci
22094332d3Sopenharmony_ci#define IFNAME "wlan0"
23094332d3Sopenharmony_ci#define CONFNAME "/data/service/el1/public/wifi/wpa_supplicant/wpa_supplicant.conf"
24094332d3Sopenharmony_ci
25094332d3Sopenharmony_ci#define HDF_LOG_TAG service_manager_test
26094332d3Sopenharmony_ciusing namespace testing::ext;
27094332d3Sopenharmony_ci
28094332d3Sopenharmony_cinamespace HdiWpaDirectTest {
29094332d3Sopenharmony_ciconst char *g_wlanServiceNameWpa = "wpa_interface_service";
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_ciclass HdfWpaHostDirectTest : public testing::Test {
32094332d3Sopenharmony_cipublic:
33094332d3Sopenharmony_ci    static void SetUpTestCase();
34094332d3Sopenharmony_ci    static void TearDownTestCase();
35094332d3Sopenharmony_ci    void SetUp();
36094332d3Sopenharmony_ci    void TearDown();
37094332d3Sopenharmony_ci};
38094332d3Sopenharmony_ci
39094332d3Sopenharmony_cistatic struct IWpaInterface *g_wpaObj = nullptr;
40094332d3Sopenharmony_cistruct IWpaCallback *g_wpaCallbackObj = nullptr;
41094332d3Sopenharmony_civoid HdfWpaHostDirectTest::SetUpTestCase()
42094332d3Sopenharmony_ci{
43094332d3Sopenharmony_ci    g_wpaObj = IWpaInterfaceGetInstance(g_wlanServiceNameWpa, true);
44094332d3Sopenharmony_ci    g_wpaCallbackObj = WpaCallbackServiceGet();
45094332d3Sopenharmony_ci    ASSERT_TRUE(g_wpaObj != nullptr);
46094332d3Sopenharmony_ci    ASSERT_TRUE(g_wpaCallbackObj != nullptr);
47094332d3Sopenharmony_ci}
48094332d3Sopenharmony_ci
49094332d3Sopenharmony_civoid HdfWpaHostDirectTest::TearDownTestCase()
50094332d3Sopenharmony_ci{
51094332d3Sopenharmony_ci    IWpaInterfaceReleaseInstance(g_wlanServiceNameWpa, g_wpaObj, true);
52094332d3Sopenharmony_ci    WpaCallbackServiceRelease(g_wpaCallbackObj);
53094332d3Sopenharmony_ci}
54094332d3Sopenharmony_ci
55094332d3Sopenharmony_civoid HdfWpaHostDirectTest::SetUp()
56094332d3Sopenharmony_ci{
57094332d3Sopenharmony_ci}
58094332d3Sopenharmony_ci
59094332d3Sopenharmony_civoid HdfWpaHostDirectTest::TearDown()
60094332d3Sopenharmony_ci{
61094332d3Sopenharmony_ci}
62094332d3Sopenharmony_ci
63094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, AddWpaIfaceTest_001, TestSize.Level1)
64094332d3Sopenharmony_ci{
65094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->AddWpaIface(g_wpaObj, IFNAME, CONFNAME);
66094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
67094332d3Sopenharmony_ci    rc = g_wpaObj->AddWpaIface(g_wpaObj, nullptr, CONFNAME);
68094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
69094332d3Sopenharmony_ci}
70094332d3Sopenharmony_ci
71094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, ScanTest_002, TestSize.Level1)
72094332d3Sopenharmony_ci{
73094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->Scan(g_wpaObj, IFNAME);
74094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
75094332d3Sopenharmony_ci    rc = g_wpaObj->Scan(g_wpaObj, nullptr);
76094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
77094332d3Sopenharmony_ci}
78094332d3Sopenharmony_ci
79094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, ScanResultTest_003, TestSize.Level1)
80094332d3Sopenharmony_ci{
81094332d3Sopenharmony_ci    unsigned char *resultBuf = (unsigned char *)calloc(4096 * 10, sizeof(unsigned char));
82094332d3Sopenharmony_ci    uint32_t resultBufLen = 4096 * 10;
83094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->ScanResult(g_wpaObj, IFNAME, resultBuf, &resultBufLen);
84094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
85094332d3Sopenharmony_ci    rc = g_wpaObj->ScanResult(g_wpaObj, nullptr, resultBuf, &resultBufLen);
86094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
87094332d3Sopenharmony_ci    rc = g_wpaObj->ScanResult(g_wpaObj, IFNAME, nullptr, &resultBufLen);
88094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
89094332d3Sopenharmony_ci    free(resultBuf);
90094332d3Sopenharmony_ci}
91094332d3Sopenharmony_ci
92094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, AddNetworkTest_004, TestSize.Level1)
93094332d3Sopenharmony_ci{
94094332d3Sopenharmony_ci    int networkId = 0;
95094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->AddNetwork(g_wpaObj, IFNAME, &networkId);
96094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
97094332d3Sopenharmony_ci    rc = g_wpaObj->AddNetwork(g_wpaObj, nullptr, &networkId);
98094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
99094332d3Sopenharmony_ci}
100094332d3Sopenharmony_ci
101094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, RemoveNetworkTest_005, TestSize.Level1)
102094332d3Sopenharmony_ci{
103094332d3Sopenharmony_ci    int networkId = 0;
104094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->RemoveNetwork(g_wpaObj, IFNAME, networkId);
105094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
106094332d3Sopenharmony_ci    rc = g_wpaObj->RemoveNetwork(g_wpaObj, nullptr, networkId);
107094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
108094332d3Sopenharmony_ci}
109094332d3Sopenharmony_ci
110094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, DisableNetworkTest_006, TestSize.Level1)
111094332d3Sopenharmony_ci{
112094332d3Sopenharmony_ci    int networkId = 0;
113094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->DisableNetwork(g_wpaObj, IFNAME, networkId);
114094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
115094332d3Sopenharmony_ci    rc = g_wpaObj->DisableNetwork(g_wpaObj, nullptr, networkId);
116094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
117094332d3Sopenharmony_ci}
118094332d3Sopenharmony_ci
119094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SetNetworkTest_007, TestSize.Level1)
120094332d3Sopenharmony_ci{
121094332d3Sopenharmony_ci    int networkId = 0;
122094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SetNetwork(g_wpaObj, IFNAME, networkId, "ssid", "WIFI_5G");
123094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
124094332d3Sopenharmony_ci    rc = g_wpaObj->SetNetwork(g_wpaObj, IFNAME, networkId, nullptr, "WPA-PSK");
125094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
126094332d3Sopenharmony_ci    rc = g_wpaObj->SetNetwork(g_wpaObj, IFNAME, networkId, "psk", nullptr);
127094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
128094332d3Sopenharmony_ci}
129094332d3Sopenharmony_ci
130094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, ListNetworksTest_008, TestSize.Level1)
131094332d3Sopenharmony_ci{
132094332d3Sopenharmony_ci    struct HdiWifiWpaNetworkInfo networkInfo;
133094332d3Sopenharmony_ci    (void)memset_s(
134094332d3Sopenharmony_ci        &networkInfo, sizeof(struct HdiWifiWpaNetworkInfo), 0, sizeof(struct HdiWifiWpaNetworkInfo));
135094332d3Sopenharmony_ci    uint32_t networkInfoLen = 0;
136094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->ListNetworks(g_wpaObj, nullptr, (struct HdiWifiWpaNetworkInfo *)&networkInfo,
137094332d3Sopenharmony_ci        &networkInfoLen);
138094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
139094332d3Sopenharmony_ci    rc = g_wpaObj->ListNetworks(g_wpaObj, IFNAME, (struct HdiWifiWpaNetworkInfo *)&networkInfo, &networkInfoLen);
140094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
141094332d3Sopenharmony_ci    rc = g_wpaObj->ListNetworks(g_wpaObj, IFNAME, nullptr, &networkInfoLen);
142094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
143094332d3Sopenharmony_ci}
144094332d3Sopenharmony_ci
145094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SelectNetworkTest_009, TestSize.Level1)
146094332d3Sopenharmony_ci{
147094332d3Sopenharmony_ci    int networkId = 0;
148094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SetNetwork(g_wpaObj, IFNAME, networkId, "ssid", "WIFI_5G");
149094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
150094332d3Sopenharmony_ci    rc = g_wpaObj->SetNetwork(g_wpaObj, nullptr, networkId, "key_mgmt", "WPA-PSK");
151094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
152094332d3Sopenharmony_ci    rc = g_wpaObj->SetNetwork(g_wpaObj, IFNAME, networkId, nullptr, nullptr);
153094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
154094332d3Sopenharmony_ci}
155094332d3Sopenharmony_ci
156094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, EnableNetworkTest_010, TestSize.Level1)
157094332d3Sopenharmony_ci{
158094332d3Sopenharmony_ci    int networkId = 0;
159094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->EnableNetwork(g_wpaObj, IFNAME, networkId);
160094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
161094332d3Sopenharmony_ci    rc = g_wpaObj->EnableNetwork(g_wpaObj, nullptr, networkId);
162094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
163094332d3Sopenharmony_ci}
164094332d3Sopenharmony_ci
165094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, ReconnectTest_011, TestSize.Level1)
166094332d3Sopenharmony_ci{
167094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->Reconnect(g_wpaObj, IFNAME);
168094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
169094332d3Sopenharmony_ci    rc = g_wpaObj->Reconnect(g_wpaObj, nullptr);
170094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
171094332d3Sopenharmony_ci}
172094332d3Sopenharmony_ci
173094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, DisconnectTest_012, TestSize.Level1)
174094332d3Sopenharmony_ci{
175094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->Disconnect(g_wpaObj, IFNAME);
176094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
177094332d3Sopenharmony_ci    rc = g_wpaObj->Disconnect(g_wpaObj, nullptr);
178094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
179094332d3Sopenharmony_ci}
180094332d3Sopenharmony_ci
181094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SaveConfigTest_013, TestSize.Level1)
182094332d3Sopenharmony_ci{
183094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SaveConfig(g_wpaObj, IFNAME);
184094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
185094332d3Sopenharmony_ci    rc = g_wpaObj->SaveConfig(g_wpaObj, nullptr);
186094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
187094332d3Sopenharmony_ci}
188094332d3Sopenharmony_ci
189094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SetPowerSaveTest_014, TestSize.Level1)
190094332d3Sopenharmony_ci{
191094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SetPowerSave(g_wpaObj, IFNAME, 0);
192094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
193094332d3Sopenharmony_ci    rc = g_wpaObj->SetPowerSave(g_wpaObj, nullptr, 0);
194094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
195094332d3Sopenharmony_ci}
196094332d3Sopenharmony_ci
197094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, AutoConnectTest_015, TestSize.Level1)
198094332d3Sopenharmony_ci{
199094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->AutoConnect(g_wpaObj, IFNAME, 0);
200094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
201094332d3Sopenharmony_ci    rc = g_wpaObj->AutoConnect(g_wpaObj, nullptr, 0);
202094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
203094332d3Sopenharmony_ci}
204094332d3Sopenharmony_ci
205094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, WifiStatusTest_016, TestSize.Level1)
206094332d3Sopenharmony_ci{
207094332d3Sopenharmony_ci    struct HdiWpaCmdStatus wifiStatus;
208094332d3Sopenharmony_ci    (void)memset_s(
209094332d3Sopenharmony_ci        &wifiStatus, sizeof(struct HdiWpaCmdStatus), 0, sizeof(struct HdiWpaCmdStatus));
210094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->WifiStatus(g_wpaObj, IFNAME, &wifiStatus);
211094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_SUCCESS);
212094332d3Sopenharmony_ci    rc = g_wpaObj->WifiStatus(g_wpaObj, IFNAME, nullptr);
213094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
214094332d3Sopenharmony_ci    rc = g_wpaObj->WifiStatus(g_wpaObj, nullptr, &wifiStatus);
215094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
216094332d3Sopenharmony_ci}
217094332d3Sopenharmony_ci
218094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, WpsPbcModeTest_017, TestSize.Level1)
219094332d3Sopenharmony_ci{
220094332d3Sopenharmony_ci    struct HdiWifiWpsParam wpsParam;
221094332d3Sopenharmony_ci    (void)memset_s(&wpsParam, sizeof(struct HdiWifiWpsParam), 0, sizeof(struct HdiWifiWpsParam));
222094332d3Sopenharmony_ci    wpsParam.anyFlag = 1;
223094332d3Sopenharmony_ci    wpsParam.multiAp = 1;
224094332d3Sopenharmony_ci    wpsParam.bssidLen = 6;
225094332d3Sopenharmony_ci    wpsParam.bssid = (uint8_t *)OsalMemCalloc(sizeof(uint8_t) * (wpsParam.bssidLen));
226094332d3Sopenharmony_ci    wpsParam.bssid[0] = 0x12;
227094332d3Sopenharmony_ci    wpsParam.bssid[1] = 0x34;
228094332d3Sopenharmony_ci    wpsParam.bssid[2] = 0x56;
229094332d3Sopenharmony_ci    wpsParam.bssid[3] = 0x78;
230094332d3Sopenharmony_ci    wpsParam.bssid[4] = 0xab;
231094332d3Sopenharmony_ci    wpsParam.bssid[5] = 0xcd;
232094332d3Sopenharmony_ci
233094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->WpsPbcMode(g_wpaObj, IFNAME, &wpsParam);
234094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
235094332d3Sopenharmony_ci    rc = g_wpaObj->WpsPbcMode(g_wpaObj, IFNAME, NULL);
236094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
237094332d3Sopenharmony_ci    OsalMemFree(wpsParam.bssid);
238094332d3Sopenharmony_ci}
239094332d3Sopenharmony_ci
240094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, WpsPinModeTest_018, TestSize.Level1)
241094332d3Sopenharmony_ci{
242094332d3Sopenharmony_ci    struct HdiWifiWpsParam wpsParam;
243094332d3Sopenharmony_ci    (void)memset_s(&wpsParam, sizeof(struct HdiWifiWpsParam), 0, sizeof(struct HdiWifiWpsParam));
244094332d3Sopenharmony_ci    wpsParam.anyFlag = 1;
245094332d3Sopenharmony_ci    wpsParam.multiAp = 1;
246094332d3Sopenharmony_ci    wpsParam.bssidLen = 6;
247094332d3Sopenharmony_ci    wpsParam.bssid = (uint8_t *)OsalMemCalloc(sizeof(uint8_t) * (wpsParam.bssidLen));
248094332d3Sopenharmony_ci    wpsParam.bssid[0] = 0x12;
249094332d3Sopenharmony_ci    wpsParam.bssid[1] = 0x34;
250094332d3Sopenharmony_ci    wpsParam.bssid[2] = 0x56;
251094332d3Sopenharmony_ci    wpsParam.bssid[3] = 0x78;
252094332d3Sopenharmony_ci    wpsParam.bssid[4] = 0xab;
253094332d3Sopenharmony_ci    wpsParam.bssid[5] = 0xcd;
254094332d3Sopenharmony_ci
255094332d3Sopenharmony_ci    int pinCode = 0;
256094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->WpsPinMode(g_wpaObj, IFNAME, &wpsParam, &pinCode);
257094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
258094332d3Sopenharmony_ci    rc = g_wpaObj->WpsPinMode(g_wpaObj, IFNAME, NULL, &pinCode);
259094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
260094332d3Sopenharmony_ci    OsalMemFree(wpsParam.bssid);
261094332d3Sopenharmony_ci}
262094332d3Sopenharmony_ci
263094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, WpsCancelTest_019, TestSize.Level1)
264094332d3Sopenharmony_ci{
265094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->WpsCancel(g_wpaObj, IFNAME);
266094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
267094332d3Sopenharmony_ci    rc = g_wpaObj->WpsCancel(g_wpaObj, nullptr);
268094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
269094332d3Sopenharmony_ci}
270094332d3Sopenharmony_ci
271094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetCountryCodeTest_020, TestSize.Level1)
272094332d3Sopenharmony_ci{
273094332d3Sopenharmony_ci    char countryCode[3] = {0};
274094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetCountryCode(g_wpaObj, IFNAME, countryCode, 3);
275094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
276094332d3Sopenharmony_ci    rc = g_wpaObj->GetCountryCode(g_wpaObj, nullptr, countryCode, 3);
277094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
278094332d3Sopenharmony_ci    rc = g_wpaObj->GetCountryCode(g_wpaObj, IFNAME, nullptr, 3);
279094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
280094332d3Sopenharmony_ci}
281094332d3Sopenharmony_ci
282094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetNetworkTest_021, TestSize.Level1)
283094332d3Sopenharmony_ci{
284094332d3Sopenharmony_ci    int networkId = 0;
285094332d3Sopenharmony_ci    char value[32] = {0};
286094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->AddNetwork(g_wpaObj, IFNAME, &networkId);
287094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
288094332d3Sopenharmony_ci    rc = g_wpaObj->GetNetwork(g_wpaObj, IFNAME, networkId, "ssid", value, 32);
289094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
290094332d3Sopenharmony_ci    rc = g_wpaObj->AddNetwork(g_wpaObj, nullptr, &networkId);
291094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
292094332d3Sopenharmony_ci    rc = g_wpaObj->GetNetwork(g_wpaObj, nullptr, networkId, "ssid", value, 32);
293094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
294094332d3Sopenharmony_ci}
295094332d3Sopenharmony_ci
296094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, BlocklistClearTest_022, TestSize.Level1)
297094332d3Sopenharmony_ci{
298094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->BlocklistClear(g_wpaObj, IFNAME);
299094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
300094332d3Sopenharmony_ci    rc = g_wpaObj->BlocklistClear(g_wpaObj, nullptr);
301094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
302094332d3Sopenharmony_ci}
303094332d3Sopenharmony_ci
304094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SetSuspendModeTest_023, TestSize.Level1)
305094332d3Sopenharmony_ci{
306094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SetSuspendMode(g_wpaObj, IFNAME, 0);
307094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
308094332d3Sopenharmony_ci    rc = g_wpaObj->SetSuspendMode(g_wpaObj, IFNAME, 1);
309094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
310094332d3Sopenharmony_ci    rc = g_wpaObj->SetSuspendMode(g_wpaObj, nullptr, 0);
311094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
312094332d3Sopenharmony_ci    rc = g_wpaObj->SetSuspendMode(g_wpaObj, nullptr, 1);
313094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
314094332d3Sopenharmony_ci}
315094332d3Sopenharmony_ci
316094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, RegisterEventCallbackTest_024, TestSize.Level1)
317094332d3Sopenharmony_ci{
318094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->RegisterEventCallback(g_wpaObj, g_wpaCallbackObj, nullptr);
319094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
320094332d3Sopenharmony_ci}
321094332d3Sopenharmony_ci
322094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, UnregisterEventCallbackTest_025, TestSize.Level1)
323094332d3Sopenharmony_ci{
324094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->UnregisterEventCallback(g_wpaObj, g_wpaCallbackObj, nullptr);
325094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
326094332d3Sopenharmony_ci}
327094332d3Sopenharmony_ci
328094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetConnectionCapabilitiesTest_026, TestSize.Level1)
329094332d3Sopenharmony_ci{
330094332d3Sopenharmony_ci    struct ConnectionCapabilities connectionCap;
331094332d3Sopenharmony_ci    (void)memset_s(
332094332d3Sopenharmony_ci        &connectionCap, sizeof(struct ConnectionCapabilities), 0, sizeof(struct ConnectionCapabilities));
333094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetConnectionCapabilities(g_wpaObj, IFNAME, &connectionCap);
334094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
335094332d3Sopenharmony_ci    rc = g_wpaObj->GetConnectionCapabilities(g_wpaObj, nullptr, &connectionCap);
336094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
337094332d3Sopenharmony_ci    rc = g_wpaObj->GetConnectionCapabilities(g_wpaObj, IFNAME, nullptr);
338094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
339094332d3Sopenharmony_ci}
340094332d3Sopenharmony_ci
341094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetScanSsidTest_027, TestSize.Level1)
342094332d3Sopenharmony_ci{
343094332d3Sopenharmony_ci    int enable = 0;
344094332d3Sopenharmony_ci
345094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetScanSsid(g_wpaObj, IFNAME, &enable);
346094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
347094332d3Sopenharmony_ci    rc = g_wpaObj->GetScanSsid(g_wpaObj, nullptr, &enable);
348094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
349094332d3Sopenharmony_ci}
350094332d3Sopenharmony_ci
351094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetPskPassphraseTest_028, TestSize.Level1)
352094332d3Sopenharmony_ci{
353094332d3Sopenharmony_ci    char psk[32] = {0};
354094332d3Sopenharmony_ci
355094332d3Sopenharmony_ci    int rc = g_wpaObj->GetPskPassphrase(g_wpaObj, IFNAME, psk, 32);
356094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
357094332d3Sopenharmony_ci    rc = g_wpaObj->GetPskPassphrase(g_wpaObj, nullptr, psk, 32);
358094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
359094332d3Sopenharmony_ci}
360094332d3Sopenharmony_ci
361094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetPskTest_029, TestSize.Level1)
362094332d3Sopenharmony_ci{
363094332d3Sopenharmony_ci    uint8_t psk[32] = {0};
364094332d3Sopenharmony_ci    uint32_t pskLen = 32;
365094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetPsk(g_wpaObj, IFNAME, psk, &pskLen);
366094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
367094332d3Sopenharmony_ci    rc = g_wpaObj->GetPsk(g_wpaObj, nullptr, psk, &pskLen);
368094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
369094332d3Sopenharmony_ci}
370094332d3Sopenharmony_ci
371094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetWepKeyTest_030, TestSize.Level1)
372094332d3Sopenharmony_ci{
373094332d3Sopenharmony_ci    uint8_t wepKey[16] = {0};
374094332d3Sopenharmony_ci    uint32_t wepKeyLen = 16;
375094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetWepKey(g_wpaObj, IFNAME, 0, wepKey, &wepKeyLen);
376094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
377094332d3Sopenharmony_ci    rc = g_wpaObj->GetWepKey(g_wpaObj, IFNAME, 1, wepKey, &wepKeyLen);
378094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
379094332d3Sopenharmony_ci    rc = g_wpaObj->GetWepKey(g_wpaObj, nullptr, 0, wepKey, &wepKeyLen);
380094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
381094332d3Sopenharmony_ci    rc = g_wpaObj->GetWepKey(g_wpaObj, nullptr, 1, wepKey, &wepKeyLen);
382094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
383094332d3Sopenharmony_ci}
384094332d3Sopenharmony_ci
385094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetWepTxKeyIdxTest_031, TestSize.Level1)
386094332d3Sopenharmony_ci{
387094332d3Sopenharmony_ci    int32_t keyIdx = 0;
388094332d3Sopenharmony_ci
389094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetWepTxKeyIdx(g_wpaObj, IFNAME, &keyIdx);
390094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
391094332d3Sopenharmony_ci    rc = g_wpaObj->GetWepTxKeyIdx(g_wpaObj, nullptr, &keyIdx);
392094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
393094332d3Sopenharmony_ci}
394094332d3Sopenharmony_ci
395094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, GetRequirePmfTest_032, TestSize.Level1)
396094332d3Sopenharmony_ci{
397094332d3Sopenharmony_ci    int32_t enable = 0;
398094332d3Sopenharmony_ci
399094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->GetRequirePmf(g_wpaObj, IFNAME, &enable);
400094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
401094332d3Sopenharmony_ci    rc = g_wpaObj->GetRequirePmf(g_wpaObj, nullptr, &enable);
402094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
403094332d3Sopenharmony_ci}
404094332d3Sopenharmony_ci
405094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, SetCountryCodeTest_033, TestSize.Level1)
406094332d3Sopenharmony_ci{
407094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->SetCountryCode(g_wpaObj, IFNAME, "00");
408094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
409094332d3Sopenharmony_ci    rc = g_wpaObj->SetCountryCode(g_wpaObj, IFNAME, "01");
410094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
411094332d3Sopenharmony_ci    rc = g_wpaObj->SetCountryCode(g_wpaObj, nullptr, "00");
412094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
413094332d3Sopenharmony_ci    rc = g_wpaObj->SetCountryCode(g_wpaObj, nullptr, "01");
414094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
415094332d3Sopenharmony_ci}
416094332d3Sopenharmony_ci
417094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, ReassociateTest_034, TestSize.Level1)
418094332d3Sopenharmony_ci{
419094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->Reassociate(g_wpaObj, IFNAME);
420094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
421094332d3Sopenharmony_ci    rc = g_wpaObj->Reassociate(g_wpaObj, nullptr);
422094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
423094332d3Sopenharmony_ci}
424094332d3Sopenharmony_ci
425094332d3Sopenharmony_ciHWTEST_F(HdfWpaHostDirectTest, StaShellCmdTest_035, TestSize.Level1)
426094332d3Sopenharmony_ci{
427094332d3Sopenharmony_ci    const char *cmd = "SET external_sim 1";
428094332d3Sopenharmony_ci    int32_t rc = g_wpaObj->StaShellCmd(g_wpaObj, IFNAME, cmd);
429094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
430094332d3Sopenharmony_ci    rc = g_wpaObj->StaShellCmd(g_wpaObj, nullptr, cmd);
431094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
432094332d3Sopenharmony_ci}
433094332d3Sopenharmony_ci};
434