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 "access_token_helper.h" 17 18 namespace { 19 bool g_mockVerifyNativeTokenRet = true; 20 bool g_mockVerifyCallerPermissionRet = true; 21 bool g_mockVerifyShellTokenRet = true; 22 } 23 MockVerifyNativeToken(bool mockRet)24void MockVerifyNativeToken(bool mockRet) 25 { 26 g_mockVerifyNativeTokenRet = mockRet; 27 } 28 MockVerifyCallerPermission(bool mockRet)29void MockVerifyCallerPermission(bool mockRet) 30 { 31 g_mockVerifyCallerPermissionRet = mockRet; 32 } 33 MockVerifyShellToken(bool mockRet)34void MockVerifyShellToken(bool mockRet) 35 { 36 g_mockVerifyShellTokenRet = mockRet; 37 } 38 39 using namespace OHOS::Security::AccessToken; 40 41 namespace OHOS { 42 namespace Notification { VerifyNativeToken(const AccessTokenID & callerToken)43bool AccessTokenHelper::VerifyNativeToken(const AccessTokenID &callerToken) 44 { 45 return g_mockVerifyNativeTokenRet; 46 } 47 VerifyCallerPermission(const AccessTokenID & tokenCaller,const std::string & permission)48bool AccessTokenHelper::VerifyCallerPermission( 49 const AccessTokenID &tokenCaller, const std::string &permission) 50 { 51 return g_mockVerifyCallerPermissionRet; 52 } 53 VerifyShellToken(const AccessTokenID & callerToken)54bool AccessTokenHelper::VerifyShellToken(const AccessTokenID &callerToken) 55 { 56 return g_mockVerifyShellTokenRet; 57 } 58 } // namespace Notification 59 } // namespace OHOS