Update test.sh (#1968)

pull/1984/head
Xinwei Xiong 9 months ago committed by GitHub
parent 18f14c9722
commit b511dc7ec4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -34,8 +34,8 @@
#
# The root of the build/dist directory
IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
[[ -z ${COMMON_SOURCED} ]] && source ${IAM_ROOT}/scripts/install/common.sh
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
[[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh
# API Server API Address:Port
INSECURE_OPENIMAPI="http://${OPENIM_API_HOST}:${API_OPENIM_PORT}"
@ -72,7 +72,7 @@ function openim::test::auth() {
# Define a function to get a token for a specific user
openim::test::get_token() {
local user_id="${1:-openIM123456}" # Default user ID if not provided
local user_id="${1:-imAdmin}" # Default user ID if not provided
token_response=$(
${CCURL} "${OperationID}" "${Header}" ${INSECURE_OPENIMAPI}/auth/user_token \
-d'{"secret": "'"$SECRET"'","platformID": 1,"userID": "'$user_id'"}'
@ -142,10 +142,7 @@ openim::test::check_user_account() {
cat <<EOF
{
"checkUserIDs": [
"${1}",
"${MANAGER_USERID_1}",
"${MANAGER_USERID_2}",
"${MANAGER_USERID_3}"
"${1}"
]
}
EOF
@ -182,8 +179,7 @@ openim::test::get_users_info() {
cat <<EOF
{
"userIDs": [
"${1}",
"${MANAGER_USERID_1}"
"${1}"
]
}
EOF
@ -201,10 +197,7 @@ openim::test::get_users_online_status() {
cat <<EOF
{
"userIDs": [
"${TEST_USER_ID}",
"${MANAGER_USERID_1}",
"${MANAGER_USERID_2}",
"${MANAGER_USERID_3}"
"${TEST_USER_ID}"
]
}
EOF
@ -369,7 +362,7 @@ openim::test::get_friend_apply_list() {
local request_body=$(
cat <<EOF
{
"userID": "${MANAGER_USERID_1}",
"userID": "${IM_ADMIN_USERID}",
"pagination": {
"pageNumber": 1,
"showNumber": 100
@ -611,7 +604,7 @@ function openim::test::friend() {
local friend_token="-Htoken: $(openim::test::get_token "${FRIEND_USER_ID}")"
# 3. Respond to a friend request.
# TODO
# openim::test::add_friend_response "${FRIEND_USER_ID}" "${TEST_USER_ID}"
# openim::test::add_friend_response "${FRIEND_USER_ID}" "${TEST_USER_ID}"
Token=$original_token
# 4. Retrieve the friend list of the test user.
@ -619,7 +612,7 @@ function openim::test::friend() {
# 5. Set a remark for a friend.
# TODO
# openim::test::set_friend_remark "${TEST_USER_ID}" "${FRIEND_USER_ID}"
# openim::test::set_friend_remark "${TEST_USER_ID}" "${FRIEND_USER_ID}"
# 6. Retrieve the friend application list for the test user.
openim::test::get_friend_apply_list "${TEST_USER_ID}" 1 100
@ -629,7 +622,7 @@ function openim::test::friend() {
# 8. Delete a friend.
# TODO
# openim::test::delete_friend "${TEST_USER_ID}" "${FRIEND_USER_ID}"
# openim::test::delete_friend "${TEST_USER_ID}" "${FRIEND_USER_ID}"
# 9. Add a user to the blacklist.
openim::test::add_black "${TEST_USER_ID}" "${BLACK_USER_ID}"
@ -1078,6 +1071,7 @@ function openim::test::group() {
local USER_ID=$RANDOM
local OTHER_USER1_ID=$RANDOM
local OTHER_USER2_ID=$RANDOM
local OTHER_USER3_ID=$RANDOM
local TEST_USER_ID=$RANDOM
local GROUP_ID=$RANDOM
@ -1087,12 +1081,13 @@ function openim::test::group() {
openim::test::user_register "${USER_ID}" "group00" "new_face_url"
openim::test::user_register "${OTHER_USER1_ID}" "group01" "new_face_url"
openim::test::user_register "${OTHER_USER2_ID}" "group02" "new_face_url"
openim::test::user_register "${OTHER_USER3_ID}" "group03" "new_face_url"
# 0. Create a new group.
openim::test::create_group "$OTHER_USER2_ID" "$OTHER_USER1_ID" "$USER_ID" "$GROUP_ID"
# 1. Invite user to group.
openim::test::invite_user_to_group "$GROUP_ID" "$MANAGER_USERID_1" "$MANAGER_USERID_2"
openim::test::invite_user_to_group "$GROUP_ID" "$IM_ADMIN_USERID" "$OTHER_USER3_ID"
# 2. Transfer group ownership.
openim::test::transfer_group "$GROUP_ID" "$USER_ID" "$OTHER_USER1_ID"
@ -1101,7 +1096,8 @@ function openim::test::group() {
openim::test::get_groups_info "$GROUP_ID" "$OTHER_USER1_ID"
# 4. Kick a user from the group.
openim::test::kick_group "$GROUP_ID" "$OTHER_USER2_ID"
# TODO
# openim::test::kick_group "$GROUP_ID" "$OTHER_USER2_ID"
# 5. Get group members info.
openim::test::get_group_members_info "$GROUP_ID" "$USER_ID"
@ -1137,7 +1133,8 @@ function openim::test::group() {
openim::test::set_group_info "$GROUP_ID2"
# 15. Quit group.
openim::test::quit_group "$GROUP_ID2" "$OTHER_USER1_ID"
# TODO
# openim::test::quit_group "$GROUP_ID2" "$OTHER_USER1_ID"
# 16. Get received group application list.
openim::test::get_recv_group_applicationList "$USER_ID" 1 100
@ -1196,7 +1193,7 @@ openim::test::register_and_check() {
echo "User registration successful."
# Get token
token=$(openim::get_token)
token=$(openim::test::get_token)
if [[ -n "$token" ]]; then
echo "Token acquired: $token"
@ -1373,7 +1370,7 @@ EOF
# The `openim::test::msg` function serves as a test suite for message-related operations.
# It sequentially invokes all message-related test functions to ensure the API's message operations are functioning correctly.
function openim::test::msg() {
local SEND_USER_ID="${MANAGER_USERID_1}" # This should be the sender's userID
local SEND_USER_ID="${IM_ADMIN_USERID}" # This should be the sender's userID
local GROUP_ID="" # GroupID if it's a group message
local USER_ID="$RANDOM"
openim::test::user_register "${USER_ID}" "msg00" "new_face_url"
@ -1391,7 +1388,7 @@ function openim::test::msg() {
local SHOW_NUMBER=20
echo "Searching for messages between ${SEND_USER_ID} and ${RECV_USER_ID}..."
openim::test::search_msg "${MANAGER_USERID_1}" "${RECV_USER_ID}" "${MSG_TYPE}" "${SEARCH_TIME}" "${SESSION_TYPE}" "${PAGE_NUMBER}" "${SHOW_NUMBER}"
openim::test::search_msg "${IM_ADMIN_USERID}" "${RECV_USER_ID}" "${MSG_TYPE}" "${SEARCH_TIME}" "${SESSION_TYPE}" "${PAGE_NUMBER}" "${SHOW_NUMBER}"
# 3. Pull messages by sequence.
local CONVERSATION_ID="ci_${SEND_USER_ID}_${RECV_USER_ID}" # Adjust as per your conversation ID format

Loading…
Cancel
Save