Skip to content

Commit

Permalink
Add test for conf method enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thevindu-w committed Jul 28, 2024
1 parent 2362957 commit 73794df
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
11 changes: 10 additions & 1 deletion tests/config/clipshare.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ bind_address = 127.0.0.1
client_selects_display=true

# min_proto_version=2
# max_proto_version=3
# 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
3 changes: 2 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/3.6_get_image_v3.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

proto="$PROTO_V3"
method="$METHOD_GET_IMAGE_ONLY"
method="$METHOD_GET_COPIED_IMAGE"

. scripts/common/get_image.sh
87 changes: 87 additions & 0 deletions tests/scripts/conf_method_enabled.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 73794df

Please sign in to comment.