diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..2d3a045fcd --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + # Existing steps... + + - name: Check CLA status + uses: contributor-assistant/github-action@v2.3.1 + with: + cla-file: 'CLA.md' + fail-on-cla-failure: true + + # Existing steps... diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index a3d3b1bcf5..accfd9ba79 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -17,7 +17,7 @@ package e2e import ( "testing" - gettoken "github.com/openimsdk/open-im-server/v3/test/e2e/api/token" + gettoken "github.com/openimsdk/open-im-server/v3/test/e2e/api/token/token" "github.com/openimsdk/open-im-server/v3/test/e2e/api/user" ) @@ -28,24 +28,86 @@ import ( // This function is called on each Ginkgo node in parallel mode. func RunE2ETests(t *testing.T) { - // Example usage of new functions - token, _ := gettoken.GetUserToken("openIM123456") + // Set headers for operationID and token + operationID := "e2e-test-operation-id" + token, err := gettoken.GetUserToken("openIM123456") + if err != nil { + t.Fatalf("Failed to get user token: %v", err) + return + } + if err != nil { + t.Fatalf("Failed to get user token: %v", err) + return + } + if err != nil { + t.Fatalf("Failed to get user token: %v", err) + } + headers := map[string]string{ + "operationID": operationID, + "token": token, +} + if err != nil { + headers = make(map[string]string) + } + if _, ok := headers["operationID"]; !ok { + headers["operationID"] = operationID + } + if _, ok := headers["token"]; !ok { + headers["token"] = token + } + + + } - // Example of getting user info - _ = user.GetUsersInfo(token, []string{"user1", "user2"}) + // Example of getting user info + _, err = user.GetUsersInfo(token, []string{"user1", "user2"}) + if err != nil { + t.Fatalf("Failed to get user info: %v", err) + return + } + _ = user.GetUsersInfo(token, headers, []string{"user1", "user2"}) // Example of updating user info - _ = user.UpdateUserInfo(token, "user1", "NewNickname", "https://github.com/openimsdk/open-im-server/blob/main/assets/logo/openim-logo.png") + _ = user.UpdateUserInfo(token, headers, "user1", "NewNickname", "https://github.com/openimsdk/open-im-server/blob/main/assets/logo/openim-logo.png") + + // Example of getting users' online status + _ = user.GetUsersOnlineStatus(token, headers, []string{"user1", "user2"}) + + // Example of forcing a logout + _, err = user.ForceLogout(token, headers, "4950983283", 2) + if err != nil { + t.Fatalf("Failed to force logout: %v", err) + return + } + + // Example of checking user account + _, err = user.CheckUserAccount(token, []string{"openIM123456", "anotherUserID"}) + if err != nil { + t.Fatalf("Failed to check user account: %v", err) + return + } + // Example of getting users + _, err = user.GetUsers(token, 1, 100) + if err != nil { + t.Fatalf("Failed to get users: %v", err) + return + } +} // Example of getting users' online status - _ = user.GetUsersOnlineStatus(token, []string{"user1", "user2"}) + _, err = user.GetUsersOnlineStatus(token, []string{"user1", "user2"}) + if err != nil { + t.Fatalf("Failed to get users' online status: %v", err) + return + } // Example of forcing a logout - _ = user.ForceLogout(token, "4950983283", 2) + err = user.ForceLogout(token, "4950983283", 2) + if err != nil { // Example of checking user account - _ = user.CheckUserAccount(token, []string{"openIM123456", "anotherUserID"}) + _ = user.CheckUserAccount(token, headers, []string{"openIM123456", "anotherUserID"}) // Example of getting users - _ = user.GetUsers(token, 1, 100) + _ = user.GetUsers(token, headers, 1, 100) }