diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index 800e197e0555da7a3485423dbc5c0db1d0546bfd..a90917a03143cfec15bb18db4437842dd5a590e2 100644 --- a/frameworks/ans/test/unittest/notification_helper_test.cpp +++ b/frameworks/ans/test/unittest/notification_helper_test.cpp @@ -48,7 +48,7 @@ HWTEST_F(NotificationHelperTest, AddNotificationSlot_00001, Function | SmallTest NotificationSlot slot; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.AddNotificationSlot(slot); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -249,7 +249,7 @@ HWTEST_F(NotificationHelperTest, CancelAsBundle_00001, Function | SmallTest | Le int32_t userId = 10; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_UID); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -390,7 +390,7 @@ HWTEST_F(NotificationHelperTest, IsAllowedNotify_00001, Function | SmallTest | L bool allowed = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsAllowedNotify(allowed); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -476,7 +476,7 @@ HWTEST_F(NotificationHelperTest, RemoveNotification_00001, Function | SmallTest int32_t removeReason = 2; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.RemoveNotification(key, removeReason); - EXPECT_EQ(ret, (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -534,7 +534,7 @@ HWTEST_F(NotificationHelperTest, RemoveNotifications_00001, Function | SmallTest { NotificationHelper notificationHelper; ErrCode ret = notificationHelper.RemoveNotifications(); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -578,7 +578,7 @@ HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00001, Function | Sma std::vector> notification; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetAllActiveNotifications(notification); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -623,7 +623,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(deviceId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -725,7 +725,7 @@ HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00001, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -739,7 +739,7 @@ HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00001, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -753,7 +753,7 @@ HWTEST_F(NotificationHelperTest, DoesSupportDoNotDisturbMode_00001, Function | S bool doesSupport = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -781,7 +781,7 @@ HWTEST_F(NotificationHelperTest, EnableDistributed_00001, Function | SmallTest | bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.EnableDistributed(enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -796,7 +796,7 @@ HWTEST_F(NotificationHelperTest, EnableDistributedByBundle_00001, Function | Sma bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.EnableDistributedByBundle(bundleOption, enabled); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -825,7 +825,7 @@ HWTEST_F(NotificationHelperTest, IsDistributedEnableByBundle_00001, Function | S bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -839,7 +839,7 @@ HWTEST_F(NotificationHelperTest, GetDeviceRemindType_00001, Function | SmallTest NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDeviceRemindType(remindType); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -868,7 +868,7 @@ HWTEST_F(NotificationHelperTest, CancelContinuousTaskNotification_00001, Functio int32_t notificationId = 10; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.CancelContinuousTaskNotification(label, notificationId); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_NOT_SYSTEM_SERVICE); } /** @@ -898,7 +898,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00002, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -928,7 +928,7 @@ HWTEST_F(NotificationHelperTest, IsAllowedNotify_00004, Function | SmallTest | L bool allowed = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsAllowedNotify(userId, allowed); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -943,7 +943,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00003, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -972,7 +972,7 @@ HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00002, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -987,7 +987,7 @@ HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00002, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -1034,7 +1034,7 @@ HWTEST_F(NotificationHelperTest, SetSyncNotificationEnabledWithoutApp_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -1049,7 +1049,7 @@ HWTEST_F(NotificationHelperTest, GetSyncNotificationEnabledWithoutApp_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } } } \ No newline at end of file diff --git a/frameworks/ans/test/unittest/reminder_helper_test.cpp b/frameworks/ans/test/unittest/reminder_helper_test.cpp index 549c42cb19ba10c8f40270fec63cb847aa76fcc1..22b93e4432ac814983218ce76f58d86d3c9721b7 100644 --- a/frameworks/ans/test/unittest/reminder_helper_test.cpp +++ b/frameworks/ans/test/unittest/reminder_helper_test.cpp @@ -101,7 +101,7 @@ HWTEST_F(ReminderHelperTest, AddNotificationSlot_00001, Function | SmallTest | L NotificationSlot slot; ReminderHelper reminderHelper; ErrCode ret = reminderHelper.AddNotificationSlot(slot); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** diff --git a/services/ans/src/access_token_helper.cpp b/services/ans/src/access_token_helper.cpp index 56c226c69dcd675a042caa05255a4efd49871cf1..ed32d526425d2e6546d1c4a474a3a27b2de3f8c9 100644 --- a/services/ans/src/access_token_helper.cpp +++ b/services/ans/src/access_token_helper.cpp @@ -32,7 +32,7 @@ bool AccessTokenHelper::VerifyCallerPermission( bool AccessTokenHelper::VerifyNativeToken(const AccessTokenID &callerToken) { ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken); - return (tokenType == ATokenTypeEnum::TOKEN_NATIVE || tokenType == ATokenTypeEnum::TOKEN_SHELL); + return (tokenType == ATokenTypeEnum::TOKEN_NATIVE); } bool AccessTokenHelper::IsSystemHap()