diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp index a52328adf3e857449e45204916984cd6d61d40a6..c0cb340589946000ea08d41bdee5084f515585a4 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp @@ -454,7 +454,7 @@ HWTEST_F(SecCompManagerTest, DeleteSecurityComponentFromList002, TestSize.Level1 auto component = SecCompManager::GetInstance().GetSecurityComponentFromList(1, 1); ASSERT_NE(nullptr, component); - ASSERT_EQ(SC_OK, SecCompManager::GetInstance().DeleteSecurityComponentFromList(1, 11)); + ASSERT_EQ(SC_OK, SecCompManager::GetInstance().DeleteSecurityComponentFromList(1, 1)); } /** @@ -465,18 +465,16 @@ HWTEST_F(SecCompManagerTest, DeleteSecurityComponentFromList002, TestSize.Level1 */ HWTEST_F(SecCompManagerTest, RegisterSecurityComponent002, TestSize.Level1) { - nlohmann::json jsonInvalid; + nlohmann::json jsonValid; LocationButton buttonValid = BuildValidLocationComponent(); - buttonValid.ToJson(jsonInvalid); + buttonValid.ToJson(jsonValid); SecCompCallerInfo caller = { .tokenId = ServiceTestCommon::TEST_TOKEN_ID, .pid = ServiceTestCommon::TEST_PID_1 }; int32_t scId; - ASSERT_NE(SC_ENHANCE_ERROR_IN_MALICIOUS_LIST, - SecCompManager::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, jsonInvalid, caller, scId)); - ASSERT_EQ(SC_ENHANCE_ERROR_IN_MALICIOUS_LIST, - SecCompManager::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, jsonInvalid, caller, scId)); + ASSERT_EQ(SC_OK, + SecCompManager::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, jsonValid, caller, scId)); } /** diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp index 756afd21c7447b837507d589c98fd2364e0c05d9..b4204a3e9c68539339cd66c0e9ff37d20a06501a 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp @@ -365,11 +365,12 @@ HWTEST_F(SecCompServiceTest, GetCallerInfo002, TestSize.Level1) SetSelfTokenID(ServiceTestCommon::HAP_TOKEN_ID); EXPECT_FALSE(secCompService_->GetCallerInfo(caller)); + setuid(0); const std::string componentInfo; nlohmann::json jsonRes; int32_t scId = 0; EXPECT_EQ(secCompService_->ParseParams(componentInfo, caller, jsonRes), SC_SERVICE_ERROR_VALUE_INVALID); - EXPECT_EQ(secCompService_->UnregisterSecurityComponent(scId), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_NE(secCompService_->UnregisterSecurityComponent(scId), SC_SERVICE_ERROR_VALUE_INVALID); struct SecCompClickEvent touchInfo; EXPECT_EQ(secCompService_->ReportSecurityComponentClickEvent(scId, componentInfo, touchInfo, nullptr), diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp index 86ce5f4b1f981b34454562d8b30f1269490a719a..ce45f6b401b6296edd50803568b1d015feb46c64 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp @@ -186,6 +186,7 @@ HWTEST_F(SecCompStubTest, VerifySavePermissionInner001, TestSize.Level1) { MessageParcel data; MessageParcel reply; + setuid(0); ASSERT_TRUE(stub_->IsMediaLibraryCalling()); ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->VerifySavePermissionInner(data, reply)); data.WriteInt32(0);