fix: fix bin tools path

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-08-08 17:34:06 +08:00
parent 7000755e15
commit e59bf2bfe8
23 changed files with 503 additions and 55 deletions

15
test/README.md Normal file
View File

@@ -0,0 +1,15 @@
## Run the Tests
To run a single test or set of tests, you'll need the [Ginkgo](https://github.com/onsi/ginkgo) tool installed on your
machine:
```console
go install github.com/onsi/ginkgo/ginkgo@latest
```
```shell
ginkgo --help
--focus value
If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed.
```

38
test/jwt/main.go Normal file
View File

@@ -0,0 +1,38 @@
// Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"github.com/golang-jwt/jwt/v4"
)
func main() {
rawJWT := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJpYW0uYXV0aHoubWFybW90ZWR1LmNvbSIsImV4cCI6MTYwNDEyODQwMywiaWF0IjoxNjA0MTI4NDAyLCJpc3MiOiJpYW1jdGwiLCJraWQiOiJpZDEifQ.Itr5u4C-nTeA01qbjjl7RzuPD-aSQazsJZY_Z25aGnI`
// Verify the token
claims := &jwt.MapClaims{}
parsedT, err := jwt.ParseWithClaims(rawJWT, claims, func(token *jwt.Token) (interface{}, error) {
// Validate the alg is HMAC signature
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}
if kid, ok := token.Header["kid"].(string); ok {
fmt.Println("kid", kid)
}
return []byte("key1"), nil
})
if err != nil || !parsedT.Valid {
fmt.Println("token valid failed", err)
return
}
fmt.Println("ok")
}

64
test/testdata/README.md vendored Normal file
View File

@@ -0,0 +1,64 @@
# Test Data for OpenIM Server
This directory (`testdata`) contains various JSON formatted data files that are used for testing the OpenIM Server.
## Structure
```bash
testdata/
├── README.md # 描述该目录下各子目录和文件的作用
├── db/ # 存储模拟的数据库数据
│ ├── users.json # 用户的模拟数据
│ └── messages.json # 消息的模拟数据
├── requests/ # 存储模拟的请求数据
│ ├── login.json # 模拟登陆请求
│ ├── register.json # 模拟注册请求
│ └── sendMessage.json # 模拟发送消息请求
└── responses/ # 存储模拟的响应数据
├── login.json # 模拟登陆响应
├── register.json # 模拟注册响应
└── sendMessage.json # 模拟发送消息响应
```
Here is an overview of what each subdirectory or file represents:
- `db/` - This directory contains mock data mimicking the actual database contents.
- `users.json` - Represents a list of users in the system. Each entry contains user-specific information such as user ID, username, password hash, etc.
- `messages.json` - Contains a list of messages exchanged between users. Each message entry includes the sender's and receiver's user IDs, message content, timestamp, etc.
- `requests/` - This directory contains mock requests that a client might send to the server.
- `login.json` - Represents a user login request. It includes fields such as username and password.
- `register.json` - Mimics a user registration request. Contains details such as username, password, email, etc.
- `sendMessage.json` - Simulates a message sending request from a user to another user.
- `responses/` - This directory holds the expected server responses for the respective requests.
- `login.json` - Represents a successful login response from the server. It typically includes a session token and user-specific information.
- `register.json` - Simulates a successful registration response from the server, usually containing the new user's ID, username, etc.
- `sendMessage.json` - Depicts a successful message sending response from the server, confirming the delivery of the message.
## JSON Format
All the data files in this directory are in JSON format. JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.
Here is a simple example of what a JSON file might look like:
```bash
"users": [
{
"id": 1,
"username": "user1",
"password": "password1"
},
{
"id": 2,
"username": "user2",
"password": "password2"
}
]
```
In this example, "users" is an array of user objects. Each user object has an "id", "username", and "password".

0
test/testdata/db/messages.json vendored Normal file
View File

0
test/testdata/db/users.json vendored Normal file
View File

0
test/testdata/requests/login.json vendored Normal file
View File

0
test/testdata/requests/register.json vendored Normal file
View File

View File

0
test/testdata/responses/login.json vendored Normal file
View File

0
test/testdata/responses/register.json vendored Normal file
View File

View File