mirror of
https://github.com/openharmony/security_security_component_manager.git
synced 2026-08-25 12:39:40 -04:00
Description:modify unit test when enhance is not exist
Match-id-34e2ec72766fe3d407856346a6fc78b39d2c2074
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("../../../../security_component.gni")
|
||||
|
||||
sec_comp_root_dir = "../../../.."
|
||||
|
||||
@@ -36,6 +37,10 @@ ohos_unittest("sec_comp_sdk_test") {
|
||||
configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
if (security_component_enhance_enable) {
|
||||
cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"${sec_comp_root_dir}/frameworks:libsecurity_component_framework",
|
||||
"${sec_comp_root_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk",
|
||||
@@ -68,6 +73,10 @@ ohos_unittest("sec_comp_register_callback_test") {
|
||||
configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
if (security_component_enhance_enable) {
|
||||
cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"${sec_comp_root_dir}/frameworks:libsecurity_component_enhance_adapter",
|
||||
"${sec_comp_root_dir}/frameworks:libsecurity_component_framework",
|
||||
|
||||
@@ -185,7 +185,13 @@ HWTEST_F(SecCompKitTest, RegisterWithoutCallback001, TestSize.Level1)
|
||||
std::string locationInfo = jsonRes.dump();
|
||||
|
||||
int32_t scId;
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
ASSERT_EQ(SC_ENHANCE_ERROR_CALLBACK_NOT_EXIST,
|
||||
SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_EQ(-1, scId);
|
||||
#else
|
||||
ASSERT_EQ(SC_OK,
|
||||
SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_NE(-1, scId);
|
||||
#endif
|
||||
}
|
||||
|
||||
+12
@@ -103,9 +103,15 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterWithoutPreprocess001, TestSize.Lev
|
||||
|
||||
SecCompEnhanceAdapter::InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE);
|
||||
int32_t scId;
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
ASSERT_EQ(SC_ENHANCE_ERROR_CHALLENGE_CHECK_FAIL,
|
||||
SecCompClient::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_EQ(-1, scId);
|
||||
#else
|
||||
ASSERT_EQ(SC_OK,
|
||||
SecCompClient::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_NE(-1, scId);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,9 +150,15 @@ HWTEST_F(SecCompRegisterCallbackTest, Register002, TestSize.Level1)
|
||||
g_probe.mockRes = -1;
|
||||
|
||||
int32_t scId;
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
ASSERT_EQ(SC_ENHANCE_ERROR_CALLBACK_OPER_FAIL,
|
||||
SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_EQ(-1, scId);
|
||||
#else
|
||||
ASSERT_EQ(SC_OK,
|
||||
SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
ASSERT_NE(-1, scId);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,3 +12,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
sec_comp_dir = "//base/security/security_component"
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.security_security_component_enhance)) {
|
||||
security_component_enhance_enable = true
|
||||
} else {
|
||||
security_component_enhance_enable = false
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("../../../../security_component.gni")
|
||||
|
||||
sec_comp_root_dir = "../../../.."
|
||||
|
||||
@@ -56,6 +57,10 @@ ohos_unittest("sec_comp_service_test") {
|
||||
configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
if (security_component_enhance_enable) {
|
||||
cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"${sec_comp_root_dir}/frameworks:libsecurity_component_enhance_adapter",
|
||||
"${sec_comp_root_dir}/frameworks:libsecurity_component_framework",
|
||||
|
||||
@@ -152,5 +152,9 @@ HWTEST_F(SecCompEntityTest, CheckTouchInfo001, TestSize.Level1)
|
||||
entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE;
|
||||
touch.timestamp = static_cast<uint64_t>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT;
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
ASSERT_FALSE(entity_->CheckTouchInfo(touch));
|
||||
#else
|
||||
ASSERT_TRUE(entity_->CheckTouchInfo(touch));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -287,9 +287,14 @@ HWTEST_F(SecCompManagerTest, RegisterSecurityComponent001, TestSize.Level1)
|
||||
LocationButton buttonValid = BuildValidLocationComponent();
|
||||
buttonValid.ToJson(jsonValid);
|
||||
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
// callback check failed
|
||||
ASSERT_EQ(SC_ENHANCE_ERROR_CALLBACK_NOT_EXIST,
|
||||
SecCompManager::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, jsonValid, caller, scId));
|
||||
#else
|
||||
ASSERT_EQ(SC_OK,
|
||||
SecCompManager::GetInstance().RegisterSecurityComponent(LOCATION_COMPONENT, jsonValid, caller, scId));
|
||||
#endif
|
||||
SecCompManager::GetInstance().maliciousAppList_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +258,13 @@ HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent001, TestSize.Leve
|
||||
};
|
||||
secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData);
|
||||
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
EXPECT_EQ(SC_ENHANCE_ERROR_CALLBACK_NOT_EXIST,
|
||||
secCompService_->RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
#else
|
||||
EXPECT_EQ(SC_OK,
|
||||
secCompService_->RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId));
|
||||
#endif
|
||||
uint8_t data[16] = { 0 };
|
||||
struct SecCompClickEvent touch = {
|
||||
.touchX = 100,
|
||||
@@ -269,8 +274,14 @@ HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent001, TestSize.Leve
|
||||
.extraInfo.data = data,
|
||||
.extraInfo.dataSize = 16,
|
||||
};
|
||||
#ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
|
||||
EXPECT_EQ(SC_ENHANCE_ERROR_IN_MALICIOUS_LIST,
|
||||
secCompService_->ReportSecurityComponentClickEvent(scId, locationInfo, touch, nullptr));
|
||||
EXPECT_EQ(SC_SERVICE_ERROR_COMPONENT_NOT_EXIST, secCompService_->UnregisterSecurityComponent(scId));
|
||||
#else
|
||||
EXPECT_EQ(SC_OK,
|
||||
secCompService_->ReportSecurityComponentClickEvent(scId, locationInfo, touch, nullptr));
|
||||
EXPECT_EQ(SC_OK, secCompService_->UnregisterSecurityComponent(scId));
|
||||
#endif
|
||||
setuid(uid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user