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 "mock_native_token.h"
17 
18 namespace OHOS {
19 namespace AppExecFwk {
SetNativeToken()20 void MockNativeToken::SetNativeToken()
21 {
22     int permission = 0;
23     int permission1 = 1;
24     int permission2 = 2;
25     int permission3 = 3;
26     int permission4 = 4;
27     int permission5 = 5;
28     uint64_t tokenId;
29     const char** perms = new const char* [6];
30     perms[permission] = "ohos.permission.DISTRIBUTED_DATASYNC";
31     perms[permission1] = "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS";
32     perms[permission2] = "ohos.permission.UPDATE_CONFIGURATION";
33     perms[permission3] = "ohos.permission.GET_RUNNING_INFO";
34     perms[permission4] = "ohos.permission.MANAGE_MISSIONS";
35     perms[permission5] = "ohos.permission.CLEAN_BACKGROUND_PROCESSES";
36     NativeTokenInfoParams infoInstance = {
37         .dcapsNum = 0,
38         .permsNum = 6,
39         .aclsNum = 0,
40         .dcaps = nullptr,
41         .perms = perms,
42         .acls = nullptr,
43         .aplStr = "system_core",
44     };
45 
46     infoInstance.processName = "SetUpTestCase";
47     tokenId = GetAccessTokenId(&infoInstance);
48     SetSelfTokenID(tokenId);
49     delete[] perms;
50 }
51 }  // namespace AppExecFwk
52 }  // namespace OHOS