• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/group_manager/src/group_operation/identical_account_group/identical_account_group.c"
26 
27 using namespace std;
28 using namespace testing::ext;
29 
30 namespace {
31 class IdenticalAccountGroupTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp();
36     void TearDown();
37 };
38 
SetUpTestCase()39 void IdenticalAccountGroupTest::SetUpTestCase() {}
TearDownTestCase()40 void IdenticalAccountGroupTest::TearDownTestCase() {}
SetUp()41 void IdenticalAccountGroupTest::SetUp() {}
TearDown()42 void IdenticalAccountGroupTest::TearDown() {}
43 
44 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest001, TestSize.Level0)
45 {
46     TrustedDeviceEntry trustedDeviceEntry;
47     int32_t ret = GenerateDevParams(nullptr, nullptr, &trustedDeviceEntry);
48     EXPECT_NE(ret, HC_SUCCESS);
49 }
50 
51 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest002, TestSize.Level0)
52 {
53     TrustedGroupEntry trustedGroupEntry;
54     int32_t ret = GenerateGroupParams(nullptr, nullptr, &trustedGroupEntry);
55     EXPECT_NE(ret, HC_SUCCESS);
56 }
57 
58 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest003, TestSize.Level0)
59 {
60     int32_t ret = GenerateGroupId(nullptr, nullptr);
61     EXPECT_NE(ret, HC_SUCCESS);
62 }
63 
64 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest004, TestSize.Level0)
65 {
66     int32_t ret = GenerateIdenticalGroupId(nullptr, nullptr);
67     EXPECT_NE(ret, HC_SUCCESS);
68 }
69 
70 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest005, TestSize.Level0)
71 {
72     int32_t ret = AssertCredentialExist(nullptr);
73     EXPECT_NE(ret, HC_SUCCESS);
74 }
75 
76 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest006, TestSize.Level0)
77 {
78     int32_t ret = CheckCreateParams(DEFAULT_OS_ACCOUNT, nullptr);
79     EXPECT_NE(ret, HC_SUCCESS);
80 }
81 
82 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest008, TestSize.Level0)
83 {
84     int32_t ret = ImportSelfToken(DEFAULT_OS_ACCOUNT, nullptr);
85     EXPECT_NE(ret, HC_SUCCESS);
86 }
87 
88 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest009, TestSize.Level0)
89 {
90     int32_t ret = DelSelfToken(DEFAULT_OS_ACCOUNT, nullptr);
91     EXPECT_NE(ret, HC_SUCCESS);
92 }
93 
94 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest010, TestSize.Level0)
95 {
96     int32_t ret = GenerateAddTokenParams(nullptr, nullptr);
97     EXPECT_NE(ret, HC_SUCCESS);
98 }
99 
100 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest011, TestSize.Level0)
101 {
102     TrustedDeviceEntry entry;
103     int32_t ret = GenerateDelTokenParams(&entry, nullptr);
104     EXPECT_NE(ret, HC_SUCCESS);
105 }
106 
107 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest012, TestSize.Level0)
108 {
109     TrustedDeviceEntry entry;
110     int32_t ret = DelDeviceToken(DEFAULT_OS_ACCOUNT, &entry, false);
111     EXPECT_NE(ret, HC_SUCCESS);
112 }
113 
114 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest016, TestSize.Level0)
115 {
116     GroupEntryVec vec;
117     int32_t ret = GetRelatedAcrossAccountGroups(DEFAULT_OS_ACCOUNT, nullptr, &vec);
118     EXPECT_NE(ret, HC_SUCCESS);
119 }
120 
121 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest017, TestSize.Level0)
122 {
123     GroupEntryVec vec;
124     int32_t ret = GetRelatedAcrossAccountGroups(DEFAULT_OS_ACCOUNT, nullptr, &vec);
125     EXPECT_NE(ret, HC_SUCCESS);
126 }
127 
128 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest018, TestSize.Level0)
129 {
130     int32_t ret = DelRelatedAcrossAccountGroups(DEFAULT_OS_ACCOUNT, nullptr);
131     EXPECT_EQ(ret, HC_SUCCESS);
132 }
133 
134 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest020, TestSize.Level0)
135 {
136     TrustedDeviceEntry devParams;
137     int32_t ret = GenerateTrustedDevParams(nullptr, nullptr, &devParams);
138     EXPECT_NE(ret, HC_SUCCESS);
139 }
140 
141 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest021, TestSize.Level0)
142 {
143     int32_t ret = CheckPeerDeviceNotSelf(nullptr);
144     EXPECT_NE(ret, HC_SUCCESS);
145 }
146 
147 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest022, TestSize.Level0)
148 {
149     int32_t ret = AddDeviceAndToken(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
150     EXPECT_NE(ret, HC_SUCCESS);
151 }
152 
153 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest023, TestSize.Level0)
154 {
155     int32_t ret = DelPeerDeviceAndToken(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
156     EXPECT_NE(ret, HC_SUCCESS);
157 }
158 
159 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest024, TestSize.Level0)
160 {
161     int32_t ret = CheckChangeParams(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
162     EXPECT_NE(ret, HC_SUCCESS);
163 }
164 
165 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest025, TestSize.Level0)
166 {
167     int32_t ret = AddGroupAndToken(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
168     EXPECT_NE(ret, HC_SUCCESS);
169 }
170 
171 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest026, TestSize.Level0)
172 {
173     int32_t ret = CheckUserIdValid(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
174     EXPECT_NE(ret, HC_SUCCESS);
175 }
176 
177 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest027, TestSize.Level0)
178 {
179     int32_t ret = CheckDeviceInfoValid(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
180     EXPECT_NE(ret, HC_SUCCESS);
181 }
182 
183 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest028, TestSize.Level0)
184 {
185     int32_t ret = CreateGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
186     EXPECT_NE(ret, HC_SUCCESS);
187 }
188 
189 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest029, TestSize.Level0)
190 {
191     int32_t ret = DeleteGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
192     EXPECT_NE(ret, HC_SUCCESS);
193 }
194 
195 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest030, TestSize.Level0)
196 {
197     int32_t ret = AddMultiMembersToGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
198     EXPECT_NE(ret, HC_SUCCESS);
199 }
200 
201 HWTEST_F(IdenticalAccountGroupTest, IdenticalAccountGroupTest031, TestSize.Level0)
202 {
203     int32_t ret = DelMultiMembersFromGroup(DEFAULT_OS_ACCOUNT, nullptr, nullptr);
204     EXPECT_NE(ret, HC_SUCCESS);
205 }
206 }