Return detected handle when remove failed 51/75051/2
authorKyungwook Tak <k.tak@samsung.com>
Thu, 16 Jun 2016 10:08:40 +0000 (19:08 +0900)
committerkyungwook tak <k.tak@samsung.com>
Thu, 16 Jun 2016 10:51:14 +0000 (03:51 -0700)
Change-Id: Ie8c8f5adec67769336a55532940c9014770214fb
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
packaging/csr-framework.spec
src/framework/service/cs-logic.cpp
test/resources/test_dir/dir1/unremovable_file [new file with mode: 0644]
test/test-api-content-screening.cpp
test/test-resource.h

index a226df5..9f156d5 100644 (file)
@@ -204,7 +204,6 @@ cp LICENSE %{buildroot}%{ro_data_dir}/license/lib%{name}-common
 cp LICENSE %{buildroot}%{ro_data_dir}/license/%{name}-test
 cp LICENSE.BSL-1.0 %{buildroot}%{ro_data_dir}/license/%{name}-test.BSL-1.0
 
-
 mkdir -p %{buildroot}%{rw_db_dir}
 mkdir -p %{buildroot}%{ro_db_dir}
 cp data/scripts/*.sql %{buildroot}%{ro_db_dir}
@@ -249,6 +248,9 @@ fi
 %postun -n lib%{name}-common -p %{sbin_dir}/ldconfig
 %postun -n lib%{name}-client -p %{sbin_dir}/ldconfig
 
+%post -n %{name}-test
+chsmack -a "_" %{test_dir}/test_dir/dir1
+
 %files
 %defattr(-,root,root,-)
 %manifest %{service_name}.manifest
index bd38f22..785653f 100644 (file)
@@ -758,6 +758,8 @@ RawBuffer CsLogic::handleAskUser(const CsContext &c, CsDetected &d, FilePtr &&fi
                        else if (e.error() == CSR_ERROR_FILE_SYSTEM)
                                WARN("File type is changed, considered as different file: " <<
                                         d.targetName);
+                       else if (e.error() == CSR_ERROR_REMOVE_FAILED)
+                               return BinaryQueue::Serialize(CSR_ERROR_REMOVE_FAILED, d).pop();
                        else
                                throw;
                }
diff --git a/test/resources/test_dir/dir1/unremovable_file b/test/resources/test_dir/dir1/unremovable_file
new file mode 100644 (file)
index 0000000..704cac8
--- /dev/null
@@ -0,0 +1 @@
+X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
index 2bd9a3a..d2c29e2 100644 (file)
@@ -1294,4 +1294,29 @@ BOOST_AUTO_TEST_CASE(get_ignored_malwares_after_file_changed)
        EXCEPTION_GUARD_END
 }
 
+// TODO: below test case needs response from UI. It'll be turned on as default after
+// write code of popup service stub
+#if 0
+BOOST_AUTO_TEST_CASE(remove_failed_returns_detected_handle)
+{
+       EXCEPTION_GUARD_START
+
+       auto start_time = ::time(nullptr);
+
+       auto c = Test::Context<csr_cs_context_h>();
+       auto context = c.get();
+
+       csr_cs_malware_h malware = nullptr;
+
+       ASSERT_SUCCESS(csr_cs_set_ask_user(context, CSR_CS_ASK_USER_YES));
+       ASSERT_IF(csr_cs_scan_file(context, TEST_FILE_UNREMOVABLE, &malware), CSR_ERROR_REMOVE_FAILED);
+       CHECK_IS_NOT_NULL(malware);
+       ASSERT_DETECTED(malware, MALWARE_HIGH_NAME, MALWARE_HIGH_SEVERITY,
+                                       MALWARE_HIGH_DETAILED_URL);
+       ASSERT_DETECTED_EXT(malware, start_time, TEST_FILE_UNREMOVABLE, false, "");
+
+       EXCEPTION_GUARD_END
+}
+#endif
+
 BOOST_AUTO_TEST_SUITE_END()
index 38b9710..4ebb54d 100644 (file)
@@ -39,6 +39,7 @@ const char *TEST_FILE_MEDIA();
 #define TEST_FILE_TMP_IN_DIR_MALWARES TEST_DIR_MALWARES "/tmp_malware_file"
 #define TEST_FILE_TMP                 TEST_DIR_TMP "/test_malware_file"
 #define TEST_FILE_NO_EXIST            TEST_DIR_TMP "/not_existing_file"
+#define TEST_FILE_UNREMOVABLE         TEST_DIR_MALWARES "/dir1/unremovable_file"
 
 #define TEST_WGT_PKG_ID    "hFhcNcbE6K"
 #define TEST_WGT_TYPE      "wgt"