1 /** 2 * Copyright (c) 2021 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 #ifndef XTS_ACTS_TOKEN_API_EXPECT_H 17 #define XTS_ACTS_TOKEN_API_EXPECT_H 18 19 #include <string> 20 #include <cstdio> 21 #include <cstring> 22 #include <cstdlib> 23 #include <fcntl.h> 24 #include <securec.h> 25 #include <sys/stat.h> 26 #include <sys/types.h> 27 #include <sys/wait.h> 28 #include <unistd.h> 29 #include "feature.h" 30 #include "gtest/gtest.h" 31 #include "iunknown.h" 32 #include "perm_define.h" 33 #include "pms.h" 34 #include "pms_common.h" 35 #include "pms_inner.h" 36 #include "pms_interface.h" 37 #include "perm_operate.h" 38 #include "service.h" 39 #include "samgr_lite.h" 40 41 #define TEST_APP_ID "com.permission.test" 42 #define TEST_APP_ID2 "com.permission.test2" 43 #define SUBTEST_APP_ID "com.permission.subtest" 44 #define TEST_APP_SHORT "a" 45 #define TEST_APP_LONG "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 46 #define TEST_APP_PATH "/storage/app/etc/permissions/com.permission.test" 47 #define TEST_APP_INVALID "com.permission.!@#$%^&*()_+" 48 #define TEST_APP_NOT_EXIST "com.permission.onetwothree" 49 #define PERMISSION_UNDEFINED "ohos.permission.TEST" 50 #define PERMISSION_TOOLONG "ohos.permission.balabalabalabalabalabalabalabalabalabala" 51 #define PERMISSION_EMPTY "" 52 #define PERMISSION_UNSUPPORTED "!@#$%^&*()_+" 53 #define ETC_PREFIX "/storage/app/etc" 54 #define PERMISSION_PREFIX "/storage/app/etc/permissions" 55 56 const int SLEEP_TIME = 5; 57 const int TEST_TASKID = 1000; 58 const int SUBTEST_TASKID = 1001; 59 const int ABNORMAL_TASKID = -1; 60 const int SYS_PERM_NUM = 9; 61 const int ABNORMAL_PERM_NUM = 3; 62 const int MAX_PERM_NUM = 1024; 63 const int RET_OK = 0; 64 const int RET_NOK = -1; 65 const int RELI_TEST_TIME = 1000; 66 const int MAX_PID = 0x7fffffff; 67 const int MIN_PID = 0; 68 const int ABNORMAL_PKG_NUM = 5; 69 const int DIR_MODE = 777; 70 const int FLAG_NOT_EXIST = 123; 71 const int PERFORMANCE_RUN_TIMES = 10000; 72 const int MILLISECOND = 1000; 73 74 int IsUserGrant(const char *pname); 75 76 int CheckPermData(const PermissionTrans *pt, const PermissionSaved *ps, 77 const PermissionSaved *pre, int len, int plen); 78 79 void ClrPers(PermissionSaved *&permissions); 80 81 void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans *installPers, 82 const PermissionSaved *lastPers = nullptr, int lastLen = 0); 83 84 void SubTestWithoutCheck(const char *identifier, int taskID); 85 86 void CreateAppDir(void); 87 88 #endif // XTS_HITS_TOKEN_API_EXPECT_H