1 /*
2 * Copyright (C) 2023 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 <cinttypes>
17 #include <unistd.h>
18 #include <gtest/gtest.h>
19
20 #include "common_defs.h"
21 #include "device_auth.h"
22 #include "device_auth_defines.h"
23 #include "hc_log.h"
24 #include "json_utils.h"
25 #include "../../../../../services/legacy/group_manager/src/group_operation/across_account_group/across_account_group.c"
26
27 using namespace std;
28 using namespace testing::ext;
29
30 namespace {
31
32 class AcrossAccountGroupTest : public testing::Test {
33 public:
34 static void SetUpTestCase();
35 static void TearDownTestCase();
36 void SetUp();
37 void TearDown();
38 };
39
SetUpTestCase()40 void AcrossAccountGroupTest::SetUpTestCase() {}
TearDownTestCase()41 void AcrossAccountGroupTest::TearDownTestCase() {}
SetUp()42 void AcrossAccountGroupTest::SetUp() {}
TearDown()43 void AcrossAccountGroupTest::TearDown() {}
44
45 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest001, TestSize.Level0)
46 {
47 int32_t ret = CompareString(nullptr, nullptr);
48 EXPECT_EQ(ret, 0);
49 }
50
51 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest002, TestSize.Level0)
52 {
53 int32_t ret = GenerateGroupId(nullptr, nullptr, nullptr);
54 EXPECT_NE(ret, HC_SUCCESS);
55 }
56
57 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest003, TestSize.Level0)
58 {
59 int32_t ret = AddCredTypeToParamsFromIdenticalGroup(DEFAULT_OS_ACCOUNT, nullptr);
60 EXPECT_NE(ret, HC_SUCCESS);
61 }
62
63 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest004, TestSize.Level0)
64 {
65 TrustedDeviceEntry devParams;
66 int32_t ret = GenerateDevParams(nullptr, nullptr, &devParams);
67 EXPECT_NE(ret, HC_SUCCESS);
68 }
69
70 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest005, TestSize.Level0)
71 {
72 TrustedGroupEntry groupParams;
73 int32_t ret = GenerateGroupParams(nullptr, nullptr, &groupParams);
74 EXPECT_NE(ret, HC_SUCCESS);
75 }
76
77 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest006, TestSize.Level0)
78 {
79 int32_t ret = GenerateAcrossAccountGroupId(nullptr, nullptr);
80 EXPECT_NE(ret, HC_SUCCESS);
81 }
82
83 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest007, TestSize.Level0)
84 {
85 int32_t ret = AssertIdenticalGroupExist(DEFAULT_OS_ACCOUNT, nullptr);
86 EXPECT_NE(ret, HC_SUCCESS);
87 }
88
89 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest008, TestSize.Level0)
90 {
91 int32_t ret = AssertSharedUserIdValid(nullptr);
92 EXPECT_NE(ret, HC_SUCCESS);
93 }
94
95 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest009, TestSize.Level0)
96 {
97 int32_t ret = CheckCreateParams(DEFAULT_OS_ACCOUNT, nullptr);
98 EXPECT_NE(ret, HC_SUCCESS);
99 }
100
101 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest010, TestSize.Level0)
102 {
103 int32_t ret = GenerateAddTokenParams(nullptr, nullptr);
104 EXPECT_NE(ret, HC_SUCCESS);
105 }
106
107 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest011, TestSize.Level0)
108 {
109 TrustedDeviceEntry entry;
110 int32_t ret = GenerateDelTokenParams(&entry, nullptr);
111 EXPECT_NE(ret, HC_SUCCESS);
112 }
113
114 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest012, TestSize.Level0)
115 {
116 int32_t ret = CheckChangeParams(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
117 EXPECT_NE(ret, HC_SUCCESS);
118 }
119
120 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest013, TestSize.Level0)
121 {
122 TrustedDeviceEntry entry;
123 int32_t ret = GenerateTrustedDevParams(nullptr, nullptr, &entry);
124 EXPECT_NE(ret, HC_SUCCESS);
125 }
126
127 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest014, TestSize.Level0)
128 {
129 int32_t ret = CheckPeerDeviceNotSelf(nullptr);
130 EXPECT_NE(ret, HC_SUCCESS);
131 }
132
133 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest015, TestSize.Level0)
134 {
135 int32_t ret = AddDeviceAndToken(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
136 EXPECT_NE(ret, HC_SUCCESS);
137 }
138
139 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest016, TestSize.Level0)
140 {
141 int32_t ret = AddGroupAndLocalDev(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
142 EXPECT_NE(ret, HC_SUCCESS);
143 }
144
145 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest017, TestSize.Level0)
146 {
147 int32_t ret = CheckUserIdValid(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
148 EXPECT_NE(ret, HC_SUCCESS);
149 }
150
151 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest018, TestSize.Level0)
152 {
153 int32_t ret = CheckDeviceInfoValid(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
154 EXPECT_NE(ret, HC_SUCCESS);
155 }
156
157 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest020, TestSize.Level0)
158 {
159 int32_t ret = CreateGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
160 EXPECT_NE(ret, HC_SUCCESS);
161 }
162
163 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest021, TestSize.Level0)
164 {
165 int32_t ret = CreateGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
166 EXPECT_NE(ret, HC_SUCCESS);
167 }
168
169 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest022, TestSize.Level0)
170 {
171 int32_t ret = DeleteGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
172 EXPECT_NE(ret, HC_SUCCESS);
173 }
174
175 HWTEST_F(AcrossAccountGroupTest, AcrossAccountGroupTest023, TestSize.Level0)
176 {
177 int32_t ret = AddMultiMembersToGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
178 EXPECT_NE(ret, HC_SUCCESS);
179 }
180 }