mirror of
https://github.com/stoatchat/rust-clamav-client.git
synced 2026-07-01 21:24:06 -04:00
test: write a test for scan buffer tcp
This commit is contained in:
@@ -7,6 +7,7 @@ const TEST_FILE_PATH: &str = "tests/eicar.txt";
|
||||
|
||||
const PONG_RESPONSE: &[u8] = b"PONG\0";
|
||||
const EICAR_FOUND_RESPONSE: &[u8] = b"stream: Eicar-Signature FOUND\0";
|
||||
const EICAR_BUFFER_FOUND_RESPONSE: &[u8] = b"stream: Win.Test.EICAR_HDB-1 FOUND\0";
|
||||
|
||||
#[test]
|
||||
#[cfg(target_family = "unix")]
|
||||
@@ -33,6 +34,7 @@ fn test_scan_socket() {
|
||||
"Could not scan test file {} via socket at {}",
|
||||
TEST_FILE_PATH, TEST_SOCKET_PATH
|
||||
);
|
||||
|
||||
let response = scan_socket(TEST_FILE_PATH, TEST_SOCKET_PATH, None).expect(&err_msg);
|
||||
assert_eq!(&response, EICAR_FOUND_RESPONSE);
|
||||
|
||||
@@ -52,3 +54,21 @@ fn test_scan_tcp() {
|
||||
let is_clean = clean(&response);
|
||||
assert_eq!(is_clean, Ok(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_scan_buffer_tcp() {
|
||||
let err_msg = format!(
|
||||
"Could not scan EICAR string via TCP at {}",
|
||||
TEST_HOST_ADDRESS
|
||||
);
|
||||
|
||||
let buffer = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
|
||||
.bytes()
|
||||
.collect::<Vec<u8>>();
|
||||
|
||||
let response = scan_buffer_tcp(buffer, TEST_HOST_ADDRESS, None).expect(&err_msg);
|
||||
assert_eq!(&response, EICAR_BUFFER_FOUND_RESPONSE);
|
||||
|
||||
let is_clean = clean(&response);
|
||||
assert_eq!(is_clean, Ok(false));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user