feat: use scripts format code

pull/1799/head
Xinwei Xiong (cubxxw) 2 years ago
parent 0b59a2205b
commit bb65e1bfac

@ -148,7 +148,7 @@ if ${require_docker}; then
fi fi
OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true) OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true)
OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:"${OPENIM_ROOT}":${OPENIM_GIT_BRANCH}") OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:${OPENIM_ROOT}:${OPENIM_GIT_BRANCH}")
OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}" OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}"
#OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}" #OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
#OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}" #OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"

@ -18,9 +18,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
version="${VERSION}" version="${VERSION}"
if [ "${version}" == "" ];then if [ "${version}" == "" ];then
version=v`${OPENIM_ROOT}/_output/tools/gsemver bump` version=v$(${OPENIM_ROOT}/_output/tools/gsemver bump)
fi fi
if [ -z "`git tag -l ${version}`" ];then if [ -z "$(git tag -l ${version})" ];then
git tag -a -m "release version ${version}" ${version} git tag -a -m "release version ${version}" ${version}
fi fi

@ -67,7 +67,7 @@ echo -e "=== any\nRepresents an untyped JSON map - see the description of the fi
asciidoctor definitions.adoc asciidoctor definitions.adoc
asciidoctor paths.adoc asciidoctor paths.adoc
cp ${OPENIM_OUTPUT_TMP}/definitions.html ${OPENIM_OUTPUT_TMP}/_output/ cp "$OPENIM_OUTPUT_TMP/definitions.html" "$OPENIM_OUTPUT_TMP/_output/"
cp ${OPENIM_OUTPUT_TMP}/paths.html ${OPENIM_OUTPUT_TMP}/_output/operations.html cp "$OPENIM_OUTPUT_TMP/paths.html" "$OPENIM_OUTPUT_TMP/_output/operations.html"
success "SUCCESS" success "SUCCESS"

@ -47,7 +47,7 @@ do
done done
if [ "${missing}" ];then if [ "${missing}" ];then
openim::log::error 'You may run `source scripts/environment.sh` to set these environment' openim::log::error "You may run 'source scripts/environment.sh' to set these environment"
exit 1 exit 1
fi fi

@ -38,7 +38,7 @@ printError() {
printMessage "Running local OpenIM pre-push hook." printMessage "Running local OpenIM pre-push hook."
if [[ `git status --porcelain` ]]; then if [[ $(git status --porcelain) ]]; then
printError "This scripts needs to run against committed code only. Please commit or stash you changes." printError "This scripts needs to run against committed code only. Please commit or stash you changes."
exit 1 exit 1
fi fi

@ -50,7 +50,7 @@ help_info() {
} }
delete_hooks() { delete_hooks() {
for file in ${OPENIM_ROOT}/scripts/githooks/*.sh; do for file in "${OPENIM_ROOT}"/scripts/githooks/*.sh; do
hook_name=$(basename "$file" .sh) # This removes the .sh extension hook_name=$(basename "$file" .sh) # This removes the .sh extension
rm -f "$HOOKS_DIR/$hook_name" rm -f "$HOOKS_DIR/$hook_name"
done done

@ -73,20 +73,22 @@ function openim::test::auth() {
# Define a function to get a token for a specific user # Define a function to get a token for a specific user
openim::test::get_token() { openim::test::get_token() {
local user_id="${1:-openIM123456}" # Default user ID if not provided local user_id="${1:-openIM123456}" # Default user ID if not provided
token_response=$(${CCURL} "${OperationID}" "${Header}" ${INSECURE_OPENIMAPI}/auth/user_token \ token_response=$(
-d'{"secret": "'"$SECRET"'","platformID": 1,"userID": "'$user_id'"}') ${CCURL} "${OperationID}" "${Header}" ${INSECURE_OPENIMAPI}/auth/user_token \
-d'{"secret": "'"$SECRET"'","platformID": 1,"userID": "'$user_id'"}'
)
token=$(echo $token_response | grep -Po 'token[" :]+\K[^"]+') token=$(echo $token_response | grep -Po 'token[" :]+\K[^"]+')
echo "$token" echo "$token"
} }
Header="-HContent-Type: application/json" Header="-HContent-Type: application/json"
OperationID="-HoperationID: 1646445464564" OperationID="-HoperationID: 1646445464564"
Token="-Htoken: $(openim::test::get_token)" Token="-Htoken: $(openim::test::get_token)"
# Forces a user to log out from the specified platform by user ID. # Forces a user to log out from the specified platform by user ID.
openim::test::force_logout() { openim::test::force_logout() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"platformID": 2, "platformID": 2,
"userID": "4950983283" "userID": "4950983283"
@ -100,7 +102,6 @@ local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OP
openim::test::check_error "$response" openim::test::check_error "$response"
} }
#################################### User Module #################################### #################################### User Module ####################################
# Registers a new user with provided user ID, nickname, and face URL using the API. # Registers a new user with provided user ID, nickname, and face URL using the API.
@ -111,7 +112,8 @@ local nickname="${2:-cubxxw}"
local face_url="${3:-https://github.com/cubxxw}" local face_url="${3:-https://github.com/cubxxw}"
# Create the request body using the provided or default values # Create the request body using the provided or default values
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"secret": "${SECRET}", "secret": "${SECRET}",
"users": [ "users": [
@ -136,7 +138,8 @@ openim::test::check_error "$user_register_response"
# Checks if the provided list of user IDs exist in the system. # Checks if the provided list of user IDs exist in the system.
openim::test::check_user_account() { openim::test::check_user_account() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"checkUserIDs": [ "checkUserIDs": [
"${1}", "${1}",
@ -156,7 +159,8 @@ openim::test::check_error "$response"
# Retrieves a list of users with pagination, limited to a specific number per page. # Retrieves a list of users with pagination, limited to a specific number per page.
openim::test::get_users() { openim::test::get_users() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"pagination": { "pagination": {
"pageNumber": 1, "pageNumber": 1,
@ -174,7 +178,8 @@ openim::test::check_error "$response"
# Obtains detailed information for a list of user IDs. # Obtains detailed information for a list of user IDs.
openim::test::get_users_info() { openim::test::get_users_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userIDs": [ "userIDs": [
"${1}", "${1}",
@ -192,7 +197,8 @@ openim::test::check_error "$response"
# Retrieves the online status for a list of user IDs. # Retrieves the online status for a list of user IDs.
openim::test::get_users_online_status() { openim::test::get_users_online_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userIDs": [ "userIDs": [
"${TEST_USER_ID}", "${TEST_USER_ID}",
@ -212,7 +218,8 @@ openim::test::check_error "$response"
# Updates the information for a user, such as nickname and face URL. # Updates the information for a user, such as nickname and face URL.
openim::test::update_user_info() { openim::test::update_user_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userInfo": { "userInfo": {
"userID": "${TEST_USER_ID}", "userID": "${TEST_USER_ID}",
@ -231,7 +238,8 @@ openim::test::check_error "$response"
# Gets the online status for users that a particular user has subscribed to. # Gets the online status for users that a particular user has subscribed to.
openim::test::get_subscribe_users_status() { openim::test::get_subscribe_users_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${TEST_USER_ID}" "userID": "${TEST_USER_ID}"
} }
@ -246,7 +254,8 @@ openim::test::check_error "$response"
# Subscribes to the online status of a list of users for a particular user ID. # Subscribes to the online status of a list of users for a particular user ID.
openim::test::subscribe_users_status() { openim::test::subscribe_users_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "9168684795", "userID": "9168684795",
"userIDs": [ "userIDs": [
@ -267,7 +276,8 @@ openim::test::check_error "$response"
# Sets the global message receiving option for a user, determining their messaging preferences. # Sets the global message receiving option for a user, determining their messaging preferences.
openim::test::set_global_msg_recv_opt() { openim::test::set_global_msg_recv_opt() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${TEST_USER_ID}", "userID": "${TEST_USER_ID}",
"globalRecvMsgOpt": 0 "globalRecvMsgOpt": 0
@ -322,7 +332,8 @@ openim::log::success "User test suite completed successfully."
# Checks if two users are friends. # Checks if two users are friends.
openim::test::is_friend() { openim::test::is_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID1": "${1}", "userID1": "${1}",
"userID2": "${2}" "userID2": "${2}"
@ -338,7 +349,8 @@ openim::test::check_error "$response"
# Deletes a friend for a user. # Deletes a friend for a user.
openim::test::delete_friend() { openim::test::delete_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID":"${1}", "ownerUserID":"${1}",
"friendUserID":"${2}" "friendUserID":"${2}"
@ -354,7 +366,8 @@ openim::test::check_error "$response"
# Gets the friend application list for a user. # Gets the friend application list for a user.
openim::test::get_friend_apply_list() { openim::test::get_friend_apply_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${MANAGER_USERID_1}", "userID": "${MANAGER_USERID_1}",
"pagination": { "pagination": {
@ -373,7 +386,8 @@ openim::test::check_error "$response"
# Gets the friend list for a user. # Gets the friend list for a user.
openim::test::get_friend_list() { openim::test::get_friend_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -392,7 +406,8 @@ openim::test::check_error "$response"
# Sets a remark for a friend. # Sets a remark for a friend.
openim::test::set_friend_remark() { openim::test::set_friend_remark() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"friendUserID": "${2}", "friendUserID": "${2}",
@ -409,7 +424,8 @@ openim::test::check_error "$response"
# Adds a friend request. # Adds a friend request.
openim::test::add_friend() { openim::test::add_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"toUserID": "${2}", "toUserID": "${2}",
@ -429,7 +445,8 @@ openim::test::check_error "$response"
openim::test::import_friend() { openim::test::import_friend() {
local friend_ids=$(printf ', "%s"' "${@:2}") local friend_ids=$(printf ', "%s"' "${@:2}")
friend_ids=${friend_ids:2} friend_ids=${friend_ids:2}
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"friendUserIDs": [${friend_ids}] "friendUserIDs": [${friend_ids}]
@ -443,10 +460,10 @@ local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OP
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Responds to a friend request. # Responds to a friend request.
openim::test::add_friend_response() { openim::test::add_friend_response() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"toUserID": "${2}", "toUserID": "${2}",
@ -464,7 +481,8 @@ openim::test::check_error "$response"
# Retrieves the friend application list that the user has applied for. # Retrieves the friend application list that the user has applied for.
openim::test::get_self_friend_apply_list() { openim::test::get_self_friend_apply_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -483,7 +501,8 @@ openim::test::check_error "$response"
# Adds a user to the blacklist. # Adds a user to the blacklist.
openim::test::add_black() { openim::test::add_black() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"blackUserID": "${2}" "blackUserID": "${2}"
@ -499,7 +518,8 @@ openim::test::check_error "$response"
# Removes a user from the blacklist. # Removes a user from the blacklist.
openim::test::remove_black() { openim::test::remove_black() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"blackUserID": "${2}" "blackUserID": "${2}"
@ -515,7 +535,8 @@ openim::test::check_error "$response"
# Retrieves the blacklist for a user. # Retrieves the blacklist for a user.
openim::test::get_black_list() { openim::test::get_black_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -544,9 +565,13 @@ local friendUserIDsArray=()
for friendUserID in "$@"; do for friendUserID in "$@"; do
friendUserIDsArray+=("\"${friendUserID}\"") friendUserIDsArray+=("\"${friendUserID}\"")
done done
local friendUserIDs=$(IFS=,; echo "${friendUserIDsArray[*]}") local friendUserIDs=$(
IFS=,
echo "${friendUserIDsArray[*]}"
)
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${ownerUserID}", "ownerUserID": "${ownerUserID}",
"friendUserIDs": [${friendUserIDs}], "friendUserIDs": [${friendUserIDs}],
@ -561,7 +586,6 @@ echo "Response: $response"
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# [openim::test::friend function description] # [openim::test::friend function description]
# The `openim::test::friend` function serves as a test suite for friend-related operations. # The `openim::test::friend` function serves as a test suite for friend-related operations.
# It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly. # It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly.
@ -631,12 +655,12 @@ openim::test::get_black_list "${TEST_USER_ID}"
openim::log::success "Friend test suite completed successfully." openim::log::success "Friend test suite completed successfully."
} }
#################################### Group Module #################################### #################################### Group Module ####################################
# Creates a new group. # Creates a new group.
openim::test::create_group() { openim::test::create_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"memberUserIDs": [ "memberUserIDs": [
"${1}" "${1}"
@ -669,7 +693,8 @@ openim::test::check_error "$response"
# Invites a user to join a group. # Invites a user to join a group.
openim::test::invite_user_to_group() { openim::test::invite_user_to_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"invitedUserIDs": [ "invitedUserIDs": [
@ -689,7 +714,8 @@ openim::test::check_error "$response"
# Transfers the ownership of a group to another user. # Transfers the ownership of a group to another user.
openim::test::transfer_group() { openim::test::transfer_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID":"${1}", "groupID":"${1}",
"oldOwnerUserID":"${2}", "oldOwnerUserID":"${2}",
@ -706,7 +732,8 @@ openim::test::check_error "$response"
# Retrieves information about multiple groups. # Retrieves information about multiple groups.
openim::test::get_groups_info() { openim::test::get_groups_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupIDs": ["${1}", "${2}"] "groupIDs": ["${1}", "${2}"]
} }
@ -721,7 +748,8 @@ openim::test::check_error "$response"
# Removes a user from a group. # Removes a user from a group.
openim::test::kick_group() { openim::test::kick_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"kickedUserIDs": [ "kickedUserIDs": [
@ -740,7 +768,8 @@ openim::test::check_error "$response"
# Retrieves information about group members. # Retrieves information about group members.
openim::test::get_group_members_info() { openim::test::get_group_members_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userIDs": ["${2}"] "userIDs": ["${2}"]
@ -756,7 +785,8 @@ openim::test::check_error "$response"
# Retrieves a list of group members. # Retrieves a list of group members.
openim::test::get_group_member_list() { openim::test::get_group_member_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"pagination": { "pagination": {
@ -775,7 +805,8 @@ openim::test::check_error "$response"
# Retrieves a list of groups that a user has joined. # Retrieves a list of groups that a user has joined.
openim::test::get_joined_group_list() { openim::test::get_joined_group_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"pagination": { "pagination": {
@ -792,10 +823,10 @@ local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OP
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Sets group member information. # Sets group member information.
openim::test::set_group_member_info() { openim::test::set_group_member_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"members": [ "members": [
{ {
@ -819,7 +850,8 @@ openim::test::check_error "$response"
# Mutes a group. # Mutes a group.
openim::test::mute_group() { openim::test::mute_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}" "groupID": "${1}"
} }
@ -834,7 +866,8 @@ openim::test::check_error "$response"
# Cancels the muting of a group. # Cancels the muting of a group.
openim::test::cancel_mute_group() { openim::test::cancel_mute_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}" "groupID": "${1}"
} }
@ -849,7 +882,8 @@ openim::test::check_error "$response"
# Dismisses a group. # Dismisses a group.
openim::test::dismiss_group() { openim::test::dismiss_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID":"${1}" "groupID":"${1}"
} }
@ -864,7 +898,8 @@ openim::test::check_error "$response"
# Cancels muting a group member. # Cancels muting a group member.
openim::test::cancel_mute_group_member() { openim::test::cancel_mute_group_member() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}" "userID": "${2}"
@ -880,7 +915,8 @@ openim::test::check_error "$response"
# Allows a user to join a group. # Allows a user to join a group.
openim::test::join_group() { openim::test::join_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"reqMessage": "req msg join group", "reqMessage": "req msg join group",
@ -898,7 +934,8 @@ openim::test::check_error "$response"
# Sets group information. # Sets group information.
openim::test::set_group_info() { openim::test::set_group_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupInfoForSet": { "groupInfoForSet": {
"groupID": "${1}", "groupID": "${1}",
@ -921,10 +958,10 @@ local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OP
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Allows a user to quit a group. # Allows a user to quit a group.
openim::test::quit_group() { openim::test::quit_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}" "userID": "${2}"
@ -940,7 +977,8 @@ openim::test::check_error "$response"
# Retrieves the list of group applications received by the user. # Retrieves the list of group applications received by the user.
openim::test::get_recv_group_applicationList() { openim::test::get_recv_group_applicationList() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"pagination": { "pagination": {
@ -959,7 +997,8 @@ openim::test::check_error "$response"
# Responds to a group application. # Responds to a group application.
openim::test::group_application_response() { openim::test::group_application_response() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"fromUserID": "${2}", "fromUserID": "${2}",
@ -977,7 +1016,8 @@ openim::test::check_error "$response"
# Retrieves the list of group applications made by the user. # Retrieves the list of group applications made by the user.
openim::test::get_user_req_group_applicationList() { openim::test::get_user_req_group_applicationList() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -996,7 +1036,8 @@ openim::test::check_error "$response"
# Mutes a group member for a specified duration. # Mutes a group member for a specified duration.
openim::test::mute_group_member() { openim::test::mute_group_member() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}", "userID": "${2}",
@ -1013,7 +1054,8 @@ openim::test::check_error "$response"
# Retrieves a list of group applications from specific users. # Retrieves a list of group applications from specific users.
openim::test::get_group_users_req_application_list() { openim::test::get_group_users_req_application_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userIDs": [ "userIDs": [
@ -1121,11 +1163,13 @@ openim::log::success "Group test suite completed successfully."
# Define a function to register a user # Define a function to register a user
openim::register_user() { openim::register_user() {
user_register_response=$(${CCURL} "${Header}" ${INSECURE_OPENIMAPI}/user/user_register \ user_register_response=$(
${CCURL} "${Header}" ${INSECURE_OPENIMAPI}/user/user_register \
-d'{ -d'{
"secret": "openIM123", "secret": "openIM123",
"users": [{"userID": "11111112","nickname": "yourNickname","faceURL": "yourFaceURL"}] "users": [{"userID": "11111112","nickname": "yourNickname","faceURL": "yourFaceURL"}]
}') }'
)
echo "$user_register_response" echo "$user_register_response"
} }
@ -1133,10 +1177,12 @@ echo "$user_register_response"
# Define a function to check the account # Define a function to check the account
openim::test::check_account() { openim::test::check_account() {
local token=$1 local token=$1
account_check_response=$(${CCURL} "${Header}" -H"operationID: 1646445464564" -H"token: ${token}" ${INSECURE_OPENIMAPI}/user/account_check \ account_check_response=$(
${CCURL} "${Header}" -H"operationID: 1646445464564" -H"token: ${token}" ${INSECURE_OPENIMAPI}/user/account_check \
-d'{ -d'{
"checkUserIDs": ["11111111","11111112"] "checkUserIDs": ["11111111","11111112"]
}') }'
)
echo "$account_check_response" echo "$account_check_response"
} }
@ -1179,7 +1225,8 @@ local sendID="${1}"
local recvID="${2}" local recvID="${2}"
local groupID="${3}" local groupID="${3}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"sendID": "${sendID}", "sendID": "${sendID}",
"recvID": "${recvID}", "recvID": "${recvID}",
@ -1223,7 +1270,8 @@ local pageNumber="${6}"
local showNumber="${7}" local showNumber="${7}"
# Construct the request body # Construct the request body
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"sendID": "${sendID}", "sendID": "${sendID}",
"recvID": "${recvID}", "recvID": "${recvID}",
@ -1256,7 +1304,8 @@ local num="${5}"
local order="${6}" # Assuming 0 for ascending, 1 for descending local order="${6}" # Assuming 0 for ascending, 1 for descending
# Construct the request body # Construct the request body
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}", "userID": "${userID}",
"seqRanges": [ "seqRanges": [
@ -1286,7 +1335,8 @@ local userID="${1}"
local conversationID="${2}" local conversationID="${2}"
local seq="${3}" local seq="${3}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}", "userID": "${userID}",
"conversationID": "${conversationID}", "conversationID": "${conversationID}",
@ -1301,12 +1351,12 @@ local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OP
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Clears all messages for a user. # Clears all messages for a user.
openim::test::user_clear_all_msg() { openim::test::user_clear_all_msg() {
local userID="${1}" local userID="${1}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}" "userID": "${userID}"
} }
@ -1322,8 +1372,7 @@ openim::test::check_error "$response"
# [openim::test::msg function description] # [openim::test::msg function description]
# The `openim::test::msg` function serves as a test suite for message-related operations. # 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. # It sequentially invokes all message-related test functions to ensure the API's message operations are functioning correctly.
function openim::test::msg() function openim::test::msg() {
{
local SEND_USER_ID="${MANAGER_USERID_1}" # This should be the sender's userID local SEND_USER_ID="${MANAGER_USERID_1}" # This should be the sender's userID
local GROUP_ID="" # GroupID if it's a group message local GROUP_ID="" # GroupID if it's a group message
local USER_ID="$RANDOM" local USER_ID="$RANDOM"
@ -1352,7 +1401,6 @@ local NUM=5
local ORDER=0 # Assuming 0 for ascending order local ORDER=0 # Assuming 0 for ascending order
openim::test::pull_msg_by_seq "${RECV_USER_ID}" "${CONVERSATION_ID}" "${BEGIN_SEQ}" "${END_SEQ}" "${NUM}" "${ORDER}" openim::test::pull_msg_by_seq "${RECV_USER_ID}" "${CONVERSATION_ID}" "${BEGIN_SEQ}" "${END_SEQ}" "${NUM}" "${ORDER}"
# Assuming message sending was successful and returned a sequence number. # Assuming message sending was successful and returned a sequence number.
local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent. local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent.
@ -1375,7 +1423,6 @@ openim::test::man() {
openim::log::info "TODO: openim test man" openim::log::info "TODO: openim test man"
} }
#################################### Build Module #################################### #################################### Build Module ####################################
# Function: openim::test::smoke # Function: openim::test::smoke

@ -1086,7 +1086,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2320,7 +2320,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2467,7 +2467,7 @@ function openim::util::desc() {
} }
function openim::util:run::prompt() { function openim::util:run::prompt() {
echo -n "$yellow\$ $reset" echo -n "${yellow}\$ ${reset}"
} }
started="" started=""
@ -2488,7 +2488,7 @@ function openim::util::run() {
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000 rate=1000
fi fi
echo "$green$1$reset" | pv -qL $rate echo "${green}$1${reset}" | pv -qL "$rate"
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
sleep 0.5 sleep 0.5
fi fi

@ -43,6 +43,54 @@ disabled=(
1091 1091
# this lint prefers command -v to which, they are not the same # this lint prefers command -v to which, they are not the same
2230 2230
# Error SC2155 indicates that you should separate variable declaration and assignment to avoid masking the return value of the command.
# In Bash scripts, when you declare and assign a local variable at the same time a command is executed, you only get the output of the command, but not the exit status (return value) of the command. #
2155
# ShellCheck issues SC2086 warnings when you refer to a variable in a script but don't put it in double quotes.This can lead to unexpected behavior when scripts encounter Spaces,
# newlines, and wildcards in file names or other data.
2086
2206
# TODO: 需要修复,然后开启
2034
2048
2148
2059
2214
2145
2128
2550
2046
2181
1102
2045
2068
2145
2207
2231
2013
2154
2120
1083
2001
2012
2016
2164
2223
2166
2119
2162
2295
2002
2004
2202
2178
2064
2260
2043
2178
2044
2153
) )
# comma separate for passing to shellcheck # comma separate for passing to shellcheck
join_by() { join_by() {
@ -76,7 +124,7 @@ do git check-ignore -q "$script" || all_shell_scripts+=("$script");
-path ./logs\* -o \ -path ./logs\* -o \
-path ./vendor\* -o \ -path ./vendor\* -o \
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \ \( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
\)) \) -print 2>/dev/null)
# detect if the host machine has the required shellcheck version installed # detect if the host machine has the required shellcheck version installed
# if so, we will use that instead. # if so, we will use that instead.
@ -117,7 +165,7 @@ if ${HAVE_SHELLCHECK}; then
else else
openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image." openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image."
"${DOCKER}" run \ "${DOCKER}" run \
--rm -v "${OPENIM_ROOT}:"${OPENIM_ROOT}"" -w "${OPENIM_ROOT}" \ --rm -v "${OPENIM_ROOT}:${OPENIM_ROOT}" -w "${OPENIM_ROOT}" \
"${SHELLCHECK_IMAGE}" \ "${SHELLCHECK_IMAGE}" \
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$? shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$?
fi fi

@ -256,7 +256,7 @@ case $1 in
t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称 t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称
join $2 $3 > /tmp/plot_diff.dat join $2 $3 > /tmp/plot_diff.dat
openim::wrk::plot_diff `basename $2` `basename $3` openim::wrk::plot_diff "$(basename "$2")" "$(basename "$3")"
exit 0 exit 0
;; ;;
*) *)

Loading…
Cancel
Save