1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <sys/socket.h>
18
19 #include "iremote_broker.h"
20 #include "message_parcel.h"
21 #include "peer_holder.h"
22 #include "softbus_errcode.h"
23 #include "softbus_server_ipc_interface_code.h"
24 #include "softbus_common.h"
25 #include "softbus_trans_def.h"
26 #include "softbus_def.h"
27 #include "softbus_adapter_mem.h"
28 #include "softbus_feature_config.h"
29 #include "softbus_log.h"
30 #include "softbus_access_token_test.h"
31 #include "session.h"
32 #include "trans_server_proxy.h"
33 #include "trans_server_proxy_standard.h"
34 #include "trans_server_proxy_standard.cpp"
35 #include "client_trans_session_manager.h"
36 #include "client_trans_session_service.h"
37
38 using namespace testing::ext;
39
40 namespace OHOS {
41 #define INVALID_VALUE (-1)
42 #define SESSIONKEY_LEN 32
43 #define LEN 32
44 static const int32_t UUID = 0;
45 static const int32_t PID = 0;
46 static const char *g_sessionName = "ohos.distributedschedule.dms.test";
47 static const char *g_peerSessionName = "ohos.distributedschedule.dms.test";
48 static const char *g_peerDeviceId = "1000";
49 static const char *g_pkgName = "com.test.trans.session";
50 static const char *g_addr = "192.168.8.1";
51 static const uint16_t PORT = 10;
52 static const char *g_networkId = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00";
53 static const char *g_groupId = "TEST_GROUP_ID";
54
55 class TransIpcStandardTest : public testing::Test {
56 public:
TransIpcStandardTest()57 TransIpcStandardTest()
58 {
59 }
~TransIpcStandardTest()60 ~TransIpcStandardTest()
61 {
62 }
63 static void SetUpTestCase(void);
64 static void TearDownTestCase(void);
SetUp()65 void SetUp() override
66 {
67 }
TearDown()68 void TearDown() override
69 {
70 }
71 };
72
SetUpTestCase(void)73 void TransIpcStandardTest::SetUpTestCase(void)
74 {
75 }
76
TearDownTestCase(void)77 void TransIpcStandardTest::TearDownTestCase(void)
78 {
79 }
80
81 /**
82 * @tc.name: SoftbusRegisterServiceTest001
83 * @tc.desc: SoftbusRegisterService, use the wrong parameter.
84 * @tc.type: FUNC
85 * @tc.require:I5HQGA
86 */
87 HWTEST_F(TransIpcStandardTest, SoftbusRegisterServiceTest001, TestSize.Level0)
88 {
89 int subscribeId = 1;
90 int publishId = 1;
91 SubscribeInfo* subInfo = (SubscribeInfo*)SoftBusCalloc(sizeof(SubscribeInfo));
92 ASSERT_TRUE(subInfo != nullptr);
93 (void)memset_s(subInfo, sizeof(SubscribeInfo), 0, sizeof(SubscribeInfo));
94 PublishInfo* pubInfo = (PublishInfo*)SoftBusCalloc(sizeof(PublishInfo));
95 ASSERT_TRUE(pubInfo != nullptr);
96 (void)memset_s(pubInfo, sizeof(PublishInfo), 0, sizeof(PublishInfo));
97 TransServerProxy transServerProxy(nullptr);
98
99 int32_t ret = transServerProxy.StartDiscovery(g_pkgName, subInfo);
100 EXPECT_TRUE(ret == SOFTBUS_OK);
101
102 ret = transServerProxy.StopDiscovery(g_pkgName, subscribeId);
103 EXPECT_TRUE(ret == SOFTBUS_OK);
104
105 ret = transServerProxy.PublishService(g_pkgName, pubInfo);
106 EXPECT_TRUE(ret == SOFTBUS_OK);
107
108 ret = transServerProxy.UnPublishService(g_pkgName, publishId);
109 EXPECT_TRUE(ret == SOFTBUS_OK);
110
111 ret = transServerProxy.SoftbusRegisterService(g_pkgName, nullptr);
112 EXPECT_TRUE(ret == SOFTBUS_OK);
113 SoftBusFree(subInfo);
114 SoftBusFree(pubInfo);
115 }
116
117 /**
118 * @tc.name: SoftbusRegisterServiceTest002
119 * @tc.desc: SoftbusRegisterService, use the wrong parameter.
120 * @tc.type: FUNC
121 * @tc.require:I5HQGA
122 */
123 HWTEST_F(TransIpcStandardTest, SoftbusRegisterServiceTest002, TestSize.Level0)
124 {
125 uint32_t addrTypeLen = 1;
126 void *info = nullptr;
127 uint32_t infoTypeLen = 1;
128 int infoNum = 1;
129 int key = 1;
130 unsigned char *buf = nullptr;
131 uint16_t dataChangeFlag = 1;
132 int32_t accuracy = 1;
133 int32_t period = 1;
134 TransServerProxy transServerProxy(nullptr);
135 CustomData *customData = (CustomData *)SoftBusCalloc(sizeof(CustomData));
136 ASSERT_TRUE(customData != nullptr);
137 (void)memset_s(customData, sizeof(customData), 0, sizeof(customData));
138
139 int32_t ret = transServerProxy.JoinLNN(g_pkgName, (void *)g_addr, addrTypeLen);
140 EXPECT_TRUE(ret == SOFTBUS_OK);
141
142 ret = transServerProxy.JoinMetaNode(g_pkgName, (void *)g_addr, customData, addrTypeLen);
143 EXPECT_TRUE(ret == SOFTBUS_OK);
144
145 ret = transServerProxy.LeaveLNN(g_pkgName, g_networkId);
146 EXPECT_TRUE(ret == SOFTBUS_OK);
147
148 ret = transServerProxy.LeaveMetaNode(g_pkgName, g_networkId);
149 EXPECT_TRUE(ret == SOFTBUS_OK);
150
151 ret = transServerProxy.GetAllOnlineNodeInfo(g_pkgName, &info, infoTypeLen, &infoNum);
152 EXPECT_TRUE(ret == SOFTBUS_OK);
153
154 ret = transServerProxy.GetLocalDeviceInfo(g_pkgName, info, infoTypeLen);
155 EXPECT_TRUE(ret == SOFTBUS_OK);
156
157 ret = transServerProxy.GetNodeKeyInfo(g_pkgName, g_networkId, key, buf, infoTypeLen);
158 EXPECT_TRUE(ret == SOFTBUS_OK);
159
160 ret = transServerProxy.SetNodeDataChangeFlag(g_pkgName, g_networkId, dataChangeFlag);
161 EXPECT_TRUE(ret == SOFTBUS_OK);
162
163 ret = transServerProxy.StartTimeSync(g_pkgName, g_networkId, accuracy, period);
164 EXPECT_TRUE(ret == SOFTBUS_OK);
165
166 ret = transServerProxy.StopTimeSync(g_pkgName, g_networkId);
167 EXPECT_TRUE(ret == SOFTBUS_OK);
168 SoftBusFree(customData);
169 }
170
171 /**
172 * @tc.name: CreateSessionServerTest001
173 * @tc.desc: CreateSessionServer, use the wrong parameter.
174 * @tc.type: FUNC
175 * @tc.require:I5HQGA
176 */
177 HWTEST_F(TransIpcStandardTest, CreateSessionServerTest001, TestSize.Level0)
178 {
179 TransServerProxy transServerProxy(nullptr);
180 int32_t ret = transServerProxy.CreateSessionServer(nullptr, g_sessionName);
181 EXPECT_TRUE(ret == SOFTBUS_ERR);
182
183 ret = transServerProxy.CreateSessionServer(g_pkgName, nullptr);
184 EXPECT_TRUE(ret == SOFTBUS_ERR);
185
186 ret = transServerProxy.CreateSessionServer(g_pkgName, g_sessionName);
187 EXPECT_TRUE(ret == SOFTBUS_ERR);
188 }
189
190 /**
191 * @tc.name: RemoveSessionServerTest001
192 * @tc.desc: RemoveSessionServer, use the wrong parameter.
193 * @tc.type: FUNC
194 * @tc.require:I5HQGA
195 */
196 HWTEST_F(TransIpcStandardTest, RemoveSessionServerTest001, TestSize.Level0)
197 {
198 TransServerProxy transServerProxy(nullptr);
199 int32_t ret = transServerProxy.RemoveSessionServer(nullptr, g_sessionName);
200 EXPECT_TRUE(ret == SOFTBUS_ERR);
201
202 ret = transServerProxy.RemoveSessionServer(g_pkgName, nullptr);
203 EXPECT_TRUE(ret == SOFTBUS_ERR);
204
205 ret = transServerProxy.RemoveSessionServer(g_pkgName, g_sessionName);
206 EXPECT_TRUE(ret == SOFTBUS_TRANS_PROXY_SEND_REQUEST_FAILED);
207 }
208
209 /**
210 * @tc.name: OpenSessionTest001
211 * @tc.desc: OpenSession, use the wrong parameter.
212 * @tc.type: FUNC
213 * @tc.require:I5HQGA
214 */
215 HWTEST_F(TransIpcStandardTest, OpenSessionTest001, TestSize.Level0)
216 {
217 TransServerProxy transServerProxy(nullptr);
218 SessionParam *param = (SessionParam*)SoftBusCalloc(sizeof(SessionParam));
219 TransInfo *info = (TransInfo*)SoftBusCalloc(sizeof(TransInfo));
220 ASSERT_TRUE(param != nullptr);
221 ASSERT_TRUE(info != nullptr);
222 (void)memset_s(param, sizeof(SessionParam), 0, sizeof(SessionParam));
223 (void)memset_s(info, sizeof(TransInfo), 0, sizeof(TransInfo));
224 param->sessionName = nullptr;
225 param->peerSessionName = nullptr;
226 param->peerDeviceId = nullptr;
227 param->groupId = nullptr;
228
229 int32_t ret = transServerProxy.OpenSession(param, info);
230 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
231
232 param->sessionName = g_sessionName;
233 ret = transServerProxy.OpenSession(param, info);
234 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
235
236 param->peerSessionName = g_peerSessionName;
237 ret = transServerProxy.OpenSession(param, info);
238 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
239
240 param->peerDeviceId = g_peerDeviceId;
241 ret = transServerProxy.OpenSession(param, info);
242 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
243
244 param->groupId = g_groupId;
245 ret = transServerProxy.OpenSession(param, info);
246 EXPECT_TRUE(ret == SOFTBUS_TRANS_PROXY_WRITERAWDATA_FAILED);
247
248 SessionAttribute sessionAttribute;
249 sessionAttribute.dataType = 1;
250 sessionAttribute.linkTypeNum= 1;
251 param->attr = &sessionAttribute;
252 ret = transServerProxy.OpenSession(param, info);
253 EXPECT_TRUE(ret == SOFTBUS_TRANS_PROXY_SEND_REQUEST_FAILED);
254 SoftBusFree(param);
255 SoftBusFree(info);
256 }
257
258 /**
259 * @tc.name: OpenAuthSessionTest001
260 * @tc.desc: OpenAuthSession, use the wrong parameter.
261 * @tc.type: FUNC
262 * @tc.require:I5HQGA
263 */
264 HWTEST_F(TransIpcStandardTest, OpenAuthSessionTest001, TestSize.Level0)
265 {
266 TransServerProxy transServerProxy(nullptr);
267 ConnectionAddr *addrInfo = (ConnectionAddr*)SoftBusCalloc(sizeof(ConnectionAddr));
268 ASSERT_TRUE(addrInfo != nullptr);
269 (void)memset_s(addrInfo, sizeof(ConnectionAddr), 0, sizeof(ConnectionAddr));
270 addrInfo->type = CONNECTION_ADDR_WLAN;
271 (void)memcpy_s(addrInfo->info.ip.ip, strlen(addrInfo->info.ip.ip), g_addr, strlen(g_addr));
272 addrInfo->info.ip.port = PORT;
273 int32_t ret = transServerProxy.OpenAuthSession(nullptr, addrInfo);
274 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
275
276 ret = transServerProxy.OpenAuthSession(g_sessionName, nullptr);
277 EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
278
279 ret = transServerProxy.OpenAuthSession(g_sessionName, addrInfo);
280 EXPECT_TRUE(ret == SOFTBUS_ERR);
281 SoftBusFree(addrInfo);
282 }
283
284 /**
285 * @tc.name: NotifyAuthSuccessTest001
286 * @tc.desc: NotifyAuthSuccess, use the wrong parameter.
287 * @tc.type: FUNC
288 * @tc.require:I5HQGA
289 */
290 HWTEST_F(TransIpcStandardTest, NotifyAuthSuccessTest001, TestSize.Level0)
291 {
292 TransServerProxy transServerProxy(nullptr);
293 int32_t channelId = 0;
294 int32_t channelType = CHANNEL_TYPE_AUTH;
295 int32_t ret = transServerProxy.NotifyAuthSuccess(channelId, channelType);
296 EXPECT_TRUE(ret == SOFTBUS_ERR);
297
298 channelId = INVALID_VALUE;
299 ret = transServerProxy.NotifyAuthSuccess(channelId, channelType);
300 EXPECT_TRUE(ret == SOFTBUS_ERR);
301 }
302
303 /**
304 * @tc.name: CloseChannelTest001
305 * @tc.desc: CloseChannel, use the wrong parameter.
306 * @tc.type: FUNC
307 * @tc.require:I5HQGA
308 */
309 HWTEST_F(TransIpcStandardTest, CloseChannelTest001, TestSize.Level0)
310 {
311 TransServerProxy transServerProxy(nullptr);
312 int32_t channelId = -1;
313 int32_t channelType = CHANNEL_TYPE_AUTH;
314 int32_t ret = transServerProxy.CloseChannel(channelId, channelType);
315 EXPECT_TRUE(ret == SOFTBUS_ERR);
316 }
317
318 /**
319 * @tc.name: SendMessageTest001
320 * @tc.desc: SendMessage, use the wrong parameter.
321 * @tc.type: FUNC
322 * @tc.require:I5HQGA
323 */
324 HWTEST_F(TransIpcStandardTest, SendMessageTest001, TestSize.Level0)
325 {
326 TransServerProxy transServerProxy(nullptr);
327 int32_t channelId = 0;
328 int32_t channelType = CHANNEL_TYPE_AUTH;
329 const char *dataInfo = "datainfo";
330 uint32_t len = LEN;
331 int32_t msgType = TRANS_SESSION_BYTES;
332 int32_t ret = transServerProxy.SendMessage(channelId, channelType, (const void *)dataInfo, len, msgType);
333 EXPECT_TRUE(ret == SOFTBUS_ERR);
334
335 ret = transServerProxy.SendMessage(channelId, channelType, nullptr, len, msgType);
336 EXPECT_TRUE(ret == SOFTBUS_ERR);
337 }
338
339 /**
340 * @tc.name: QosReportTest001
341 * @tc.desc: SendMessage, use the wrong parameter.
342 * @tc.type: FUNC
343 * @tc.require:I5HQGA
344 */
345 HWTEST_F(TransIpcStandardTest, QosReportTest001, TestSize.Level0)
346 {
347 TransServerProxy transServerProxy(nullptr);
348 int32_t channelId = 1;
349 int32_t channelType = CHANNEL_TYPE_BUTT;
350 int32_t appType = 0;
351 int32_t quality = QOS_IMPROVE;
352 int32_t ret = transServerProxy.QosReport(channelId, channelType, appType, quality);
353 EXPECT_TRUE(ret == SOFTBUS_ERR);
354
355 channelId = INVALID_VALUE;
356 ret = transServerProxy.QosReport(channelId, channelType, appType, quality);
357 EXPECT_TRUE(ret == SOFTBUS_ERR);
358 }
359
360 /**
361 * @tc.name: StreamStatsTest001
362 * @tc.desc: StreamStats, use the wrong parameter.
363 * @tc.type: FUNC
364 * @tc.require:I5HQGA
365 */
366 HWTEST_F(TransIpcStandardTest, StreamStatsTest001, TestSize.Level0)
367 {
368 TransServerProxy transServerProxy(nullptr);
369 int32_t channelId = INVALID_VALUE;
370 int32_t channelType = CHANNEL_TYPE_BUTT;
371 StreamSendStats *statsData = (StreamSendStats*)SoftBusCalloc(sizeof(StreamSendStats));
372 ASSERT_TRUE(statsData != nullptr);
373 (void)memset_s(statsData, sizeof(StreamSendStats), 0, sizeof(StreamSendStats));
374
375 int32_t ret = transServerProxy.StreamStats(channelId, channelType, nullptr);
376 EXPECT_TRUE(ret == SOFTBUS_ERR);
377
378 channelId = INVALID_VALUE;
379 ret = transServerProxy.StreamStats(channelId, channelType, statsData);
380 EXPECT_TRUE(ret == SOFTBUS_ERR);
381 SoftBusFree(statsData);
382 }
383
384 /**
385 * @tc.name: RippleStatsTest0011
386 * @tc.desc: RippleStats, use the wrong parameter.
387 * @tc.type: FUNC
388 * @tc.require:I5HQGA
389 */
390 HWTEST_F(TransIpcStandardTest, RippleStatsTest0011, TestSize.Level0)
391 {
392 TransServerProxy transServerProxy(nullptr);
393 int32_t channelId = INVALID_VALUE;
394 int32_t channelType = CHANNEL_TYPE_BUTT;
395 TrafficStats *statsData = (TrafficStats*)SoftBusCalloc(sizeof(TrafficStats));
396 ASSERT_TRUE(statsData != nullptr);
397 (void)memset_s(statsData, sizeof(TrafficStats), 0, sizeof(TrafficStats));
398
399 int32_t ret = transServerProxy.RippleStats(channelId, channelType, nullptr);
400 EXPECT_TRUE(ret == SOFTBUS_ERR);
401
402 channelId = INVALID_VALUE;
403 ret = transServerProxy.RippleStats(channelId, channelType, statsData);
404 EXPECT_TRUE(ret == SOFTBUS_ERR);
405 SoftBusFree(statsData);
406 }
407
408 /**
409 * @tc.name: GrantPermissionTest001
410 * @tc.desc: GrantPermission, use the wrong parameter.
411 * @tc.type: FUNC
412 * @tc.require:I5HQGA
413 */
414 HWTEST_F(TransIpcStandardTest, GrantPermissionTest001, TestSize.Level0)
415 {
416 TransServerProxy transServerProxy(nullptr);
417 int32_t ret = transServerProxy.GrantPermission(UUID, PID, nullptr);
418 EXPECT_TRUE(ret == SOFTBUS_ERR);
419
420 ret = transServerProxy.GrantPermission(UUID, PID, g_sessionName);
421 EXPECT_TRUE(ret == SOFTBUS_ERR);
422 }
423
424 /**
425 * @tc.name: RemovePermissionTest001
426 * @tc.desc: RemovePermission, use the wrong parameter.
427 * @tc.type: FUNC
428 * @tc.require:I5HQGA
429 */
430 HWTEST_F(TransIpcStandardTest, RemovePermissionTest001, TestSize.Level0)
431 {
432 TransServerProxy transServerProxy(nullptr);
433 int32_t ret = transServerProxy.RemovePermission(g_sessionName);
434 EXPECT_TRUE(ret == SOFTBUS_ERR);
435
436 ret = transServerProxy.RemovePermission(g_sessionName);
437 EXPECT_TRUE(ret == SOFTBUS_ERR);
438 }
439
440 /**
441 * @tc.name: TransServerProxyInitTest001
442 * @tc.desc: TransServerProxyInit, use the wrong parameter.
443 * @tc.type: FUNC
444 * @tc.require:I5HQGA
445 */
446 HWTEST_F(TransIpcStandardTest, TransServerProxyInitTest001, TestSize.Level0)
447 {
448 int32_t ret = TransServerProxyInit();
449 ASSERT_EQ(ret, SOFTBUS_OK);
450 TransClientDeinit();
451
452 ret = TransServerProxyInit();
453 ASSERT_EQ(ret, SOFTBUS_OK);
454 TransClientDeinit();
455 }
456
457 /**
458 * @tc.name: ServerIpcCreateSessionServerTest001
459 * @tc.desc: ServerIpcCreateSessionServer, use the wrong parameter.
460 * @tc.type: FUNC
461 * @tc.require:I5HQGA
462 */
463 HWTEST_F(TransIpcStandardTest, ServerIpcCreateSessionServerTest001, TestSize.Level0)
464 {
465 int32_t ret = ServerIpcCreateSessionServer(g_pkgName, g_sessionName);
466 EXPECT_TRUE(ret != SOFTBUS_OK);
467
468 ret = TransServerProxyInit();
469 ASSERT_EQ(ret, SOFTBUS_OK);
470
471 ret = ServerIpcCreateSessionServer(nullptr, g_sessionName);
472 EXPECT_TRUE(ret != SOFTBUS_OK);
473
474 ret = ServerIpcCreateSessionServer(g_pkgName, nullptr);
475 EXPECT_TRUE(ret != SOFTBUS_OK);
476
477 ret = ServerIpcCreateSessionServer(g_pkgName, g_sessionName);
478 EXPECT_TRUE(ret == SOFTBUS_ERR);
479
480 TransClientDeinit();
481 }
482
483 /**
484 * @tc.name: ServerIpcRemoveSessionServerTest001
485 * @tc.desc: ServerIpcRemoveSessionServer, use the wrong parameter.
486 * @tc.type: FUNC
487 * @tc.require:I5HQGA
488 */
489 HWTEST_F(TransIpcStandardTest, ServerIpcRemoveSessionServerTest001, TestSize.Level0)
490 {
491 int32_t ret = ServerIpcRemoveSessionServer(g_pkgName, g_sessionName);
492 EXPECT_TRUE(ret != SOFTBUS_OK);
493
494 ret = TransServerProxyInit();
495 ASSERT_EQ(ret, SOFTBUS_OK);
496
497 ret = ServerIpcRemoveSessionServer(nullptr, g_sessionName);
498 EXPECT_TRUE(ret != SOFTBUS_OK);
499
500 ret = ServerIpcRemoveSessionServer(g_pkgName, nullptr);
501 EXPECT_TRUE(ret != SOFTBUS_OK);
502
503 ret = ServerIpcRemoveSessionServer(g_pkgName, g_sessionName);
504 EXPECT_TRUE(ret != SOFTBUS_OK);
505
506 TransClientDeinit();
507 }
508
509 /**
510 * @tc.name: ServerIpcOpenSessionTest001
511 * @tc.desc: ServerIpcOpenSession, use the wrong parameter.
512 * @tc.type: FUNC
513 * @tc.require:I5HQGA
514 */
515 HWTEST_F(TransIpcStandardTest, ServerIpcOpenSessionTest001, TestSize.Level0)
516 {
517 TransInfo* info = (TransInfo*)SoftBusCalloc(sizeof(TransInfo));
518 ASSERT_TRUE(info != nullptr);
519 (void)memset_s(info, sizeof(TransInfo), 0, sizeof(TransInfo));
520 SessionParam* param = (SessionParam*)SoftBusCalloc(sizeof(SessionParam));
521 ASSERT_TRUE(param != nullptr);
522 (void)memset_s(param, sizeof(SessionParam), 0, sizeof(SessionParam));
523 param->sessionName = nullptr;
524 param->peerSessionName = nullptr;
525 param->peerDeviceId = nullptr;
526 param->groupId = nullptr;
527 param->attr = nullptr;
528
529 int32_t sessionId = INVALID_SESSION_ID;
530 int32_t ret = ServerIpcOpenSession(param, info);
531 EXPECT_TRUE(ret != SOFTBUS_OK);
532
533 TransClientDeinit();
534 ret = TransServerProxyInit();
535 ASSERT_EQ(ret, SOFTBUS_OK);
536
537 param->sessionName = g_sessionName;
538 ret = ServerIpcOpenSession(param, info);
539 EXPECT_TRUE(ret != SOFTBUS_OK);
540 (void)ClientDeleteSession(sessionId);
541
542 param->peerSessionName = g_peerSessionName;
543 ret = ServerIpcOpenSession(param, info);
544 EXPECT_TRUE(ret != SOFTBUS_OK);
545 (void)ClientDeleteSession(sessionId);
546
547 param->peerDeviceId = g_peerDeviceId;
548 ret = ServerIpcOpenSession(param, info);
549 EXPECT_TRUE(ret != SOFTBUS_OK);
550 (void)ClientDeleteSession(sessionId);
551
552 param->groupId = g_groupId;
553 ret = ServerIpcOpenSession(param, info);
554 EXPECT_TRUE(ret != SOFTBUS_OK);
555 (void)ClientDeleteSession(sessionId);
556
557 SessionAttribute sessionAttribute;
558 sessionAttribute.dataType = 1;
559 sessionAttribute.linkTypeNum = 1;
560 param->attr = &sessionAttribute;
561 ret = ServerIpcOpenSession(param, info);
562 EXPECT_TRUE(ret != SOFTBUS_OK);
563 (void)ClientDeleteSession(sessionId);
564
565 TransClientDeinit();
566 SoftBusFree(param);
567 SoftBusFree(info);
568 }
569
570 /**
571 * @tc.name: ServerIpcOpenAuthSessionTest001
572 * @tc.desc: ServerIpcOpenAuthSession, use the wrong parameter.
573 * @tc.type: FUNC
574 * @tc.require:I5HQGA
575 */
576 HWTEST_F(TransIpcStandardTest, ServerIpcOpenAuthSessionTest001, TestSize.Level0)
577 {
578 ConnectionAddr* addrInfo = (ConnectionAddr*)SoftBusCalloc(sizeof(ConnectionAddr));
579 ASSERT_TRUE(addrInfo != nullptr);
580 (void)memset_s(addrInfo, sizeof(ConnectionAddr), 0, sizeof(ConnectionAddr));
581 addrInfo->type = CONNECTION_ADDR_BR;
582 int32_t ret = ServerIpcOpenAuthSession(g_sessionName, addrInfo);
583 EXPECT_TRUE(ret != SOFTBUS_OK);
584
585 ret = TransServerProxyInit();
586 ASSERT_EQ(ret, SOFTBUS_OK);
587
588 ret = ServerIpcOpenAuthSession(nullptr, addrInfo);
589 EXPECT_TRUE(ret != SOFTBUS_OK);
590
591 ret = ServerIpcOpenAuthSession(g_sessionName, nullptr);
592 EXPECT_TRUE(ret != SOFTBUS_OK);
593
594 ret = ServerIpcOpenAuthSession(g_sessionName, addrInfo);
595 EXPECT_TRUE(ret != SOFTBUS_OK);
596
597 TransClientDeinit();
598 SoftBusFree(addrInfo);
599 }
600
601 /**
602 * @tc.name: ServerIpcNotifyAuthSuccessTest001
603 * @tc.desc: ServerIpcNotifyAuthSuccess, use the wrong parameter.
604 * @tc.type: FUNC
605 * @tc.require:I5HQGA
606 */
607 HWTEST_F(TransIpcStandardTest, ServerIpcNotifyAuthSuccessTest001, TestSize.Level0)
608 {
609 int32_t ret = TransServerProxyInit();
610 ASSERT_EQ(ret, SOFTBUS_OK);
611
612 int32_t channelId = 0;
613 int32_t channelType = CHANNEL_TYPE_AUTH;
614 ret = ServerIpcNotifyAuthSuccess(channelId, channelType);
615 EXPECT_TRUE(ret != SOFTBUS_OK);
616 TransClientDeinit();
617 }
618
619 /**
620 * @tc.name: ServerIpcCloseChannelTest001
621 * @tc.desc: ServerIpcCloseChannel, use the wrong parameter.
622 * @tc.type: FUNC
623 * @tc.require:I5HQGA
624 */
625 HWTEST_F(TransIpcStandardTest, ServerIpcCloseChannelTest001, TestSize.Level0)
626 {
627 int32_t channelId = 0;
628 int32_t chanType = CHANNEL_TYPE_AUTH;
629 int32_t ret = ServerIpcCloseChannel(channelId, chanType);
630 EXPECT_TRUE(ret == SOFTBUS_ERR);
631
632 ret = TransServerProxyInit();
633 ASSERT_EQ(ret, SOFTBUS_OK);
634
635 ret = ServerIpcCloseChannel(-1, chanType);
636 EXPECT_TRUE(ret == SOFTBUS_ERR);
637
638 ret = ServerIpcCloseChannel(channelId, chanType);
639 EXPECT_TRUE(ret != SOFTBUS_OK);
640
641 TransClientDeinit();
642 }
643
644 /**
645 * @tc.name: ServerIpcSendMessageTest001
646 * @tc.desc: ServerIpcSendMessage, use the wrong parameter.
647 * @tc.type: FUNC
648 * @tc.require:I5HQGA
649 */
650 HWTEST_F(TransIpcStandardTest, ServerIpcSendMessageTest001, TestSize.Level0)
651 {
652 int32_t channelId = 0;
653 int32_t chanType = CHANNEL_TYPE_AUTH;
654 int32_t ret = ServerIpcSendMessage(channelId, chanType, nullptr, 0, 0);
655 EXPECT_TRUE(ret == SOFTBUS_ERR);
656
657 ret = TransServerProxyInit();
658 ASSERT_EQ(ret, SOFTBUS_OK);
659
660 ret = ServerIpcSendMessage(channelId, chanType, nullptr, 0, 0);
661 EXPECT_TRUE(ret == SOFTBUS_ERR);
662
663 TransClientDeinit();
664 }
665
666 /**
667 * @tc.name: ServerIpcQosReportTest001
668 * @tc.desc: ServerIpcQosReport, use the wrong parameter.
669 * @tc.type: FUNC
670 * @tc.require:I5HQGA
671 */
672 HWTEST_F(TransIpcStandardTest, ServerIpcQosReportTest001, TestSize.Level0)
673 {
674 int32_t channelId = 0;
675 int32_t chanType = CHANNEL_TYPE_AUTH;
676 int32_t appType = 0;
677 int32_t quality = QOS_IMPROVE;
678 int32_t ret = ServerIpcQosReport(channelId, chanType, appType, quality);
679 EXPECT_TRUE(ret == SOFTBUS_ERR);
680
681 ret = TransServerProxyInit();
682 ASSERT_EQ(ret, SOFTBUS_OK);
683
684 ret = ServerIpcQosReport(channelId, chanType, appType, quality);
685 EXPECT_TRUE(ret == SOFTBUS_ERR);
686
687 TransClientDeinit();
688 }
689
690 /**
691 * @tc.name: ServerIpcStreamStatsTest001
692 * @tc.desc: ServerIpcStreamStats, use the wrong parameter.
693 * @tc.type: FUNC
694 * @tc.require:I5HQGA
695 */
696 HWTEST_F(TransIpcStandardTest, ServerIpcStreamStatsTest001, TestSize.Level0)
697 {
698 int32_t channelId = 0;
699 int32_t chanType = CHANNEL_TYPE_AUTH;
700 int32_t ret = ServerIpcStreamStats(channelId, chanType, nullptr);
701 EXPECT_TRUE(ret == SOFTBUS_ERR);
702
703 ret = TransServerProxyInit();
704 ASSERT_EQ(ret, SOFTBUS_OK);
705
706 ret = ServerIpcStreamStats(channelId, chanType, nullptr);
707 EXPECT_TRUE(ret == SOFTBUS_ERR);
708
709 TransClientDeinit();
710 }
711
712 /**
713 * @tc.name: ServerIpcRippleStatsTest001
714 * @tc.desc: ServerIpcRippleStats, use the wrong parameter.
715 * @tc.type: FUNC
716 * @tc.require:I5HQGA
717 */
718 HWTEST_F(TransIpcStandardTest, ServerIpcRippleStatsTest001, TestSize.Level0)
719 {
720 int32_t channelId = 0;
721 int32_t chanType = CHANNEL_TYPE_AUTH;
722 int32_t ret = ServerIpcRippleStats(channelId, chanType, nullptr);
723 EXPECT_TRUE(ret == SOFTBUS_ERR);
724
725 ret = TransServerProxyInit();
726 ASSERT_EQ(ret, SOFTBUS_OK);
727
728 ret = ServerIpcRippleStats(channelId, chanType, nullptr);
729 EXPECT_TRUE(ret == SOFTBUS_ERR);
730
731 TransClientDeinit();
732 }
733
734 /**
735 * @tc.name: ServerIpcGrantPermissionTest001
736 * @tc.desc: ServerIpcGrantPermission, use the wrong parameter.
737 * @tc.type: FUNC
738 * @tc.require:I5HQGA
739 */
740 HWTEST_F(TransIpcStandardTest, ServerIpcGrantPermissionTest001, TestSize.Level0)
741 {
742 int uid = 1;
743 int pid = 1;
744 int32_t ret = ServerIpcGrantPermission(uid, pid, nullptr);
745 EXPECT_TRUE(ret == SOFTBUS_ERR);
746
747 ret = TransServerProxyInit();
748 ASSERT_EQ(ret, SOFTBUS_OK);
749
750 ret = ServerIpcGrantPermission(uid, pid, nullptr);
751 EXPECT_TRUE(ret == SOFTBUS_ERR);
752
753 ret = ServerIpcGrantPermission(uid, pid, g_sessionName);
754 EXPECT_TRUE(ret == SOFTBUS_ERR);
755
756 TransClientDeinit();
757 }
758
759 /**
760 * @tc.name: ServerIpcRemovePermissionTest001
761 * @tc.desc: ServerIpcRemovePermission, use the wrong parameter.
762 * @tc.type: FUNC
763 * @tc.require:I5HQGA
764 */
765 HWTEST_F(TransIpcStandardTest, ServerIpcRemovePermissionTest001, TestSize.Level0)
766 {
767 int32_t ret = ServerIpcRemovePermission(nullptr);
768 EXPECT_TRUE(ret == SOFTBUS_ERR);
769
770 ret = TransServerProxyInit();
771 ASSERT_EQ(ret, SOFTBUS_OK);
772
773 ret = ServerIpcRemovePermission(nullptr);
774 EXPECT_TRUE(ret == SOFTBUS_ERR);
775
776 ret = ServerIpcRemovePermission(g_sessionName);
777 EXPECT_TRUE(ret == SOFTBUS_ERR);
778
779 TransClientDeinit();
780 }
781 }
782