From 73794df9a1833709fdf203c6815d645a16255c6a Mon Sep 17 00:00:00 2001 From: thevindu-w Date: Sun, 28 Jul 2024 22:49:25 +0530 Subject: [PATCH] Add test for conf method enabled --- tests/config/clipshare.conf | 11 +++- tests/run.sh | 3 +- tests/scripts/3.6_get_image_v3.sh | 2 +- tests/scripts/conf_method_enabled.sh | 87 ++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100755 tests/scripts/conf_method_enabled.sh diff --git a/tests/config/clipshare.conf b/tests/config/clipshare.conf index 1094040..4b3a227 100644 --- a/tests/config/clipshare.conf +++ b/tests/config/clipshare.conf @@ -18,4 +18,13 @@ bind_address = 127.0.0.1 client_selects_display=true # min_proto_version=2 -# max_proto_version=3 \ No newline at end of file +# max_proto_version=3 + +# method_get_text_enabled=false +# method_send_text_enabled=false +# method_get_files_enabled=false +# method_send_files_enabled=false +# method_get_image_enabled=false +# method_get_copied_image_enabled=false +# method_get_screenshot_enabled=false +# method_info_enabled=false \ No newline at end of file diff --git a/tests/run.sh b/tests/run.sh index 3b77196..418432d 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -296,8 +296,9 @@ export METHOD_SEND_TEXT=$(printf '\x02' | bin2hex) export METHOD_GET_FILES=$(printf '\x03' | bin2hex) export METHOD_SEND_FILES=$(printf '\x04' | bin2hex) export METHOD_GET_IMAGE=$(printf '\x05' | bin2hex) -export METHOD_GET_IMAGE_ONLY=$(printf '\x06' | bin2hex) +export METHOD_GET_COPIED_IMAGE=$(printf '\x06' | bin2hex) export METHOD_GET_SCREENSHOT=$(printf '\x07' | bin2hex) +export METHOD_INFO=$(printf '\x7d' | bin2hex) # Proto ack export PROTO_SUPPORTED=$(printf '\x01' | bin2hex) diff --git a/tests/scripts/3.6_get_image_v3.sh b/tests/scripts/3.6_get_image_v3.sh index c2b65cf..b400e2c 100755 --- a/tests/scripts/3.6_get_image_v3.sh +++ b/tests/scripts/3.6_get_image_v3.sh @@ -1,6 +1,6 @@ #!/bin/bash proto="$PROTO_V3" -method="$METHOD_GET_IMAGE_ONLY" +method="$METHOD_GET_COPIED_IMAGE" . scripts/common/get_image.sh diff --git a/tests/scripts/conf_method_enabled.sh b/tests/scripts/conf_method_enabled.sh new file mode 100755 index 0000000..2d9f0d7 --- /dev/null +++ b/tests/scripts/conf_method_enabled.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +. init.sh + +check_method() { + payload="$1" + status="$2" + responseDump=$(echo -n "${PROTO_MAX_VERSION}${payload}" | hex2bin | client_tool) + expected="${PROTO_SUPPORTED}${status}" + if [ "${responseDump::4}" != "$expected" ]; then + showStatus info 'Incorrect server response.' + echo 'Expected:' "$expected" + echo 'Received:' "$responseDump" + exit 1 + fi +} + +GET_TEXT_STATUS="$METHOD_NO_DATA" +GET_FILES_STATUS="$METHOD_NO_DATA" +GET_IMAGE_STATUS="$METHOD_OK" +GET_COPIED_IMAGE_STATUS="$METHOD_NO_DATA" +GET_SCREENSHOT_STATUS="$METHOD_OK" +SEND_TEXT_STATUS="$METHOD_OK" +SEND_FILES_STATUS="$METHOD_OK" +INFO_STATUS="$METHOD_OK" + +TEXT="0000000000000000" +FILE_CNT="0000000000000000" + +check_all_methods() { + check_method "$METHOD_GET_TEXT" "$GET_TEXT_STATUS" + check_method "$METHOD_GET_FILES" "$GET_FILES_STATUS" + check_method "$METHOD_GET_IMAGE" "$GET_IMAGE_STATUS" + check_method "$METHOD_GET_COPIED_IMAGE" "$GET_COPIED_IMAGE_STATUS" + check_method "$METHOD_GET_SCREENSHOT" "$GET_SCREENSHOT_STATUS" + check_method "${METHOD_SEND_TEXT}${TEXT}" "$SEND_TEXT_STATUS" + check_method "${METHOD_SEND_FILES}${FILE_CNT}" "$SEND_FILES_STATUS" + check_method "$METHOD_INFO" "$INFO_STATUS" +} + +clear_clipboard + +check_all_methods + +update_config method_get_text_enabled false +clear_clipboard + +GET_TEXT_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_get_files_enabled false +clear_clipboard + +GET_FILES_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_get_image_enabled false + +GET_IMAGE_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_get_copied_image_enabled false + +GET_COPIED_IMAGE_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_get_screenshot_enabled false + +GET_SCREENSHOT_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_send_text_enabled false + +TEXT='' +SEND_TEXT_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_send_files_enabled false + +FILE_CNT='' +SEND_FILES_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods + +update_config method_info_enabled false + +INFO_STATUS="$METHOD_NOT_IMPLEMENTED" +check_all_methods