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 "attributes_test.h"
17
18 #include <climits>
19
20 #include "attributes.h"
21
22 namespace OHOS {
23 namespace UserIam {
24 namespace UserAuth {
25 using namespace testing;
26 using namespace testing::ext;
27
SetUpTestCase()28 void AttributesTest::SetUpTestCase()
29 {
30 }
31
TearDownTestCase()32 void AttributesTest::TearDownTestCase()
33 {
34 }
35
SetUp()36 void AttributesTest::SetUp()
37 {
38 }
39
TearDown()40 void AttributesTest::TearDown()
41 {
42 }
43
44 HWTEST_F(AttributesTest, AttributesInit, TestSize.Level0)
45 {
46 Attributes attrs;
47 EXPECT_EQ(attrs.Serialize().size(), 0U);
48 }
49
50 HWTEST_F(AttributesTest, AttributesSerialize, TestSize.Level0)
51 {
52 const std::vector<Attributes::AttributeKey> desired = {Attributes::ATTR_RESULT_CODE, Attributes::ATTR_SIGNATURE,
53 Attributes::ATTR_TEMPLATE_ID_LIST, Attributes::ATTR_REMAIN_TIMES, Attributes::ATTR_FREEZING_TIME,
54 Attributes::ATTR_SCHEDULE_ID, Attributes::ATTR_SCHEDULE_MODE};
55
56 Attributes attrs;
57
58 EXPECT_TRUE(attrs.SetBoolValue(Attributes::ATTR_RESULT_CODE, true));
59 EXPECT_TRUE(attrs.SetBoolValue(Attributes::ATTR_SIGNATURE, false));
60 EXPECT_TRUE(attrs.SetUint64Value(Attributes::ATTR_SCHEDULE_ID, UINT64_MAX));
61 EXPECT_TRUE(attrs.SetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, {1, 3, 5, 7, 9}));
62 EXPECT_TRUE(attrs.SetUint32Value(Attributes::ATTR_SCHEDULE_MODE, UINT32_MAX));
63 EXPECT_TRUE(attrs.SetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, {2, 4, 6, 8, 10}));
64 EXPECT_TRUE(attrs.SetStringValue(Attributes::ATTR_TEMPLATE_ID_LIST, "iam"));
65
66 EXPECT_THAT(attrs.GetKeys(), ElementsAreArray(desired));
67 auto buff = attrs.Serialize();
68 Attributes attrs2(buff);
69 EXPECT_THAT(attrs2.GetKeys(), ElementsAreArray(desired));
70
71 bool boolValue;
72 EXPECT_TRUE(attrs2.GetBoolValue(Attributes::ATTR_RESULT_CODE, boolValue));
73 EXPECT_EQ(boolValue, true);
74
75 EXPECT_TRUE(attrs2.GetBoolValue(Attributes::ATTR_SIGNATURE, boolValue));
76 EXPECT_EQ(boolValue, false);
77
78 uint64_t u64Value;
79 EXPECT_TRUE(attrs2.GetUint64Value(Attributes::ATTR_SCHEDULE_ID, u64Value));
80 EXPECT_EQ(u64Value, UINT64_MAX);
81
82 std::vector<uint32_t> u32Vector;
83 EXPECT_TRUE(attrs2.GetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, u32Vector));
84 EXPECT_THAT(u32Vector, ElementsAre(1, 3, 5, 7, 9));
85
86 uint32_t u32Value;
87 EXPECT_TRUE(attrs2.GetUint32Value(Attributes::ATTR_SCHEDULE_MODE, u32Value));
88 EXPECT_EQ(u32Value, UINT32_MAX);
89
90 std::vector<uint64_t> u64Vector;
91 EXPECT_TRUE(attrs2.GetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, u64Vector));
92 EXPECT_THAT(u64Vector, ElementsAre(2, 4, 6, 8, 10));
93
94 std::string str;
95 EXPECT_TRUE(attrs2.GetStringValue(Attributes::ATTR_TEMPLATE_ID_LIST, str));
96 EXPECT_EQ(str, "iam");
97 }
98
99 HWTEST_F(AttributesTest, AttributesBoolValue, TestSize.Level0)
100 {
101 Attributes attrs;
102 EXPECT_TRUE(attrs.SetBoolValue(Attributes::ATTR_RESULT_CODE, true));
103 EXPECT_TRUE(attrs.SetBoolValue(Attributes::ATTR_SIGNATURE, false));
104
105 bool value1;
106 bool value2;
107 EXPECT_TRUE(attrs.GetBoolValue(Attributes::ATTR_RESULT_CODE, value1));
108 EXPECT_TRUE(attrs.GetBoolValue(Attributes::ATTR_SIGNATURE, value2));
109 EXPECT_TRUE(value1);
110 EXPECT_FALSE(value2);
111 }
112
113 HWTEST_F(AttributesTest, AttributesUint64Value, TestSize.Level0)
114 {
115 Attributes attrs;
116 EXPECT_TRUE(attrs.SetUint64Value(Attributes::ATTR_RESULT_CODE, UINT32_MAX));
117 EXPECT_TRUE(attrs.SetUint64Value(Attributes::ATTR_SIGNATURE, UINT64_MAX));
118
119 uint64_t value1;
120 uint64_t value2;
121 EXPECT_TRUE(attrs.GetUint64Value(Attributes::ATTR_RESULT_CODE, value1));
122 EXPECT_TRUE(attrs.GetUint64Value(Attributes::ATTR_SIGNATURE, value2));
123 EXPECT_EQ(value1, UINT32_MAX);
124 EXPECT_EQ(value2, UINT64_MAX);
125 }
126
127 HWTEST_F(AttributesTest, AttributesUint32Value, TestSize.Level0)
128 {
129 Attributes attrs;
130 EXPECT_TRUE(attrs.SetUint32Value(Attributes::ATTR_RESULT_CODE, UINT16_MAX));
131 EXPECT_TRUE(attrs.SetUint32Value(Attributes::ATTR_SIGNATURE, UINT32_MAX));
132
133 uint32_t value1;
134 uint32_t value2;
135 EXPECT_TRUE(attrs.GetUint32Value(Attributes::ATTR_RESULT_CODE, value1));
136 EXPECT_TRUE(attrs.GetUint32Value(Attributes::ATTR_SIGNATURE, value2));
137 EXPECT_TRUE(value1 == UINT16_MAX);
138 EXPECT_TRUE(value2 == UINT32_MAX);
139 }
140
141 HWTEST_F(AttributesTest, AttributesUint16Value, TestSize.Level0)
142 {
143 Attributes attrs;
144 EXPECT_TRUE(attrs.SetUint16Value(Attributes::ATTR_RESULT_CODE, UINT8_MAX));
145 EXPECT_TRUE(attrs.SetUint16Value(Attributes::ATTR_SIGNATURE, UINT16_MAX));
146
147 uint16_t value1;
148 uint16_t value2;
149 EXPECT_TRUE(attrs.GetUint16Value(Attributes::ATTR_RESULT_CODE, value1));
150 EXPECT_TRUE(attrs.GetUint16Value(Attributes::ATTR_SIGNATURE, value2));
151 EXPECT_TRUE(value1 == UINT8_MAX);
152 EXPECT_TRUE(value2 == UINT16_MAX);
153 }
154
155 HWTEST_F(AttributesTest, AttributesUint8Value, TestSize.Level0)
156 {
157 Attributes attrs;
158 EXPECT_TRUE(attrs.SetUint8Value(Attributes::ATTR_RESULT_CODE, 0));
159 EXPECT_TRUE(attrs.SetUint8Value(Attributes::ATTR_SIGNATURE, UINT8_MAX));
160
161 uint8_t value1;
162 uint8_t value2;
163 EXPECT_TRUE(attrs.GetUint8Value(Attributes::ATTR_RESULT_CODE, value1));
164 EXPECT_TRUE(attrs.GetUint8Value(Attributes::ATTR_SIGNATURE, value2));
165 EXPECT_EQ(value1, 0);
166 EXPECT_EQ(value2, UINT8_MAX);
167 }
168
169 HWTEST_F(AttributesTest, AttributesStringValue, TestSize.Level0)
170 {
171 Attributes attrs;
172 EXPECT_TRUE(attrs.SetStringValue(Attributes::ATTR_RESULT_CODE, "hello iam"));
173 EXPECT_TRUE(attrs.SetStringValue(Attributes::ATTR_SIGNATURE, ""));
174
175 std::string value1;
176 std::string value2;
177 EXPECT_TRUE(attrs.GetStringValue(Attributes::ATTR_RESULT_CODE, value1));
178 EXPECT_TRUE(attrs.GetStringValue(Attributes::ATTR_SIGNATURE, value2));
179 EXPECT_EQ(value1, "hello iam");
180 EXPECT_EQ(value2, "");
181 }
182
183 HWTEST_F(AttributesTest, AttributesUint64ByteArray, TestSize.Level0)
184 {
185 {
186 constexpr int SIZE = 8192;
187
188 Attributes attrs;
189 std::vector<uint64_t> array;
190 array.reserve(SIZE);
191 for (int i = 0; i < SIZE; i++) {
192 array.push_back(UINT64_MAX - i);
193 }
194 EXPECT_TRUE(attrs.SetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
195
196 std::vector<uint64_t> out;
197 EXPECT_TRUE(attrs.GetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, out));
198 EXPECT_THAT(out, ElementsAreArray(array));
199 }
200
201 {
202 Attributes attrs;
203 std::vector<uint64_t> array;
204 EXPECT_TRUE(attrs.SetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
205 EXPECT_TRUE(attrs.GetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
206 EXPECT_TRUE(array.empty());
207 }
208 }
209
210 HWTEST_F(AttributesTest, AttributesUint32ByteArray, TestSize.Level0)
211 {
212 {
213 constexpr int SIZE = 8192;
214
215 Attributes attrs;
216 std::vector<uint32_t> array;
217 array.reserve(SIZE);
218 for (int i = 0; i < SIZE; i++) {
219 array.push_back(UINT32_MAX - i);
220 }
221 EXPECT_TRUE(attrs.SetUint32ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
222
223 std::vector<uint32_t> out;
224 EXPECT_TRUE(attrs.GetUint32ArrayValue(Attributes::ATTR_FREEZING_TIME, out));
225 EXPECT_THAT(out, ElementsAreArray(array));
226 }
227 {
228 Attributes attrs;
229 std::vector<uint32_t> array;
230 EXPECT_TRUE(attrs.SetUint32ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
231
232 EXPECT_TRUE(attrs.GetUint32ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
233 EXPECT_TRUE(array.empty());
234 }
235 }
236
237 HWTEST_F(AttributesTest, AttributesUint16ByteArray, TestSize.Level0)
238 {
239 {
240 constexpr int SIZE = 8192;
241
242 Attributes attrs;
243 std::vector<uint16_t> array;
244 array.reserve(SIZE);
245 for (int i = 0; i < SIZE; i++) {
246 array.push_back(UINT16_MAX - i);
247 }
248 EXPECT_TRUE(attrs.SetUint16ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
249
250 std::vector<uint16_t> out;
251 EXPECT_TRUE(attrs.GetUint16ArrayValue(Attributes::ATTR_FREEZING_TIME, out));
252 EXPECT_THAT(out, ElementsAreArray(array));
253 }
254 {
255 Attributes attrs;
256 std::vector<uint16_t> array;
257 EXPECT_TRUE(attrs.SetUint16ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
258
259 EXPECT_TRUE(attrs.GetUint16ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
260 EXPECT_TRUE(array.empty());
261 }
262 }
263
264 HWTEST_F(AttributesTest, AttributesUint8ByteArray, TestSize.Level0)
265 {
266 {
267 constexpr int SIZE = 8192;
268
269 Attributes attrs;
270 std::vector<uint8_t> array;
271 array.reserve(SIZE);
272 for (int i = 0; i < SIZE; i++) {
273 array.push_back(i);
274 }
275 EXPECT_TRUE(attrs.SetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
276
277 std::vector<uint8_t> out;
278 EXPECT_TRUE(attrs.GetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, out));
279 EXPECT_THAT(out, ElementsAreArray(array));
280 }
281 {
282 Attributes attrs;
283 std::vector<uint8_t> array;
284 EXPECT_TRUE(attrs.SetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
285
286 EXPECT_TRUE(attrs.GetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, array));
287 EXPECT_TRUE(array.empty());
288 }
289 }
290
291 HWTEST_F(AttributesTest, AttributesDeserialize, TestSize.Level0)
292 {
293 const std::vector<Attributes::AttributeKey> desired = {Attributes::ATTR_RESULT_CODE, Attributes::ATTR_SIGNATURE,
294 Attributes::ATTR_TEMPLATE_ID_LIST, Attributes::ATTR_REMAIN_TIMES, Attributes::ATTR_FREEZING_TIME,
295 Attributes::ATTR_SCHEDULE_ID, Attributes::ATTR_SCHEDULE_MODE};
296
297 const std::vector<uint8_t> raw = {161, 134, 1, 0, 1, 0, 0, 0, 1, 164, 134, 1, 0, 1, 0, 0, 0, 0, 167, 134, 1, 0, 4,
298 0, 0, 0, 105, 97, 109, 0, 169, 134, 1, 0, 20, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 5, 0, 0, 0, 7, 0, 0, 0, 9, 0, 0,
299 0, 170, 134, 1, 0, 40, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0,
300 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 180, 134, 1, 0, 8, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 182,
301 134, 1, 0, 4, 0, 0, 0, 255, 255, 255, 255};
302
303 Attributes attrs(raw);
304 EXPECT_THAT(attrs.GetKeys(), ElementsAreArray(desired));
305 {
306 bool value;
307 EXPECT_TRUE(attrs.GetBoolValue(Attributes::ATTR_RESULT_CODE, value));
308 EXPECT_EQ(value, true);
309 }
310 {
311 bool value;
312 EXPECT_TRUE(attrs.GetBoolValue(Attributes::ATTR_SIGNATURE, value));
313 EXPECT_EQ(value, false);
314 }
315 {
316 uint64_t value;
317 EXPECT_TRUE(attrs.GetUint64Value(Attributes::ATTR_SCHEDULE_ID, value));
318 EXPECT_EQ(value, UINT64_MAX);
319 }
320 {
321 std::vector<uint32_t> value;
322 EXPECT_TRUE(attrs.GetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, value));
323 EXPECT_THAT(value, ElementsAre(1, 3, 5, 7, 9));
324 }
325 {
326 uint32_t value;
327 EXPECT_TRUE(attrs.GetUint32Value(Attributes::ATTR_SCHEDULE_MODE, value));
328 EXPECT_EQ(value, UINT32_MAX);
329 }
330 {
331 std::vector<uint64_t> value;
332 EXPECT_TRUE(attrs.GetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, value));
333 EXPECT_THAT(value, ElementsAre(2, 4, 6, 8, 10));
334 }
335 {
336 std::string value;
337 EXPECT_TRUE(attrs.GetStringValue(Attributes::ATTR_TEMPLATE_ID_LIST, value));
338 EXPECT_EQ(value, "iam");
339 }
340 }
341
342 HWTEST_F(AttributesTest, AttributesInAttribute, TestSize.Level0)
343 {
344 const std::vector<uint8_t> raw = {161, 134, 1, 0, 1, 0, 0, 0, 1, 164, 134, 1, 0, 1, 0, 0, 0, 0, 167, 134, 1, 0, 4,
345 0, 0, 0, 105, 97, 109, 0, 169, 134, 1, 0, 20, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 5, 0, 0, 0, 7, 0, 0, 0, 9, 0, 0,
346 0, 170, 134, 1, 0, 40, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0,
347 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 180, 134, 1, 0, 8, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 182,
348 134, 1, 0, 4, 0, 0, 0, 255, 255, 255, 255};
349
350 Attributes attrs1;
351 EXPECT_TRUE(attrs1.SetBoolValue(Attributes::ATTR_RESULT_CODE, true));
352 EXPECT_TRUE(attrs1.SetBoolValue(Attributes::ATTR_SIGNATURE, false));
353 EXPECT_TRUE(attrs1.SetUint64Value(Attributes::ATTR_SCHEDULE_ID, UINT64_MAX));
354 EXPECT_TRUE(attrs1.SetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, {1, 3, 5, 7, 9}));
355 EXPECT_TRUE(attrs1.SetUint32Value(Attributes::ATTR_SCHEDULE_MODE, UINT32_MAX));
356 EXPECT_TRUE(attrs1.SetUint64ArrayValue(Attributes::ATTR_FREEZING_TIME, {2, 4, 6, 8, 10}));
357 EXPECT_TRUE(attrs1.SetStringValue(Attributes::ATTR_TEMPLATE_ID_LIST, "iam"));
358
359 Attributes attrs2;
360 EXPECT_TRUE(attrs2.SetAttributesValue(Attributes::ATTR_RESULT_CODE, attrs1));
361
362 Attributes attrs3(attrs2.Serialize());
363
364 Attributes attrs4;
365 EXPECT_TRUE(attrs3.GetAttributesValue(Attributes::ATTR_RESULT_CODE, attrs4));
366 EXPECT_THAT(attrs4.Serialize(), ElementsAreArray(raw));
367 }
368
369 HWTEST_F(AttributesTest, AttributesDeserializeMismatch, TestSize.Level0)
370 {
371 const std::vector<uint8_t> raw = {0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 20, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 5, 0,
372 0, 0, 7, 0, 0, 0, 9, 0, 0, 0, 3, 0, 0, 0, 40, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0,
373 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0,
374 0, 255, 255, 255, 255, 6, 0, 0, 0, 8, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 7, 0, 0, 0, 4, 0, 0, 0,
375 105, 97, 109, 0};
376
377 Attributes attrs(raw);
378 {
379 bool value;
380 EXPECT_FALSE(attrs.GetBoolValue(Attributes::ATTR_TEMPLATE_ID_LIST, value));
381 }
382 {
383 uint16_t value;
384 EXPECT_FALSE(attrs.GetUint16Value(Attributes::ATTR_TEMPLATE_ID_LIST, value));
385 }
386 }
387
388 HWTEST_F(AttributesTest, AttributesEmptyArrays, TestSize.Level0)
389 {
390 Attributes attrs1;
391 bool value = true;
392 EXPECT_TRUE(attrs1.SetBoolValue(Attributes::ATTR_RESULT_CODE, value));
393
394 std::vector<uint64_t> u64Vector;
395 EXPECT_TRUE(attrs1.SetUint64ArrayValue(Attributes::ATTR_SCHEDULE_ID, u64Vector));
396
397 std::vector<uint32_t> u32Vector;
398 EXPECT_TRUE(attrs1.SetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, u32Vector));
399
400 std::vector<uint16_t> u16Vector;
401 EXPECT_TRUE(attrs1.SetUint16ArrayValue(Attributes::ATTR_TEMPLATE_ID_LIST, u16Vector));
402
403 std::vector<uint8_t> u8Vector;
404 EXPECT_TRUE(attrs1.SetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, u8Vector));
405
406 auto buff = attrs1.Serialize();
407 EXPECT_FALSE(buff.empty());
408 Attributes attrs2(buff);
409 EXPECT_TRUE(attrs1.GetBoolValue(Attributes::ATTR_RESULT_CODE, value));
410 EXPECT_TRUE(value);
411
412 EXPECT_TRUE(attrs1.GetUint64ArrayValue(Attributes::ATTR_SCHEDULE_ID, u64Vector));
413 EXPECT_THAT(u64Vector, IsEmpty());
414
415 EXPECT_TRUE(attrs1.GetUint32ArrayValue(Attributes::ATTR_REMAIN_TIMES, u32Vector));
416 EXPECT_THAT(u32Vector, IsEmpty());
417
418 EXPECT_TRUE(attrs1.GetUint16ArrayValue(Attributes::ATTR_TEMPLATE_ID_LIST, u16Vector));
419 EXPECT_THAT(u16Vector, IsEmpty());
420
421 EXPECT_TRUE(attrs1.GetUint8ArrayValue(Attributes::ATTR_FREEZING_TIME, u8Vector));
422 EXPECT_THAT(u8Vector, IsEmpty());
423 }
424
425 HWTEST_F(AttributesTest, AttributesCopyAndMove, TestSize.Level0)
426 {
427 EXPECT_FALSE(std::is_copy_assignable<Attributes>::value);
428 EXPECT_FALSE(std::is_copy_constructible<Attributes>::value);
429
430 const std::vector<uint8_t> raw = {0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 255,
431 255, 255, 255, 3, 0, 0, 0, 8, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 4, 0, 0, 0, 4, 0, 0, 0, 105, 97,
432 109, 0, 5, 0, 0, 0, 20, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 5, 0, 0, 0, 7, 0, 0, 0, 9, 0, 0, 0, 6, 0, 0, 0, 40, 0,
433 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0,
434 0, 0, 0, 0, 0};
435 Attributes attrs1(raw);
436
437 EXPECT_THAT(attrs1.Serialize(), ElementsAreArray(raw));
438
439 Attributes attrs2 = std::move(attrs1);
440
441 EXPECT_EQ(attrs1.Serialize().size(), 0U);
442 EXPECT_THAT(attrs2.Serialize(), ElementsAreArray(raw));
443 }
444 } // namespace UserAuth
445 } // namespace UserIam
446 } // namespace OHOS
447