• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "disallow_add_local_account_plugin_test.h"
17 
18 #define private public
19 #define protected public
20 #include "disallow_add_local_account_plugin.h"
21 #undef private
22 #undef protected
23 
24 #include "utils.h"
25 
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace EDM {
30 namespace TEST {
SetUpTestSuite(void)31 void DisallowAddLocalAccountPluginTest::SetUpTestSuite(void)
32 {
33     Utils::SetEdmInitialEnv();
34 }
35 
TearDownTestSuite(void)36 void DisallowAddLocalAccountPluginTest::TearDownTestSuite(void)
37 {
38     Utils::ResetTokenTypeAndUid();
39     ASSERT_TRUE(Utils::IsOriginalUTEnv());
40     std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl;
41 }
42 
43 /**
44  * @tc.name: TestDisallowAddLocalAccountPlugin
45  * @tc.desc: Test DisallowAddLocalAccountPlugin::OnSetPolicy function and remove policy.
46  * @tc.type: FUNC
47  */
48 HWTEST_F(DisallowAddLocalAccountPluginTest, TestDisallowAddLocalAccountPlugin, TestSize.Level1)
49 {
50     DisallowAddLocalAccountPlugin plugin;
51     bool data = true;
52     bool currentdata = false;
53     bool mergeData = false;
54     ErrCode ret = plugin.OnSetPolicy(data, currentdata, mergeData, DEFAULT_USER_ID);
55     ASSERT_TRUE(ret == ERR_OK && data);
56 
57     string adminName{"testAdminName"};
58     bool allowAddLocalAccount = true;
59     ret = plugin.OnAdminRemove(adminName, allowAddLocalAccount, mergeData, DEFAULT_USER_ID);
60     ASSERT_TRUE(ret == ERR_OK);
61 }
62 } // namespace TEST
63 } // namespace EDM
64 } // namespace OHOS