1 /*
2 * Copyright (c) 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 #include "password_policy_plugin_test.h"
16 #include "password_policy_serializer.h"
17 #include "utils.h"
18
19 using namespace testing::ext;
20
21 namespace OHOS {
22 namespace EDM {
23 namespace TEST {
24 const std::string TEST_POLICY_DATA = "{\"complexityReg\":\"^(?=.*[a-zA-Z]).{1,9}$\", \"validityPeriod\": 2,"
25 "\"additionalDescription\": \"testDescription\"}";
26 const std::string TEST_POLICY_ERR_DATA = "{\"comple\":\"^(?=.*[a-zA-Z]).{1,9}$\", \"validityPeriod\": 2,"
27 "\"additionalDescription\": \"testDescription\"}";
28 const std::string TEST_VALUE_COMPLEXITYREG = "^(?=.*[a-zA-Z]).{1,9}$";
29 const std::string TEST_VALUE_ADDITIONAL_DESCRIPTION = "testDescription";
SetUpTestSuite(void)30 void PasswordPolicyPluginTest::SetUpTestSuite(void)
31 {
32 Utils::SetEdmInitialEnv();
33 }
34
TearDownTestSuite(void)35 void PasswordPolicyPluginTest::TearDownTestSuite(void)
36 {
37 Utils::ResetTokenTypeAndUid();
38 ASSERT_TRUE(Utils::IsOriginalUTEnv());
39 std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl;
40 }
41
42 /**
43 * @tc.name: TestOnSetPolicyEmpty
44 * @tc.desc: Test PasswordPolicyPlugin::OnSetPolicy
45 * @tc.type: FUNC
46 */
47 HWTEST_F(PasswordPolicyPluginTest, TestOnSetPolicy, TestSize.Level1)
48 {
49 PasswordPolicyPlugin plugin;
50 PasswordPolicy policy;
51 PasswordPolicy currentData;
52 PasswordPolicy mergeData;
53 ErrCode ret = plugin.OnSetPolicy(policy, currentData, mergeData, DEFAULT_USER_ID);
54 ASSERT_TRUE(ret == ERR_OK);
55 }
56 } // namespace TEST
57 } // namespace EDM
58 } // namespace OHOS