1/*
2 * Copyright (c) 2024-2024 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 "signature_tools_log.h"
18#include "options.h"
19#include "sign_tool_service_impl.h"
20#include "localization_adapter.h"
21#include "openssl/ssl.h"
22#include "openssl/pem.h"
23#include "openssl/err.h"
24#include "p12_local.h"
25#include "cmd_util.h"
26#include "file_utils.h"
27#include "params_run_tool.h"
28#include "constant.h"
29#include "params.h"
30#include "params_trust_list.h"
31#include "param_constants.h"
32
33namespace OHOS {
34namespace SignatureTools {
35
36class OptionsCmdTest : public testing::Test {
37public:
38    static void SetUpTestCase()
39    {
40    };
41    static void TearDownTestCase()
42    {
43    };
44    void SetUp()
45    {
46    };
47    void TearDown()
48    {
49    };
50};
51
52/*
53 * @tc.name: Options_test_001
54 * @tc.desc: get char* type value, and do type checking.
55 * @tc.type: FUNC
56 * @tc.require:
57 */
58HWTEST_F(OptionsCmdTest, Options_test_001, testing::ext::TestSize.Level1)
59{
60    std::shared_ptr<Options> params = std::make_shared<Options>();
61    char keyPwd[] = "123456";
62    (*params)["keyPwd"] = keyPwd;
63
64    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
65    char* strPrt = adaptePtr->options->GetChars(Options::KEY_RIGHTS);
66    EXPECT_NE(strPrt, nullptr);
67}
68
69/*
70 * @tc.name: Options_test_002
71 * @tc.desc: get string type value, and do type checking.
72 * @tc.type: FUNC
73 * @tc.require:
74 */
75HWTEST_F(OptionsCmdTest, Options_test_002, testing::ext::TestSize.Level1)
76{
77    std::shared_ptr<Options> params = std::make_shared<Options>();
78    std::string keyAlias = "oh-app1-key-v1";
79    (*params)["keyAlias"] = keyAlias;
80    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
81    std::string strPrt = adaptePtr->options->GetString(Options::KEY_ALIAS);
82
83    EXPECT_NE(strPrt, "");
84}
85
86/*
87 * @tc.name: Options_test_003
88 * @tc.desc: get two-parameter string type value, and do type checking.
89 * @tc.type: FUNC
90 * @tc.require:
91 */
92HWTEST_F(OptionsCmdTest, Options_test_003, testing::ext::TestSize.Level1)
93{
94    std::shared_ptr<Options> params = std::make_shared<Options>();
95    std::string keyAlias = "oh-app1-key-v1";
96    std::string str = "test";
97    (*params)["keyAlias"] = keyAlias;
98    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
99    std::string strPrt = adaptePtr->options->GetString(Options::KEY_ALIAS, str);
100
101    if (strPrt == keyAlias) {
102        EXPECT_EQ(strPrt, keyAlias);
103    } else if (strPrt == str) {
104        EXPECT_EQ(strPrt, str);
105    } else {
106        EXPECT_EQ(strPrt, keyAlias);
107    }
108}
109
110/*
111 * @tc.name: Options_test_004
112 * @tc.desc: get Int type value, and do type checking.
113 * @tc.type: FUNC
114 * @tc.require:
115 */
116HWTEST_F(OptionsCmdTest, Options_test_004, testing::ext::TestSize.Level1)
117{
118    std::shared_ptr<Options> params = std::make_shared<Options>();
119    int keySize = 256;
120    (*params)["keySize"] = keySize;
121    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
122    int size = adaptePtr->options->GetInt(Options::KEY_SIZE);
123
124    EXPECT_NE(size, 0);
125}
126
127/*
128 * @tc.name: Options_test_005
129 * @tc.desc: Check for equality.
130 * @tc.type: FUNC
131 * @tc.require:
132 */
133HWTEST_F(OptionsCmdTest, Options_test_005, testing::ext::TestSize.Level1)
134{
135    std::shared_ptr<Options> params = std::make_shared<Options>();
136    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
137    std::string issuerkeystoreFile = "./generateKeyPair/OpenHarmony.p12";
138
139    (*params)["keystoreFile"] = keystoreFile;
140    (*params)["issuerkeystoreFile"] = issuerkeystoreFile;
141
142    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
143    EXPECT_EQ(adaptePtr->options->Equals(Options::KEY_STORE_FILE, Options::ISSUER_KEY_STORE_FILE), false);
144}
145
146/*
147 * @tc.name: Options_test_006
148 * @tc.desc: Check for presence.
149 * @tc.type: FUNC
150 * @tc.require:
151 */
152HWTEST_F(OptionsCmdTest, Options_test_006, testing::ext::TestSize.Level1)
153{
154    std::shared_ptr<Options> params = std::make_shared<Options>();
155
156    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
157    std::string issuerkeystoreFile = "./generateKeyPair/OpenHarmony.p12";
158
159    (*params)["keystoreFile"] = keystoreFile;
160    (*params)["issuerkeystoreFile"] = issuerkeystoreFile;
161
162    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
163    EXPECT_EQ(adaptePtr->options->Required({ Options::KEY_STORE_FILE, Options::ISSUER_KEY_STORE_FILE }), false);
164}
165/*
166 * @tc.name: Options_test_007
167 * @tc.desc: Check whether it is empty.
168 * @tc.type: FUNC
169 * @tc.require:
170 */
171HWTEST_F(OptionsCmdTest, Options_test_007, testing::ext::TestSize.Level1)
172{
173    std::shared_ptr<Options> params = std::make_shared<Options>();
174    std::string str = "";
175    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
176    EXPECT_EQ(adaptePtr->options->IsEmpty(str), true);
177}
178
179/*
180* @tc.name: Options_test_008
181* @tc.desc: get string type value, and do type checking.
182* @tc.type: FUNC
183* @tc.require:
184*/
185HWTEST_F(OptionsCmdTest, Options_test_008, testing::ext::TestSize.Level1)
186{
187    std::shared_ptr<Options> params = std::make_shared<Options>();
188    std::string keyAlias = "oh-app1-key-v1";
189    (*params)["keyAlias"];
190
191    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
192    std::string strPrt = adaptePtr->options->GetString(Options::KEY_ALIAS);
193    EXPECT_EQ(strPrt, "");
194}
195
196/*
197 * @tc.name: Options_test_009
198 * @tc.desc: get string type value, and do type checking.
199 * @tc.type: FUNC
200 * @tc.require:
201 */
202HWTEST_F(OptionsCmdTest, Options_test_009, testing::ext::TestSize.Level1)
203{
204    std::shared_ptr<Options> params = std::make_shared<Options>();
205    std::string keyAlias = "oh-app1-key-v1";
206    (*params)["keyAlias"] = keyAlias;
207
208    std::string strPrt = params->GetString(Options::KEY_STORE_FILE);
209    EXPECT_EQ(strPrt, "");
210}
211
212/*
213 * @tc.name: Options_test_010
214 * @tc.desc: get string type value, and do type checking.
215 * @tc.type: FUNC
216 * @tc.require:
217 */
218HWTEST_F(OptionsCmdTest, Options_test_010, testing::ext::TestSize.Level1)
219{
220    std::shared_ptr<Options> params = std::make_shared<Options>();
221    std::string keyAlias = "oh-app1-key-v1";
222    char keyPwd[] = "123456";
223
224    (*params)["keyAlias"] = keyAlias;
225    (*params)["keyPwd"] = keyPwd;
226    std::string strPrt = params->GetString(Options::KEY_RIGHTS);
227    EXPECT_EQ(strPrt, "");
228}
229
230/*
231 * @tc.name: Options_test_011
232 * @tc.desc: get two-parameter string type value, and do type checking.
233 * @tc.type: FUNC
234 * @tc.require:
235 */
236HWTEST_F(OptionsCmdTest, Options_test_011, testing::ext::TestSize.Level1)
237{
238    std::shared_ptr<Options> params = std::make_shared<Options>();
239
240    std::string keyAlias = "oh-app1-key-v1";
241    char keyPwd[] = "123456";
242    std::string str = "abcd";
243
244    (*params)["keyAlias"] = keyAlias;
245    (*params)["keyPwd"] = keyPwd;
246    std::string strPrt = params->GetString(Options::KEY_RIGHTS, str);
247    EXPECT_EQ(strPrt, str);
248}
249
250/*
251 * @tc.name: Options_test_012
252 * @tc.desc: get two-parameter string type value, and do type checking.
253 * @tc.type: FUNC
254 * @tc.require:
255 */
256HWTEST_F(OptionsCmdTest, Options_test_012, testing::ext::TestSize.Level1)
257{
258    std::shared_ptr<Options> params = std::make_shared<Options>();
259
260    std::string keyAlias = "";
261    char keyPwd[] = "123456";
262    std::string str = "abcd";
263
264    (*params)["keyAlias"] = keyAlias;
265    (*params)["keyPwd"] = keyPwd;
266    std::string strPrt = params->GetString(Options::KEY_ALIAS, str);
267    EXPECT_EQ(strPrt, str);
268}
269
270/*
271 * @tc.name: Options_test_013
272 * @tc.desc: Check if required parameters exist.
273 * @tc.type: FUNC
274 * @tc.require:
275 */
276HWTEST_F(OptionsCmdTest, Options_test_013, testing::ext::TestSize.Level1)
277{
278    std::shared_ptr<Options> params = std::make_shared<Options>();
279
280    std::string keyAlias = "oh-app1-key-v1";
281    std::string signAlg = "SHA256withECDSA";
282    std::string outForm = "cert";
283    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
284
285    (*params)["keyAlias"] = keyAlias;
286    (*params)["signAlg"] = signAlg;
287    (*params)["outForm"] = outForm;
288    (*params)["keystoreFile"] = keystoreFile;
289    bool ret = params->Required({ Options::KEY_ALIAS, Options::SIGN_ALG, Options::OUT_FORM, Options::KEY_STORE_FILE });
290    EXPECT_EQ(ret, true);
291}
292
293/*
294 * @tc.name: Options_test_014
295 * @tc.desc: Check if required parameters exist.
296 * @tc.type: FUNC
297 * @tc.require:
298 */
299HWTEST_F(OptionsCmdTest, Options_test_014, testing::ext::TestSize.Level1)
300{
301    std::shared_ptr<Options> params = std::make_shared<Options>();
302    bool ret = params->Required({ "" });
303    EXPECT_EQ(ret, true);
304}
305
306/*
307 * @tc.name: Options_test_015
308 * @tc.desc: Check if required parameters exist.
309 * @tc.type: FUNC
310 * @tc.require:
311 */
312HWTEST_F(OptionsCmdTest, Options_test_015, testing::ext::TestSize.Level1)
313{
314    std::shared_ptr<Options> params = std::make_shared<Options>();
315    std::string keyAlias = "oh-app1-key-v1";
316
317    (*params)["inFile"] = keyAlias;
318    bool ret = params->Required({ Options::KEY_ALIAS });
319    EXPECT_EQ(ret, false);
320}
321
322/*
323 * @tc.name: Options_test_016
324 * @tc.desc: Check whether the algorithm is in ECC format.
325 * @tc.type: FUNC
326 * @tc.require:
327 */
328HWTEST_F(OptionsCmdTest, Options_test_016, testing::ext::TestSize.Level1)
329{
330    std::string keyAlg = "ECC";
331    EXPECT_EQ(CmdUtil::JudgeAlgType(keyAlg), true);
332}
333
334/*
335 * @tc.name: Options_test_017
336 * @tc.desc: Check whether the algorithm length is 256 or 384.
337 * @tc.type: FUNC
338 * @tc.require:
339 */
340HWTEST_F(OptionsCmdTest, Options_test_017, testing::ext::TestSize.Level1)
341{
342    int size = 256;
343    EXPECT_EQ(CmdUtil::JudgeSize(size), true);
344}
345
346/*
347 * @tc.name: Options_test_018
348 * @tc.desc: Write command line arguments to map.
349 * @tc.type: FUNC
350 * @tc.require:
351 */
352HWTEST_F(OptionsCmdTest, Options_test_018, testing::ext::TestSize.Level1)
353{
354    char arg0[] = "";
355    char arg1[] = "generate-keypair";
356    char arg2[] = "-keyAlias";
357    char arg3[] = "oh-app1-key-v1";
358    char arg4[] = "-keyPwd";
359    char arg5[] = "123456";
360    char arg6[] = "-keyAlg";
361    char arg7[] = "ECC";
362    char arg8[] = "-keySize";
363    char arg9[] = "NIST-P-384";
364    char arg10[] = "-keystoreFile";
365    char arg11[] = "./generateKeyPair/OpenHarmony.p12";
366    char arg12[] = "-keystorePwd";
367    char arg13[] = "123456";
368    char* argv[] = { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 };
369    int argc = 14;
370
371    CmdUtil cmdUtil;
372    ParamsSharedPtr param = std::make_shared<Params>();
373    bool ret = cmdUtil.Convert2Params(argv, argc, param);
374
375    EXPECT_EQ(ret, true);
376}
377
378/*
379 * @tc.name: Options_test_019
380 * @tc.desc: Gets command line arguments.
381 * @tc.type: FUNC
382 * @tc.require:
383 */
384HWTEST_F(OptionsCmdTest, Options_test_019, testing::ext::TestSize.Level1)
385{
386    char argv[][100] = { "generate-keypair",
387                     "-keyAlias", "oh-app1-key-v1",
388                     "-keyPwd", "123456",
389                     "-keyAlg", "ECC",
390                     "-keySize", "NIST-P-384",
391                     "-keystoreFile", "./generateKeyPair/OpenHarmony.p12",
392                     "-keystorePwd", "123456"
393    };
394
395    ParamsTrustList params_trust_list;
396    std::vector<std::string> trustList = params_trust_list.GetTrustList(argv[1]);
397    if (trustList.empty()) {
398        bool ret = false;
399        EXPECT_EQ(ret, false);
400    } else {
401        bool ret = true;
402        EXPECT_EQ(ret, true);
403    }
404}
405
406/*
407 * @tc.name: Options_test_020
408 * @tc.desc: Check whether the file format is p12 or jks.
409 * @tc.type: FUNC
410 * @tc.require:
411 */
412HWTEST_F(OptionsCmdTest, Options_test_020, testing::ext::TestSize.Level1)
413{
414    std::shared_ptr<Options> params = std::make_shared<Options>();
415    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
416    (*params)["keystoreFile"] = keystoreFile;
417
418    std::unique_ptr<LocalizationAdapter> adaptePtr = std::make_unique<LocalizationAdapter>(params.get());
419    EXPECT_EQ(FileUtils::ValidFileType(adaptePtr->options->GetString(Options::KEY_STORE_FILE),
420              { "p12", "jks" }), true);
421}
422
423/*
424* @tc.name: Options_test_021
425* @tc.desc: Checks whether the type is legal.
426* @tc.type: FUNC
427* @tc.require:
428*/
429HWTEST_F(OptionsCmdTest, Options_test_021, testing::ext::TestSize.Level1)
430{
431    std::string str = "";
432    bool ret = CmdUtil::VerifyTypes(str);
433
434    EXPECT_EQ(ret, false);
435}
436
437/*
438 * @tc.name: Options_test_022
439 * @tc.desc: The sign-app module checks whether the inFile module is a valid path.
440 * @tc.type: FUNC
441 * @tc.require:
442 */
443HWTEST_F(OptionsCmdTest, Options_test_022, testing::ext::TestSize.Level1)
444{
445    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
446    std::shared_ptr<Options> params = std::make_shared<Options>();
447
448    std::string mode = "abcd";
449    std::string keyAlias = "oh-app1-key-v1";
450    char keyPwd[] = "123456";
451    std::string signCode = "1";
452    std::string signAlg = "SHA384withECDSA";
453    std::string appCertFile = "./generateKeyPair/app-release1.pem";
454    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
455    std::string inFile = "OpenHarmonyDamage.p12";
456    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
457    char keystorePwd[] = "123456";
458    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
459
460    (*params)["mode"] = mode;
461    (*params)["keyAlias"] = keyAlias;
462    (*params)["keyPwd"] = keyPwd;
463    (*params)["signCode"] = signCode;
464    (*params)["signAlg"] = signAlg;
465    (*params)["appCertFile"] = appCertFile;
466    (*params)["profileFile"] = profileFile;
467    (*params)["inFile"] = inFile;
468    (*params)["keystoreFile"] = keystoreFile;
469    (*params)["keystorePwd"] = keystorePwd;
470    (*params)["outFile"] = outFile;
471
472    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
473    EXPECT_EQ(ret, false);
474}
475
476/*
477 * @tc.name: Options_test_023
478 * @tc.desc: The sign-app module checks if inform is a valid parameter.
479 * @tc.type: FUNC
480 * @tc.require:
481 */
482HWTEST_F(OptionsCmdTest, Options_test_023, testing::ext::TestSize.Level1)
483{
484    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
485    std::shared_ptr<Options> params = std::make_shared<Options>();
486
487    std::string mode = "localSign";
488    std::string keyAlias = "oh-app1-key-v1";
489    char keyPwd[] = "123456";
490    std::string signCode = "1";
491    std::string signAlg = "SHA384withECDSA";
492    std::string appCertFile = "./generateKeyPair/app-release1.pem";
493    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
494    std::string inFile = "OpenHarmonyDamage.p12";
495    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
496    char keystorePwd[] = "123456";
497    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
498    std::string inform = "abcd";
499
500    (*params)["mode"] = mode;
501    (*params)["keyAlias"] = keyAlias;
502    (*params)["keyPwd"] = keyPwd;
503    (*params)["signCode"] = signCode;
504    (*params)["signAlg"] = signAlg;
505    (*params)["appCertFile"] = appCertFile;
506    (*params)["profileFile"] = profileFile;
507    (*params)["inFile"] = inFile;
508    (*params)["keystoreFile"] = keystoreFile;
509    (*params)["keystorePwd"] = keystorePwd;
510    (*params)["outFile"] = outFile;
511    (*params)["inForm"] = inform;
512
513    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
514    EXPECT_EQ(ret, false);
515}
516
517/*
518 * @tc.name: Options_test_024
519 * @tc.desc: The sign-app module checks if signAlg is a valid parameter.
520 * @tc.type: FUNC
521 * @tc.require:
522 */
523HWTEST_F(OptionsCmdTest, Options_test_024, testing::ext::TestSize.Level1)
524{
525    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
526    std::shared_ptr<Options> params = std::make_shared<Options>();
527
528    std::string mode = "localSign";
529    std::string keyAlias = "oh-app1-key-v1";
530    char keyPwd[] = "123456";
531    std::string signCode = "1";
532    std::string signAlg = "SHA384w";
533    std::string appCertFile = "./generateKeyPair/app-release1.pem";
534    std::string profileFile = "";
535    std::string inFile = "OpenHarmonyDamage.p12";
536    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
537    char keystorePwd[] = "123456";
538    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
539    std::string inform = "elf";
540
541    (*params)["mode"] = mode;
542    (*params)["keyAlias"] = keyAlias;
543    (*params)["keyPwd"] = keyPwd;
544    (*params)["signCode"] = signCode;
545    (*params)["signAlg"] = signAlg;
546    (*params)["appCertFile"] = appCertFile;
547    (*params)["profileFile"] = profileFile;
548    (*params)["inFile"] = inFile;
549    (*params)["keystoreFile"] = keystoreFile;
550    (*params)["keystorePwd"] = keystorePwd;
551    (*params)["outFile"] = outFile;
552    (*params)["inForm"] = inform;
553
554    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
555    EXPECT_EQ(ret, false);
556}
557
558/*
559 * @tc.name: Options_test_025
560 * @tc.desc: The sign-app module executes the branch with profileSigned = "1".
561 * @tc.type: FUNC
562 * @tc.require:
563 */
564HWTEST_F(OptionsCmdTest, Options_test_025, testing::ext::TestSize.Level1)
565{
566    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
567    std::shared_ptr<Options> params = std::make_shared<Options>();
568
569    std::string mode = "localSign";
570    std::string keyAlias = "oh-app1-key-v1";
571    char keyPwd[] = "123456";
572    std::string signCode = "1";
573    std::string signAlg = "SHA384withECDSA";
574    std::string appCertFile = "./generateKeyPair/app-release1.pem";
575    std::string profileFile = "./generateKeyPair/signed-profile.txt";
576    std::string inFile = "OpenHarmonyDamage.p12";
577    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
578    char keystorePwd[] = "123456";
579    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
580    std::string profileSigned = "1";
581
582    (*params)["mode"] = mode;
583    (*params)["keyAlias"] = keyAlias;
584    (*params)["keyPwd"] = keyPwd;
585    (*params)["signCode"] = signCode;
586    (*params)["signAlg"] = signAlg;
587    (*params)["appCertFile"] = appCertFile;
588    (*params)["profileFile"] = profileFile;
589    (*params)["inFile"] = inFile;
590    (*params)["keystoreFile"] = keystoreFile;
591    (*params)["keystorePwd"] = keystorePwd;
592    (*params)["outFile"] = outFile;
593    (*params)["profileSigned"] = profileSigned;
594
595    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
596    EXPECT_EQ(ret, false);
597}
598
599/*
600 * @tc.name: Options_test_026
601 * @tc.desc: The sign-app module executes the branch with profileSigned = "0".
602 * @tc.type: FUNC
603 * @tc.require:
604 */
605HWTEST_F(OptionsCmdTest, Options_test_026, testing::ext::TestSize.Level1)
606{
607    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
608    std::shared_ptr<Options> params = std::make_shared<Options>();
609
610    std::string mode = "localSign";
611    std::string keyAlias = "oh-app1-key-v1";
612    char keyPwd[] = "123456";
613    std::string signCode = "1";
614    std::string signAlg = "SHA384withECDSA";
615    std::string appCertFile = "./generateKeyPair/app-release1.pem";
616    std::string profileFile = "./generateKeyPair/signed-profile.txt";
617    std::string inFile = "OpenHarmonyDamage.p12";
618    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
619    char keystorePwd[] = "123456";
620    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
621    std::string profileSigned = "0";
622
623    (*params)["mode"] = mode;
624    (*params)["keyAlias"] = keyAlias;
625    (*params)["keyPwd"] = keyPwd;
626    (*params)["signCode"] = signCode;
627    (*params)["signAlg"] = signAlg;
628    (*params)["appCertFile"] = appCertFile;
629    (*params)["profileFile"] = profileFile;
630    (*params)["inFile"] = inFile;
631    (*params)["keystoreFile"] = keystoreFile;
632    (*params)["keystorePwd"] = keystorePwd;
633    (*params)["outFile"] = outFile;
634    (*params)["profileSigned"] = profileSigned;
635
636    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
637    EXPECT_EQ(ret, false);
638}
639
640/*
641 * @tc.name: Options_test_027
642 * @tc.desc: sign-app module parameter validation.
643 * @tc.type: FUNC
644 * @tc.require:
645 */
646HWTEST_F(OptionsCmdTest, Options_test_027, testing::ext::TestSize.Level1)
647{
648    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
649    std::shared_ptr<Options> params = std::make_shared<Options>();
650
651    std::string mode = "localSign";
652    std::string keyAlias = "oh-app1-key-v1";
653    char keyPwd[] = "123456";
654    std::string signCode = "1";
655    std::string signAlg = "SHA384withECDSA";
656    std::string appCertFile = "./generateKeyPair/app-release1.pem";
657    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
658    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
659    char keystorePwd[] = "123456";
660    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
661
662    (*params)["mode"] = mode;
663    (*params)["keyAlias"] = keyAlias;
664    (*params)["keyPwd"] = keyPwd;
665    (*params)["signCode"] = signCode;
666    (*params)["signAlg"] = signAlg;
667    (*params)["appCertFile"] = appCertFile;
668    (*params)["profileFile"] = profileFile;
669    (*params)["keystoreFile"] = keystoreFile;
670    (*params)["keystorePwd"] = keystorePwd;
671    (*params)["outFile"] = outFile;
672
673    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
674    EXPECT_EQ(ret, false);
675}
676
677/*
678 * @tc.name: Options_test_028
679 * @tc.desc: sign-app module parameter validation.
680 * @tc.type: FUNC
681 * @tc.require:
682 */
683HWTEST_F(OptionsCmdTest, Options_test_028, testing::ext::TestSize.Level1)
684{
685    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
686    std::shared_ptr<Options> params = std::make_shared<Options>();
687
688    std::string mode = "localSign";
689    std::string keyAlias = "oh-app1-key-v1";
690    char keyPwd[] = "123456";
691    std::string signCode = "1";
692    std::string signAlg = "SHA384withECDSA";
693    std::string appCertFile = "./generateKeyPair/app-release1.pem";
694    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
695    std::string inFile = "OpenHarmonyDamage.p12";
696    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
697    char keystorePwd[] = "123456";
698
699    (*params)["mode"] = mode;
700    (*params)["keyAlias"] = keyAlias;
701    (*params)["keyPwd"] = keyPwd;
702    (*params)["signCode"] = signCode;
703    (*params)["signAlg"] = signAlg;
704    (*params)["appCertFile"] = appCertFile;
705    (*params)["profileFile"] = profileFile;
706    (*params)["inFile"] = inFile;
707    (*params)["keystoreFile"] = keystoreFile;
708    (*params)["keystorePwd"] = keystorePwd;
709
710    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
711    EXPECT_EQ(ret, false);
712}
713
714/*
715 * @tc.name: Options_test_029
716 * @tc.desc: sign-app module parameter validation.
717 * @tc.type: FUNC
718 * @tc.require:
719 */
720HWTEST_F(OptionsCmdTest, Options_test_029, testing::ext::TestSize.Level1)
721{
722    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
723    std::shared_ptr<Options> params = std::make_shared<Options>();
724
725    std::string mode = "localSign";
726    std::string keyAlias = "oh-app1-key-v1";
727    char keyPwd[] = "123456";
728    std::string signCode = "1";
729    std::string appCertFile = "./generateKeyPair/app-release1.pem";
730    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
731    std::string inFile = "OpenHarmonyDamage.p12";
732    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
733    char keystorePwd[] = "123456";
734    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
735
736    (*params)["mode"] = mode;
737    (*params)["keyAlias"] = keyAlias;
738    (*params)["keyPwd"] = keyPwd;
739    (*params)["signCode"] = signCode;
740    (*params)["appCertFile"] = appCertFile;
741    (*params)["profileFile"] = profileFile;
742    (*params)["inFile"] = inFile;
743    (*params)["keystoreFile"] = keystoreFile;
744    (*params)["keystorePwd"] = keystorePwd;
745    (*params)["outFile"] = outFile;
746
747    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
748    EXPECT_EQ(ret, false);
749}
750
751/*
752 * @tc.name: Options_test_030
753 * @tc.desc: sign-app module parameter validation.
754 * @tc.type: FUNC
755 * @tc.require:
756 */
757HWTEST_F(OptionsCmdTest, Options_test_030, testing::ext::TestSize.Level1)
758{
759    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
760    std::shared_ptr<Options> params = std::make_shared<Options>();
761
762    std::string mode = "localSign";
763    std::string keyAlias = "oh-app1-key-v1";
764    char keyPwd[] = "123456";
765    std::string signCode = "1";
766    std::string signAlg = "SHA384withECDSA";
767    std::string appCertFile = "./generateKeyPair/app-release1.pem";
768    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
769    std::string inFile = "OpenHarmonyDamage.p12";
770    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
771    char keystorePwd[] = "123456";
772    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
773
774    (*params)["mode"] = mode;
775    (*params)["keyAlias"] = keyAlias;
776    (*params)["keyPwd"] = keyPwd;
777    (*params)["signCode"] = signCode;
778    (*params)["signAlg"] = signAlg;
779    (*params)["appCertFile"] = appCertFile;
780    (*params)["profileFile"] = profileFile;
781    (*params)["inFile"] = inFile;
782    (*params)["keystoreFile"] = keystoreFile;
783    (*params)["keystorePwd"] = keystorePwd;
784    (*params)["outFile"] = outFile;
785
786    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
787    EXPECT_EQ(ret, false);
788}
789
790/*
791 * @tc.name: Options_test_031
792 * @tc.desc: sign-app module parameter validation.
793 * @tc.type: FUNC
794 * @tc.require:
795 */
796HWTEST_F(OptionsCmdTest, Options_test_031, testing::ext::TestSize.Level1)
797{
798    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
799    std::shared_ptr<Options> params = std::make_shared<Options>();
800
801    std::string mode = "remoteSign";
802    std::string keyAlias = "oh-app1-key-v1";
803    char keyPwd[] = "123456";
804    std::string signCode = "1";
805    std::string signAlg = "SHA384withECDSA";
806    std::string appCertFile = "./generateKeyPair/app-release1.pem";
807    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
808    std::string inFile = "OpenHarmonyDamage.p12";
809    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
810    char keystorePwd[] = "123456";
811    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
812
813    (*params)["mode"] = mode;
814    (*params)["keyAlias"] = keyAlias;
815    (*params)["keyPwd"] = keyPwd;
816    (*params)["signCode"] = signCode;
817    (*params)["signAlg"] = signAlg;
818    (*params)["appCertFile"] = appCertFile;
819    (*params)["profileFile"] = profileFile;
820    (*params)["inFile"] = inFile;
821    (*params)["keystoreFile"] = keystoreFile;
822    (*params)["keystorePwd"] = keystorePwd;
823    (*params)["outFile"] = outFile;
824
825    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
826    EXPECT_EQ(ret, false);
827}
828
829/*
830 * @tc.name: Options_test_032
831 * @tc.desc: sign-app module parameter validation.
832 * @tc.type: FUNC
833 * @tc.require:
834 */
835HWTEST_F(OptionsCmdTest, Options_test_032, testing::ext::TestSize.Level1)
836{
837    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
838    std::shared_ptr<Options> params = std::make_shared<Options>();
839
840    std::string mode = "remoteResign";
841    std::string keyAlias = "oh-app1-key-v1";
842    char keyPwd[] = "123456";
843    std::string signCode = "1";
844    std::string signAlg = "SHA384withECDSA";
845    std::string appCertFile = "./generateKeyPair/app-release1.pem";
846    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
847    std::string inFile = "OpenHarmonyDamage.p12";
848    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
849    char keystorePwd[] = "123456";
850    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
851
852    (*params)["mode"] = mode;
853    (*params)["keyAlias"] = keyAlias;
854    (*params)["keyPwd"] = keyPwd;
855    (*params)["signCode"] = signCode;
856    (*params)["signAlg"] = signAlg;
857    (*params)["appCertFile"] = appCertFile;
858    (*params)["profileFile"] = profileFile;
859    (*params)["inFile"] = inFile;
860    (*params)["keystoreFile"] = keystoreFile;
861    (*params)["keystorePwd"] = keystorePwd;
862    (*params)["outFile"] = outFile;
863
864    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
865    EXPECT_EQ(ret, false);
866}
867
868/*
869* @tc.name: Options_test_033
870* @tc.desc: Checks whether the type is legal.
871* @tc.type: FUNC
872* @tc.require:
873*/
874HWTEST_F(OptionsCmdTest, Options_test_033, testing::ext::TestSize.Level1)
875{
876    std::string str = "clientAuthentication";
877    bool ret = CmdUtil::VerifyType(str);
878
879    EXPECT_EQ(ret, true);
880}
881
882/*
883* @tc.name: Options_test_034
884* @tc.desc: Checks whether the type is legal.
885* @tc.type: FUNC
886* @tc.require:
887*/
888HWTEST_F(OptionsCmdTest, Options_test_034, testing::ext::TestSize.Level1)
889{
890    std::string supportTypes = "abc,cba";
891    std::string inputtype = "abc";
892    bool ret = CmdUtil::VerifyType(inputtype, supportTypes);
893
894    EXPECT_EQ(ret, true);
895}
896
897/*
898* @tc.name: Options_test_035
899* @tc.desc: Checks whether the type is legal.
900* @tc.type: FUNC
901* @tc.require:
902*/
903HWTEST_F(OptionsCmdTest, Options_test_035, testing::ext::TestSize.Level1)
904{
905    std::string supportTypes = "abc,cba";
906    std::string inputtype = "cba";
907    bool ret = CmdUtil::VerifyType(inputtype, supportTypes);
908
909    EXPECT_EQ(ret, true);
910}
911
912/*
913 * @tc.name: Options_test_036
914 * @tc.desc: sign-app module parameter validation.
915 * @tc.type: FUNC
916 * @tc.require:
917 */
918HWTEST_F(OptionsCmdTest, Options_test_036, testing::ext::TestSize.Level1)
919{
920    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
921    std::shared_ptr<Options> params = std::make_shared<Options>();
922
923    std::string mode = "remoteResign";
924    std::string keyAlias = "oh-app1-key-v1";
925    char keyPwd[] = "123456";
926    std::string signCode = "1";
927    std::string signAlg = "SHA384withECDSA";
928    std::string appCertFile = "./generateKeyPair/app-release1.pem";
929    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
930    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
931    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
932    char keystorePwd[] = "123456";
933    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
934
935    (*params)["mode"] = mode;
936    (*params)["keyAlias"] = keyAlias;
937    (*params)["keyPwd"] = keyPwd;
938    (*params)["signCode"] = signCode;
939    (*params)["signAlg"] = signAlg;
940    (*params)["appCertFile"] = appCertFile;
941    (*params)["profileFile"] = profileFile;
942    (*params)["inFile"] = inFile;
943    (*params)["keystoreFile"] = keystoreFile;
944    (*params)["keystorePwd"] = keystorePwd;
945    (*params)["outFile"] = outFile;
946
947    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
948    EXPECT_EQ(ret, false);
949}
950
951/*
952 * @tc.name: Options_test_037
953 * @tc.desc: sign-app module parameter validation.
954 * @tc.type: FUNC
955 * @tc.require:
956 */
957HWTEST_F(OptionsCmdTest, Options_test_037, testing::ext::TestSize.Level1)
958{
959    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
960    std::shared_ptr<Options> params = std::make_shared<Options>();
961
962    std::string mode = "remoteResign";
963    std::string keyAlias = "oh-app1-key-v1";
964    char keyPwd[] = "123456";
965    std::string signCode = "1";
966    std::string appCertFile = "./generateKeyPair/app-release1.pem";
967    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
968    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
969    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
970    char keystorePwd[] = "123456";
971
972    (*params)["mode"] = mode;
973    (*params)["keyAlias"] = keyAlias;
974    (*params)["keyPwd"] = keyPwd;
975    (*params)["signCode"] = signCode;
976    (*params)["appCertFile"] = appCertFile;
977    (*params)["profileFile"] = profileFile;
978    (*params)["inFile"] = inFile;
979    (*params)["keystoreFile"] = keystoreFile;
980    (*params)["keystorePwd"] = keystorePwd;
981
982    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
983    EXPECT_EQ(ret, false);
984}
985
986/*
987 * @tc.name: Options_test_038
988 * @tc.desc: sign-app module parameter validation.
989 * @tc.type: FUNC
990 * @tc.require:
991 */
992HWTEST_F(OptionsCmdTest, Options_test_038, testing::ext::TestSize.Level1)
993{
994    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
995    std::shared_ptr<Options> params = std::make_shared<Options>();
996
997    std::string mode = "remoteResign";
998    std::string keyAlias = "oh-app1-key-v1";
999    char keyPwd[] = "123456";
1000    std::string signCode = "1";
1001    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1002    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
1003    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1004    char keystorePwd[] = "123456";
1005    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1006
1007    (*params)["mode"] = mode;
1008    (*params)["keyAlias"] = keyAlias;
1009    (*params)["keyPwd"] = keyPwd;
1010    (*params)["signCode"] = signCode;
1011    (*params)["appCertFile"] = appCertFile;
1012    (*params)["profileFile"] = profileFile;
1013    (*params)["keystoreFile"] = keystoreFile;
1014    (*params)["keystorePwd"] = keystorePwd;
1015    (*params)["outFile"] = outFile;
1016
1017    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1018    EXPECT_EQ(ret, false);
1019}
1020
1021/*
1022 * @tc.name: Options_test_039
1023 * @tc.desc: sign-app module parameter validation.
1024 * @tc.type: FUNC
1025 * @tc.require:
1026 */
1027HWTEST_F(OptionsCmdTest, Options_test_039, testing::ext::TestSize.Level1)
1028{
1029    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1030    std::shared_ptr<Options> params = std::make_shared<Options>();
1031
1032    std::string mode = "remoteResign";
1033    std::string keyAlias = "oh-app1-key-v1";
1034    char keyPwd[] = "123456";
1035    std::string signCode = "1";
1036    std::string signAlg = "SHA384withECDSA";
1037    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1038    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
1039    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1040    char keystorePwd[] = "123456";
1041
1042    (*params)["mode"] = mode;
1043    (*params)["keyAlias"] = keyAlias;
1044    (*params)["keyPwd"] = keyPwd;
1045    (*params)["signCode"] = signCode;
1046    (*params)["signAlg"] = signAlg;
1047    (*params)["appCertFile"] = appCertFile;
1048    (*params)["profileFile"] = profileFile;
1049    (*params)["keystoreFile"] = keystoreFile;
1050    (*params)["keystorePwd"] = keystorePwd;
1051
1052    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1053    EXPECT_EQ(ret, false);
1054}
1055
1056/*
1057 * @tc.name: Options_test_040
1058 * @tc.desc: sign-app module parameter validation.
1059 * @tc.type: FUNC
1060 * @tc.require:
1061 */
1062HWTEST_F(OptionsCmdTest, Options_test_040, testing::ext::TestSize.Level1)
1063{
1064    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1065    std::shared_ptr<Options> params = std::make_shared<Options>();
1066
1067    std::string keyAlias = "oh-app1-key-v1";
1068    char keyPwd[] = "123456";
1069    std::string signCode = "1";
1070    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1071    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
1072    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1073    char keystorePwd[] = "123456";
1074
1075    (*params)["keyAlias"] = keyAlias;
1076    (*params)["keyPwd"] = keyPwd;
1077    (*params)["signCode"] = signCode;
1078    (*params)["appCertFile"] = appCertFile;
1079    (*params)["profileFile"] = profileFile;
1080    (*params)["keystoreFile"] = keystoreFile;
1081    (*params)["keystorePwd"] = keystorePwd;
1082
1083    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1084    EXPECT_EQ(ret, false);
1085}
1086
1087/*
1088 * @tc.name: Options_test_041
1089 * @tc.desc: sign-app module parameter validation.
1090 * @tc.type: FUNC
1091 * @tc.require:
1092 */
1093HWTEST_F(OptionsCmdTest, Options_test_041, testing::ext::TestSize.Level1)
1094{
1095    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1096    std::shared_ptr<Options> params = std::make_shared<Options>();
1097
1098    std::string mode = "";
1099    std::string keyAlias = "oh-app1-key-v1";
1100    char keyPwd[] = "123456";
1101    std::string signCode = "1";
1102    std::string signAlg = "";
1103    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1104    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
1105    std::string inFile = "";
1106    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1107    char keystorePwd[] = "123456";
1108    std::string outFile = "";
1109
1110    (*params)["mode"] = mode;
1111    (*params)["keyAlias"] = keyAlias;
1112    (*params)["keyPwd"] = keyPwd;
1113    (*params)["signCode"] = signCode;
1114    (*params)["signAlg"] = signAlg;
1115    (*params)["appCertFile"] = appCertFile;
1116    (*params)["profileFile"] = profileFile;
1117    (*params)["inFile"] = inFile;
1118    (*params)["keystoreFile"] = keystoreFile;
1119    (*params)["keystorePwd"] = keystorePwd;
1120    (*params)["outFile"] = outFile;
1121
1122    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1123    EXPECT_EQ(ret, false);
1124}
1125
1126/*
1127 * @tc.name: Options_test_042
1128 * @tc.desc: sign-app module parameter validation.
1129 * @tc.type: FUNC
1130 * @tc.require:
1131 */
1132HWTEST_F(OptionsCmdTest, Options_test_042, testing::ext::TestSize.Level1)
1133{
1134    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1135    std::shared_ptr<Options> params = std::make_shared<Options>();
1136
1137    std::string mode = "remoteResign";
1138    std::string keyAlias = "oh-app1-key-v1";
1139    char keyPwd[] = "123456";
1140    std::string signCode = "1";
1141    std::string signAlg = "SHA384withECDSA";
1142    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1143    std::string profileFile = "./generateKeyPair/signed-profile.p7b";
1144    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1145    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1146    char keystorePwd[] = "123456";
1147    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1148    std::string inForm = "abcd";
1149    std::string profileSigned = "1";
1150
1151    (*params)["mode"] = mode;
1152    (*params)["keyAlias"] = keyAlias;
1153    (*params)["keyPwd"] = keyPwd;
1154    (*params)["signCode"] = signCode;
1155    (*params)["signAlg"] = signAlg;
1156    (*params)["appCertFile"] = appCertFile;
1157    (*params)["profileFile"] = profileFile;
1158    (*params)["inFile"] = inFile;
1159    (*params)["keystoreFile"] = keystoreFile;
1160    (*params)["keystorePwd"] = keystorePwd;
1161    (*params)["outFile"] = outFile;
1162    (*params)["inForm"] = inForm;
1163    (*params)["profileSigned"] = profileSigned;
1164
1165    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1166    EXPECT_EQ(ret, false);
1167}
1168
1169/*
1170 * @tc.name: Options_test_043
1171 * @tc.desc: sign-app module parameter validation.
1172 * @tc.type: FUNC
1173 * @tc.require:
1174 */
1175HWTEST_F(OptionsCmdTest, Options_test_043, testing::ext::TestSize.Level1)
1176{
1177    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1178    std::shared_ptr<Options> params = std::make_shared<Options>();
1179
1180    std::string mode = "remoteResign";
1181    std::string keyAlias = "oh-app1-key-v1";
1182    char keyPwd[] = "123456";
1183    std::string signCode = "1";
1184    std::string signAlg = "SHA384withECDSA";
1185    std::string appCertFile = "./generateKeyPair/app-release1.pem";
1186    std::string profileFile = "./generateKeyPair/profile.json";
1187    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1188    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1189    char keystorePwd[] = "123456";
1190    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1191    std::string inForm = "abcd";
1192    std::string profileSigned = "0";
1193
1194    (*params)["mode"] = mode;
1195    (*params)["keyAlias"] = keyAlias;
1196    (*params)["keyPwd"] = keyPwd;
1197    (*params)["signCode"] = signCode;
1198    (*params)["signAlg"] = signAlg;
1199    (*params)["appCertFile"] = appCertFile;
1200    (*params)["profileFile"] = profileFile;
1201    (*params)["inFile"] = inFile;
1202    (*params)["keystoreFile"] = keystoreFile;
1203    (*params)["keystorePwd"] = keystorePwd;
1204    (*params)["outFile"] = outFile;
1205    (*params)["inForm"] = inForm;
1206    (*params)["profileSigned"] = profileSigned;
1207
1208    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1209    EXPECT_EQ(ret, false);
1210}
1211
1212/*
1213 * @tc.name: Options_test_044
1214 * @tc.desc: generate-app-cert module parameter inspection.
1215 * @tc.type: FUNC
1216 * @tc.require:
1217 */
1218HWTEST_F(OptionsCmdTest, Options_test_044, testing::ext::TestSize.Level1)
1219{
1220    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1221    std::shared_ptr<Options> params = std::make_shared<Options>();
1222
1223    std::string keyAlias = "oh-app1-key-v1";
1224    char keyPwd[] = "123456";
1225    std::string issuer = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Application Signature Service CA";
1226    std::string issuerKeyAlias = "abcd";
1227    std::string subject = "abcd";
1228    std::string signAlg = "SHA256withECDSA";
1229    std::string outForm = "cert";
1230    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1231    char keystorePwd[] = "123456";
1232    std::string outFile = "./generateKeyPair/app1.txt";
1233
1234    (*params)["keyAlias"] = keyAlias;
1235    (*params)["keyPwd"] = keyPwd;
1236    (*params)["issuer"] = issuer;
1237    (*params)["issuerKeyAlias"] = issuerKeyAlias;
1238    (*params)["signAlg"] = signAlg;
1239    (*params)["subject"] = subject;
1240    (*params)["outForm"] = outForm;
1241    (*params)["keystoreFile"] = keystoreFile;
1242    (*params)["keystorePwd"] = keystorePwd;
1243    (*params)["outFile"] = outFile;
1244
1245    bool ret = ParamsRunTool::CheckEndCertArguments(*params);
1246    EXPECT_EQ(ret, false);
1247}
1248
1249/*
1250 * @tc.name: Options_test_045
1251 * @tc.desc: sign-app module parameter validation.
1252 * @tc.type: FUNC
1253 * @tc.require:
1254 */
1255HWTEST_F(OptionsCmdTest, Options_test_045, testing::ext::TestSize.Level1)
1256{
1257    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1258    std::shared_ptr<Options> params = std::make_shared<Options>();
1259
1260    std::string mode = "remoteResign";
1261    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1262    std::string outFile = "./generateKeyPair/test A/abc";
1263    std::string signAlg = "SHA384withECDSA";
1264
1265    (*params)["mode"] = mode;
1266    (*params)["inFile"] = inFile;
1267    (*params)["outFile"] = outFile;
1268    (*params)["signAlg"] = signAlg;
1269
1270    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1271    EXPECT_EQ(ret, false);
1272}
1273
1274/*
1275 * @tc.name: Options_test_046
1276 * @tc.desc: sign-app module parameter validation.
1277 * @tc.type: FUNC
1278 * @tc.require:
1279 */
1280HWTEST_F(OptionsCmdTest, Options_test_046, testing::ext::TestSize.Level1)
1281{
1282    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1283    std::shared_ptr<Options> params = std::make_shared<Options>();
1284
1285    std::string mode = "remoteSign";
1286    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1287    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1288    std::string signAlg = "SHA384withECDSA";
1289
1290    (*params)["mode"] = mode;
1291    (*params)["inFile"] = inFile;
1292    (*params)["outFile"] = outFile;
1293    (*params)["signAlg"] = signAlg;
1294
1295    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1296    EXPECT_EQ(ret, false);
1297}
1298
1299/*
1300 * @tc.name: Options_test_047
1301 * @tc.desc: sign-app module parameter validation.
1302 * @tc.type: FUNC
1303 * @tc.require:
1304 */
1305HWTEST_F(OptionsCmdTest, Options_test_047, testing::ext::TestSize.Level1)
1306{
1307    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1308    std::shared_ptr<Options> params = std::make_shared<Options>();
1309
1310    std::string mode = "abc";
1311    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1312    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1313    std::string signAlg = "SHA384withECDSA";
1314
1315    (*params)["mode"] = mode;
1316    (*params)["inFile"] = inFile;
1317    (*params)["outFile"] = outFile;
1318    (*params)["signAlg"] = signAlg;
1319
1320    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1321    EXPECT_EQ(ret, false);
1322}
1323
1324/*
1325 * @tc.name: Options_test_048
1326 * @tc.desc: sign-app module parameter validation.
1327 * @tc.type: FUNC
1328 * @tc.require:
1329 */
1330HWTEST_F(OptionsCmdTest, Options_test_048, testing::ext::TestSize.Level1)
1331{
1332    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1333    std::shared_ptr<Options> params = std::make_shared<Options>();
1334
1335    std::string mode = "localSign";
1336    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1337    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1338    std::string signAlg = "SHA384withECDSA";
1339
1340    (*params)["mode"] = mode;
1341    (*params)["inFile"] = inFile;
1342    (*params)["outFile"] = outFile;
1343    (*params)["signAlg"] = signAlg;
1344
1345    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1346    EXPECT_EQ(ret, false);
1347}
1348
1349/*
1350 * @tc.name: Options_test_049
1351 * @tc.desc: sign-app module parameter validation.
1352 * @tc.type: FUNC
1353 * @tc.require:
1354 */
1355HWTEST_F(OptionsCmdTest, Options_test_049, testing::ext::TestSize.Level1)
1356{
1357    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1358    std::shared_ptr<Options> params = std::make_shared<Options>();
1359
1360    std::string mode = "localSign";
1361    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1362    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1363    std::string signAlg = "SHA384withECDSA";
1364    std::string keystoreFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1365    std::string keyAlias = "oh-app1-key-v1";
1366    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1367
1368    (*params)["mode"] = mode;
1369    (*params)["inFile"] = inFile;
1370    (*params)["outFile"] = outFile;
1371    (*params)["signAlg"] = signAlg;
1372    (*params)["keystoreFile"] = keystoreFile;
1373    (*params)["keyAlias"] = keyAlias;
1374    (*params)["appCertFile"] = appCertFile;
1375
1376    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1377    EXPECT_EQ(ret, false);
1378}
1379
1380/*
1381 * @tc.name: Options_test_050
1382 * @tc.desc: sign-app module parameter validation.
1383 * @tc.type: FUNC
1384 * @tc.require:
1385 */
1386HWTEST_F(OptionsCmdTest, Options_test_050, testing::ext::TestSize.Level1)
1387{
1388    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1389    std::shared_ptr<Options> params = std::make_shared<Options>();
1390
1391    std::string mode = "localSign";
1392    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1393    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1394    std::string signAlg = "SHA385withECDSA";
1395    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1396    std::string keyAlias = "oh-app1-key-v1";
1397    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1398    std::string profileFile = "./generateKeyPair/profile.json";
1399    std::string inForm = "";
1400
1401    (*params)["mode"] = mode;
1402    (*params)["inFile"] = inFile;
1403    (*params)["outFile"] = outFile;
1404    (*params)["signAlg"] = signAlg;
1405    (*params)["keystoreFile"] = keystoreFile;
1406    (*params)["keyAlias"] = keyAlias;
1407    (*params)["appCertFile"] = appCertFile;
1408    (*params)["profileFile"] = profileFile;
1409    (*params)["inForm"] = inForm;
1410
1411    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1412    EXPECT_EQ(ret, false);
1413}
1414
1415/*
1416 * @tc.name: Options_test_051
1417 * @tc.desc: sign-app module parameter validation.
1418 * @tc.type: FUNC
1419 * @tc.require:
1420 */
1421HWTEST_F(OptionsCmdTest, Options_test_051, testing::ext::TestSize.Level1)
1422{
1423    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1424    std::shared_ptr<Options> params = std::make_shared<Options>();
1425
1426    std::string mode = "localSign";
1427    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1428    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1429    std::string signAlg = "SHA384withECDSA";
1430    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1431    std::string keyAlias = "oh-app1-key-v1";
1432    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1433    std::string inForm = "elf";
1434
1435    (*params)["mode"] = mode;
1436    (*params)["inFile"] = inFile;
1437    (*params)["outFile"] = outFile;
1438    (*params)["signAlg"] = signAlg;
1439    (*params)["keystoreFile"] = keystoreFile;
1440    (*params)["keyAlias"] = keyAlias;
1441    (*params)["appCertFile"] = appCertFile;
1442    (*params)["inForm"] = inForm;
1443
1444    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1445    EXPECT_EQ(ret, false);
1446}
1447
1448/*
1449 * @tc.name: Options_test_052
1450 * @tc.desc: sign-app module parameter validation.
1451 * @tc.type: FUNC
1452 * @tc.require:
1453 */
1454HWTEST_F(OptionsCmdTest, Options_test_052, testing::ext::TestSize.Level1)
1455{
1456    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1457    std::shared_ptr<Options> params = std::make_shared<Options>();
1458
1459    std::string mode = "localSign";
1460    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1461    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1462    std::string signAlg = "SHA384withECDSA";
1463    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1464    std::string keyAlias = "oh-app1-key-v1";
1465    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1466    std::string profileFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1467    std::string profileSigned = "1";
1468
1469    (*params)["mode"] = mode;
1470    (*params)["inFile"] = inFile;
1471    (*params)["outFile"] = outFile;
1472    (*params)["signAlg"] = signAlg;
1473    (*params)["keystoreFile"] = keystoreFile;
1474    (*params)["keyAlias"] = keyAlias;
1475    (*params)["appCertFile"] = appCertFile;
1476    (*params)["profileSigned"] = profileSigned;
1477    (*params)["profileFile"] = profileFile;
1478
1479    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1480    EXPECT_EQ(ret, false);
1481}
1482
1483/*
1484 * @tc.name: Options_test_053
1485 * @tc.desc: sign-app module keystoreFile parameter validation.
1486 * @tc.type: FUNC
1487 * @tc.require:
1488 */
1489HWTEST_F(OptionsCmdTest, Options_test_053, testing::ext::TestSize.Level1)
1490{
1491    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1492    std::shared_ptr<Options> params = std::make_shared<Options>();
1493
1494    std::string mode = "localSign";
1495    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1496    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1497    std::string signAlg = "SHA384withECDSA";
1498    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1499    std::string keyAlias = "oh-app1-key-v1";
1500    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1501    std::string profileFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1502    std::string profileSigned = "1";
1503
1504    (*params)["mode"] = mode;
1505    (*params)["inFile"] = inFile;
1506    (*params)["outFile"] = outFile;
1507    (*params)["signAlg"] = signAlg;
1508    (*params)["keystoreFile"] = keystoreFile;
1509    (*params)["keyAlias"] = keyAlias;
1510    (*params)["appCertFile"] = appCertFile;
1511    (*params)["profileSigned"] = profileSigned;
1512    (*params)["profileFile"] = profileFile;
1513
1514    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1515    EXPECT_EQ(ret, false);
1516}
1517
1518/*
1519 * @tc.name: Options_test_054
1520 * @tc.desc: sign-app module inForm parameter validation.
1521 * @tc.type: FUNC
1522 * @tc.require:
1523 */
1524HWTEST_F(OptionsCmdTest, Options_test_054, testing::ext::TestSize.Level1)
1525{
1526    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1527    std::shared_ptr<Options> params = std::make_shared<Options>();
1528
1529    std::string mode = "localSign";
1530    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1531    std::string outFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1532    std::string signAlg = "SHA384withECDSA";
1533    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1534    std::string keyAlias = "oh-app1-key-v1";
1535    std::string appCertFile = "./generateKeyPair/app-profile.p7b";
1536    std::string profileFile = "./generateKeyPair/app-profile.p7b";
1537    std::string profileSigned = "1";
1538    std::string inForm = "abc";
1539
1540    (*params)["mode"] = mode;
1541    (*params)["inFile"] = inFile;
1542    (*params)["outFile"] = outFile;
1543    (*params)["signAlg"] = signAlg;
1544    (*params)["keystoreFile"] = keystoreFile;
1545    (*params)["keyAlias"] = keyAlias;
1546    (*params)["appCertFile"] = appCertFile;
1547    (*params)["profileSigned"] = profileSigned;
1548    (*params)["profileFile"] = profileFile;
1549    (*params)["inForm"] = inForm;
1550
1551    bool ret = ParamsRunTool::RunSignApp(params.get(), *api);
1552    EXPECT_EQ(ret, false);
1553}
1554
1555/*
1556 * @tc.name: Options_test_055
1557 * @tc.desc: generate-ca module keystoreFile parameter validation.
1558 * @tc.type: FUNC
1559 * @tc.require:
1560 */
1561HWTEST_F(OptionsCmdTest, Options_test_055, testing::ext::TestSize.Level1)
1562{
1563    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1564    std::shared_ptr<Options> params = std::make_shared<Options>();
1565
1566    std::string keyAlias = "oh-root-ca-key-v1";
1567    char keyPwd[] = "123456";
1568    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Root CA";
1569    std::string issuer = "C=CN,O=OpenHarmony_test,OU=OpenHarmony Community,CN= Openharmony Application SUB  CA";
1570    int validity = 365;
1571    std::string signAlg = "SHA384withECDSA";
1572    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1573    char keystorePwd[] = "123456";
1574    std::string outFile = "./generateKeyPair/root-ca1.cer";
1575    std::string keyAlg = "ECC";
1576    int keySize = 384;
1577
1578    (*params)["keyAlias"] = keyAlias;
1579    (*params)["keyPwd"] = keyPwd;
1580    (*params)["subject"] = subject;
1581    (*params)["signAlg"] = signAlg;
1582    (*params)["keystoreFile"] = keystoreFile;
1583    (*params)["keystorePwd"] = keystorePwd;
1584    (*params)["outFile"] = outFile;
1585    (*params)["keyAlg"] = keyAlg;
1586    (*params)["keySize"] = keySize;
1587    (*params)["validity"] = validity;
1588    (*params)["issuer"] = issuer;
1589
1590    bool ret = ParamsRunTool::RunCa(params.get(), *api);
1591    EXPECT_EQ(ret, false);
1592}
1593
1594/*
1595 * @tc.name: Options_test_056
1596 * @tc.desc: generate-cert module keystoreFile parameter validation.
1597 * @tc.type: FUNC
1598 * @tc.require:
1599 */
1600HWTEST_F(OptionsCmdTest, Options_test_056, testing::ext::TestSize.Level1)
1601{
1602    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1603    std::shared_ptr<Options> params = std::make_shared<Options>();
1604
1605    std::string keyAlias = "oh-profile1-key-v1";
1606    std::string issuer = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Application Signature Service CA";
1607    std::string issuerKeyAlias = "oh-profile-sign-srv-ca-key-v1";
1608    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App1 Release";
1609    std::string keyUsage = "digitalSignature";
1610    std::string signAlg = "SHA384withECDSA";
1611    std::string keystoreFile = "./generateKeyPair/abc/OpenHarmonyDamage.p12";
1612    std::string outFile = "./generateKeyPair/general.cer";
1613
1614
1615    (*params)["keyAlias"] = keyAlias;
1616    (*params)["issuer"] = issuer;
1617    (*params)["issuerKeyAlias"] = issuerKeyAlias;
1618    (*params)["subject"] = subject;
1619    (*params)["signAlg"] = signAlg;
1620    (*params)["keystoreFile"] = keystoreFile;
1621    (*params)["outFile"] = outFile;
1622    (*params)["keyUsage"] = keyUsage;
1623
1624    bool ret = ParamsRunTool::RunCert(params.get(), *api);
1625    EXPECT_EQ(ret, false);
1626}
1627
1628/*
1629 * @tc.name: Options_test_057
1630 * @tc.desc: generate-cert module keystoreFile parameter validation.
1631 * @tc.type: FUNC
1632 * @tc.require:
1633 */
1634HWTEST_F(OptionsCmdTest, Options_test_057, testing::ext::TestSize.Level1)
1635{
1636    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1637    std::shared_ptr<Options> params = std::make_shared<Options>();
1638
1639    std::string keyAlias = "oh-profile1-key-v1";
1640    std::string issuer = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Application Signature Service CA";
1641    std::string issuerKeyAlias = "oh-profile-sign-srv-ca-key-v1";
1642    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App1 Release";
1643    std::string keyUsage = "digitalSignature";
1644    std::string signAlg = "SHA384withECDSA";
1645    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1646    std::string outFile = "./generateKeyPair/general.cer";
1647
1648
1649    (*params)["keyAlias"] = keyAlias;
1650    (*params)["issuer"] = issuer;
1651    (*params)["issuerKeyAlias"] = issuerKeyAlias;
1652    (*params)["subject"] = subject;
1653    (*params)["signAlg"] = signAlg;
1654    (*params)["keystoreFile"] = keystoreFile;
1655    (*params)["outFile"] = outFile;
1656    (*params)["keyUsage"] = keyUsage;
1657
1658    bool ret = ParamsRunTool::RunCert(params.get(), *api);
1659    EXPECT_EQ(ret, false);
1660}
1661
1662/*
1663 * @tc.name: Options_test_058
1664 * @tc.desc: generate-app-cert module keystoreFile parameter validation.
1665 * @tc.type: FUNC
1666 * @tc.require:
1667 */
1668HWTEST_F(OptionsCmdTest, Options_test_058, testing::ext::TestSize.Level1)
1669{
1670    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1671    std::shared_ptr<Options> params = std::make_shared<Options>();
1672
1673    std::string keyAlias = "oh-app1-key-v1";
1674    std::string issuer = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Application Signature Service CA";
1675    std::string issuerKeyAlias = "oh-app-sign-srv-ca-key-v1";
1676    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App1 Release";
1677    std::string signAlg = "SHA384withECDSA";
1678    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1679    std::string outFile = "./generateKeyPair/app-release1.pem";
1680
1681    (*params)["keyAlias"] = keyAlias;
1682    (*params)["issuer"] = issuer;
1683    (*params)["issuerKeyAlias"] = issuerKeyAlias;
1684    (*params)["subject"] = subject;
1685    (*params)["signAlg"] = signAlg;
1686    (*params)["keystoreFile"] = keystoreFile;
1687    (*params)["outFile"] = outFile;
1688
1689    bool ret = ParamsRunTool::RunAppCert(params.get(), *api);
1690    EXPECT_EQ(ret, false);
1691}
1692
1693/*
1694 * @tc.name: Options_test_059
1695 * @tc.desc: generate-app-cert module issuerKeystoreFile parameter validation.
1696 * @tc.type: FUNC
1697 * @tc.require:
1698 */
1699HWTEST_F(OptionsCmdTest, Options_test_059, testing::ext::TestSize.Level1)
1700{
1701    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1702    std::shared_ptr<Options> params = std::make_shared<Options>();
1703
1704    std::string keyAlias = "oh-app1-key-v1";
1705    std::string issuer = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=Application Signature Service CA";
1706    std::string issuerKeyAlias = "oh-app-sign-srv-ca-key-v1";
1707    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App1 Release";
1708    std::string signAlg = "SHA384withECDSA";
1709    std::string keystoreFile = "./generateKeyPair/OpenHarmony.p12";
1710    std::string outFile = "./generateKeyPair/app-release1.pem";
1711    std::string issuerKeystoreFile = "./generateKeyPair/app-profile.p7b";
1712
1713    (*params)["keyAlias"] = keyAlias;
1714    (*params)["issuer"] = issuer;
1715    (*params)["issuerKeyAlias"] = issuerKeyAlias;
1716    (*params)["subject"] = subject;
1717    (*params)["signAlg"] = signAlg;
1718    (*params)["keystoreFile"] = keystoreFile;
1719    (*params)["outFile"] = outFile;
1720    (*params)["issuerKeystoreFile"] = issuerKeystoreFile;
1721
1722    bool ret = ParamsRunTool::RunAppCert(params.get(), *api);
1723    EXPECT_EQ(ret, false);
1724}
1725
1726/*
1727 * @tc.name: Options_test_060
1728 * @tc.desc: generate-app-cert module keystoreFile parameter validation.
1729 * @tc.type: FUNC
1730 * @tc.require:
1731 */
1732HWTEST_F(OptionsCmdTest, Options_test_060, testing::ext::TestSize.Level1)
1733{
1734    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1735    std::shared_ptr<Options> params = std::make_shared<Options>();
1736    std::string keystoreFile = "./generateKeyPair/abc/OpenHarmony.p12";
1737    (*params)["keystoreFile"] = keystoreFile;
1738    bool ret = ParamsRunTool::RunAppCert(params.get(), *api);
1739    EXPECT_EQ(ret, false);
1740}
1741
1742/*
1743 * @tc.name: Options_test_061
1744 * @tc.desc: generate-csr module keystoreFile parameter validation.
1745 * @tc.type: FUNC
1746 * @tc.require:
1747 */
1748HWTEST_F(OptionsCmdTest, Options_test_061, testing::ext::TestSize.Level1)
1749{
1750    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1751    std::shared_ptr<Options> params = std::make_shared<Options>();
1752
1753    std::string keyAlias = "oh-app1-key-v1";
1754    std::string subject = "C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App1 Release";
1755    std::string signAlg = "SHA256withECDSA";
1756    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1757    std::string outFile = "./generateKeyPair/oh-app1-key-v1.csr";
1758
1759    (*params)["keyAlias"] = keyAlias;
1760    (*params)["subject"] = subject;
1761    (*params)["signAlg"] = signAlg;
1762    (*params)["keystoreFile"] = keystoreFile;
1763    (*params)["outFile"] = outFile;
1764
1765    bool ret = ParamsRunTool::RunCsr(params.get(), *api);
1766    EXPECT_EQ(ret, false);
1767}
1768
1769/*
1770 * @tc.name: Options_test_062
1771 * @tc.desc: sign-profile module keystoreFile parameter validation.
1772 * @tc.type: FUNC
1773 * @tc.require:
1774 */
1775HWTEST_F(OptionsCmdTest, Options_test_062, testing::ext::TestSize.Level1)
1776{
1777    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1778    std::shared_ptr<Options> params = std::make_shared<Options>();
1779
1780    std::string mode = "localSign";
1781    std::string inFile = "./generateKeyPair/profile.json";
1782    std::string signAlg = "SHA384withECDSA";
1783    std::string outFile = "./generateKeyPair/signed-profile.txt";
1784    std::string keyAlias = "abc";
1785    std::string keystoreFile = "./generateKeyPair/app-profile.p7b";
1786    std::string profileCertFile = "./generateKeyPair/OpenHarmony.p12";
1787
1788    (*params)["mode"] = mode;
1789    (*params)["inFile"] = inFile;
1790    (*params)["signAlg"] = signAlg;
1791    (*params)["outFile"] = outFile;
1792    (*params)["keyAlias"] = keyAlias;
1793    (*params)["keystoreFile"] = keystoreFile;
1794    (*params)["profileCertFile"] = profileCertFile;
1795
1796    bool ret = ParamsRunTool::RunSignProfile(params.get(), *api);
1797    EXPECT_EQ(ret, false);
1798}
1799
1800/*
1801 * @tc.name: Options_test_063
1802 * @tc.desc: verify-profile module inFile parameter validation.
1803 * @tc.type: FUNC
1804 * @tc.require:
1805 */
1806HWTEST_F(OptionsCmdTest, Options_test_063, testing::ext::TestSize.Level1)
1807{
1808    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1809    std::shared_ptr<Options> params = std::make_shared<Options>();
1810
1811    std::string inFile = "./generateKeyPair/OpenHarmony.p12";
1812    std::string outFile = "./generateKeyPair/VerifyResult.json";
1813
1814    (*params)["inFile"] = inFile;
1815    (*params)["outFile"] = outFile;
1816
1817    bool ret = ParamsRunTool::RunVerifyProfile(params.get(), *api);
1818    EXPECT_EQ(ret, false);
1819}
1820
1821/*
1822 * @tc.name: Options_test_064
1823 * @tc.desc: verify-app module inFile parameter validation.
1824 * @tc.type: FUNC
1825 * @tc.require:
1826 */
1827HWTEST_F(OptionsCmdTest, Options_test_064, testing::ext::TestSize.Level1)
1828{
1829    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1830    std::shared_ptr<Options> params = std::make_shared<Options>();
1831
1832    std::string inFile = "./generateKeyPair/OpenHarmonyDamage.p12";
1833    (*params)["inFile"] = inFile;
1834    bool ret = ParamsRunTool::RunVerifyApp(params.get(), *api);
1835    EXPECT_EQ(ret, false);
1836}
1837
1838/*
1839 * @tc.name: Options_test_065
1840 * @tc.desc: verify-profile module inFile parameter validation.
1841 * @tc.type: FUNC
1842 * @tc.require:
1843 */
1844HWTEST_F(OptionsCmdTest, Options_test_065, testing::ext::TestSize.Level1)
1845{
1846    std::unique_ptr<SignToolServiceImpl> api = std::make_unique<SignToolServiceImpl>();
1847    std::shared_ptr<Options> params = std::make_shared<Options>();
1848
1849    std::string inFile = "./generateKeyPair/abc/OpenHarmonyDamage.p12";
1850    std::string outCertChain = "abc";
1851    std::string outProfile = "abc";
1852    (*params)["inFile"] = inFile;
1853    (*params)["outCertChain"] = outCertChain;
1854    (*params)["outProfile"] = outProfile;
1855    bool ret = ParamsRunTool::RunVerifyApp(params.get(), *api);
1856    EXPECT_EQ(ret, false);
1857}
1858
1859
1860/*
1861 * @tc.name: Options_test_066
1862 * @tc.desc: Set the first parameter of the command.
1863 * @tc.type: FUNC
1864 * @tc.require:
1865 */
1866HWTEST_F(OptionsCmdTest, Options_test_066, testing::ext::TestSize.Level1)
1867{
1868    char argv[][100] = { "generate-keypair",
1869                     "-keyAlias", "oh-app1-key-v1",
1870                     "-keyPwd", "123456",
1871                     "-keyAlg", "ECC",
1872                     "-keySize", "NIST-P-384",
1873                     "-keystoreFile", "./generateKeyPair/OpenHarmony.p12",
1874                     "-keystorePwd", "123456"
1875    };
1876
1877    ParamsSharedPtr param = std::make_shared<Params>();
1878    param->SetMethod(argv[1]);
1879    bool ret = true;
1880    EXPECT_EQ(ret, true);
1881}
1882
1883/*
1884 * @tc.name: Options_test_067
1885 * @tc.desc: Remove the white space.
1886 * @tc.type: FUNC
1887 * @tc.require:
1888 */
1889HWTEST_F(OptionsCmdTest, Options_test_067, testing::ext::TestSize.Level1)
1890{
1891    std::string str = "  123456  ";
1892    std::string params = StringUtils::Trim(str);
1893    if (params == "123456") {
1894        bool ret = true;
1895        EXPECT_EQ(ret, true);
1896    } else {
1897        bool ret = false;
1898        EXPECT_EQ(ret, false);
1899    }
1900}
1901
1902/*
1903 * @tc.name: Options_test_068
1904 * @tc.desc: Gets the first command line argument.
1905 * @tc.type: FUNC
1906 * @tc.require:
1907 */
1908HWTEST_F(OptionsCmdTest, Options_test_068, testing::ext::TestSize.Level1)
1909{
1910    char argv[][100] = { "generate-keypair",
1911                     "-keyAlias", "oh-app1-key-v1",
1912                     "-keyPwd", "123456",
1913                     "-keyAlg", "ECC",
1914                     "-keySize", "NIST-P-384",
1915                     "-keystoreFile", "./generateKeyPair/OpenHarmony.p12",
1916                     "-keystorePwd", "123456"
1917    };
1918
1919    ParamsSharedPtr param = std::make_shared<Params>();
1920    param->SetMethod(argv[1]);
1921
1922    if (param->GetMethod().empty()) {
1923        bool ret = false;
1924        EXPECT_EQ(ret, false);
1925    } else {
1926        bool ret = true;
1927        EXPECT_EQ(ret, true);
1928    }
1929}
1930
1931/*
1932 * @tc.name: Options_test_069
1933 * @tc.desc: Gets the first command line argument.
1934 * @tc.type: FUNC
1935 * @tc.require:
1936 */
1937HWTEST_F(OptionsCmdTest, Options_test_069, testing::ext::TestSize.Level1)
1938{
1939    std::string signatureAlgorithm = ParamConstants::HAP_SIG_ALGORITHM_SHA384_ECDSA;
1940    SignatureAlgorithmHelper out;
1941    bool ret = Params::GetSignatureAlgorithm(signatureAlgorithm, out);
1942    EXPECT_EQ(ret, true);
1943}
1944
1945/*
1946 * @tc.name: Options_test_070
1947 * @tc.desc: Gets the first command line argument.
1948 * @tc.type: FUNC
1949 * @tc.require:
1950 */
1951HWTEST_F(OptionsCmdTest, Options_test_070, testing::ext::TestSize.Level1)
1952{
1953    std::string signatureAlgorithm = "123456";
1954    SignatureAlgorithmHelper out;
1955    bool ret = Params::GetSignatureAlgorithm(signatureAlgorithm, out);
1956    EXPECT_EQ(ret, false);
1957}
1958} // namespace SignatureTools
1959} // namespace OHOS