fix: use personal login for default IM tenant
Deploy olons-server production / deploy (push) Successful in 2m48s
Deploy olons-server production / deploy (push) Successful in 2m48s
This commit is contained in:
@@ -120,6 +120,39 @@ func TestLoginBasicUsesExistingWebSocketProtocol(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginBasicUsesPersonalTypeForDefaultTenant(t *testing.T) {
|
||||
upgrader := websocket.Upgrader{}
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
var packet map[string]map[string]any
|
||||
if err = conn.ReadJSON(&packet); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = conn.WriteJSON(map[string]any{"ctrl": map[string]any{"id": packet["hi"]["id"], "code": 201, "text": "created"}})
|
||||
if err = conn.ReadJSON(&packet); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
login := packet["login"]
|
||||
if login["login_type"] != float64(1) || login["tenant_code"] != defaultIMTenantCode {
|
||||
t.Fatalf("unexpected login: %#v", login)
|
||||
}
|
||||
_ = conn.WriteJSON(map[string]any{"ctrl": map[string]any{"id": login["id"], "code": 200, "text": "ok",
|
||||
"params": map[string]any{"user": "usr_member", "token": "token", "expires": "2026-10-27T10:00:00Z"}}})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := New(config.IMConfig{BaseURL: server.URL, HTTPAPIURL: server.URL,
|
||||
WebSocketURL: "ws" + strings.TrimPrefix(server.URL, "http"), TenantCode: defaultIMTenantCode,
|
||||
APIKey: "public-key", InternalService: "olons-server", InternalSecret: "secret", Timeout: time.Second})
|
||||
if _, err := client.LoginBasic(context.Background(), "member01", "password", "web-1", "web"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResetPasswordSendsBase64BcryptHash(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
|
||||
Reference in New Issue
Block a user