mirror of
https://gitee.com/openharmony/xts_dcts
synced 2024-11-27 01:40:46 +00:00
!641 【distributedhardware】【master】分布式Dp用例添加权限
Merge pull request !641 from bjliang/master
This commit is contained in:
commit
b968b0f1b5
@ -40,6 +40,9 @@ ohos_moduletest_suite("SubDctsDistributedDpTest") {
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/common/include/interfaces",
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/common/include/utils",
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/radar/include",
|
||||
"$base_root/base/security/access_token/interfaces/innerkits/accesstoke/include",
|
||||
"$base_root/base/security/access_token/interfaces/innerkits/nativetoken/include",
|
||||
"$base_root/base/security/access_token/interfaces/innerkits/token_setproc/include",
|
||||
]
|
||||
|
||||
sources = [ "device_profile_test.cpp" ]
|
||||
@ -56,6 +59,8 @@ ohos_moduletest_suite("SubDctsDistributedDpTest") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$base_root/base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
|
||||
"$base_root/base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/common:distributed_device_profile_common",
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/interfaces/innerkits/core:distributed_device_profile_sdk",
|
||||
"$base_root/foundation/deviceprofile/device_info_manager/services/core:distributed_device_profile_svr",
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include "device_profile_manager.h"
|
||||
#include "kv_adapter.h"
|
||||
#include "profile_cache.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "token_setproc.h"
|
||||
#undef PRIVATE
|
||||
#undef PROTECTED
|
||||
|
||||
@ -42,6 +45,28 @@ namespace DistributedDeviceProfile {
|
||||
using namespace testing::ext;
|
||||
using namespace std;
|
||||
|
||||
void AddPermission(void)
|
||||
{
|
||||
const int32_t PERMS_NUM = 2;
|
||||
const char *perms[PERMS_NUM] = {
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC",
|
||||
"ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"
|
||||
};
|
||||
uint64_t tokenId;
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = PERMS_NUM,
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = perms,
|
||||
.acls = nullptr,
|
||||
.processName = "deviceprofile",
|
||||
.aplStr = "system_core",
|
||||
};
|
||||
tokenId = GetAccessTokenId(&infoInstance);
|
||||
SetSelfTokenID(tokenId);
|
||||
}
|
||||
|
||||
class DeviceProfileManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
@ -50,7 +75,12 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void DeviceProfileManagerTest::SetUpTestCase(void) {
|
||||
void DeviceProfileManagerTest::SetUpTestCase(void)
|
||||
{
|
||||
AddPermission();
|
||||
sleep(1);
|
||||
system("pidof accesstoken_service | xargs kill -9");
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
void DeviceProfileManagerTest::TearDownTestCase(void) {
|
||||
@ -858,4 +888,4 @@ HWTEST_F(DeviceProfileManagerTest, SUB_DH_DDp_Dcts_3900, TestSize.Level1)
|
||||
EXPECT_EQ(errCode, DP_INVALID_PARAMS);
|
||||
}
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user