ActsPMSTest.h 3.0 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/**
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef XTS_ACTS_TOKEN_API_EXPECT_H
#define XTS_ACTS_TOKEN_API_EXPECT_H

#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <fcntl.h>
#include <securec.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "feature.h"
#include "gtest/gtest.h"
#include "iunknown.h"
#include "perm_define.h"
#include "pms.h"
#include "pms_common.h"
#include "pms_inner.h"
#include "pms_interface.h"
#include "perm_operate.h"
#include "service.h"
#include "samgr_lite.h"

X
xia-liyun 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54
const char TEST_APP_ID[] = "com.permission.test";
const char TEST_APP_ID2[] = "com.permission.test2";
const char SUBTEST_APP_ID[] = "com.permission.subtest";
const char TEST_APP_SHORT[] = "a";
const char TEST_APP_LONG[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const char TEST_APP_PATH[] = "/storage/app/etc/permissions/com.permission.test";
const char TEST_APP_INVALID[] = "com.permission.!@#$%^&*()_+";
const char TEST_APP_NOT_EXIST[] = "com.permission.onetwothree";
const char PERMISSION_UNDEFINED[] = "ohos.permission.TEST";
const char PERMISSION_TOOLONG[] = "ohos.permission.balabalabalabalabalabalabalabalabalabala";
const char PERMISSION_EMPTY[] = "";
const char PERMISSION_UNSUPPORTED[] = "!@#$%^&*()_+";
const char ETC_PREFIX[] = "/storage/app/etc";
const char PERMISSION_PREFIX[] = "/storage/app/etc/permissions";
M
mamingshuai 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

const int SLEEP_TIME = 5;
const int TEST_TASKID = 1000;
const int SUBTEST_TASKID = 1001;
const int ABNORMAL_TASKID = -1;
const int SYS_PERM_NUM = 9;
const int ABNORMAL_PERM_NUM = 3;
const int MAX_PERM_NUM = 1024;
const int RET_OK = 0;
const int RET_NOK = -1;
const int RELI_TEST_TIME = 1000;
const int MAX_PID = 0x7fffffff;
const int MIN_PID = 0;
const int ABNORMAL_PKG_NUM = 5;
const int DIR_MODE = 777;
X
xia-liyun 已提交
70 71 72
const int FLAG_NOT_EXIST = 123;
const int PERFORMANCE_RUN_TIMES = 10000;
const int MILLISECOND = 1000;
M
mamingshuai 已提交
73

X
xia-liyun 已提交
74
int IsUserGrant(const char *pname);
M
mamingshuai 已提交
75

X
xia-liyun 已提交
76 77
int CheckPermData(const PermissionTrans *pt, const PermissionSaved *ps,
                  const PermissionSaved *pre, int len, int plen);
M
mamingshuai 已提交
78

X
xia-liyun 已提交
79
void ClrPers(PermissionSaved *&permissions);
M
mamingshuai 已提交
80

X
xia-liyun 已提交
81 82
void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans *installPers,
                        const PermissionSaved *lastPers = nullptr, int lastLen = 0);
M
mamingshuai 已提交
83 84 85 86 87

void SubTestWithoutCheck(const char *identifier, int taskID);

void CreateAppDir(void);

X
xia-liyun 已提交
88
#endif // XTS_HITS_TOKEN_API_EXPECT_H