mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
e6a6dbe3f6
* feat(channel): add qq adapter and outbound delivery * feat(channel): ingest inbound qq messages * feat(web): expose qq channel in management ui * feat(channel): support qq attachment ingestion * fix(mcp): fail read raw immediately for missing files * fix(agent): parse inline image data into native image parts * test(agent): align read_media tool tests with SDK options * fix(channel): harden qq image delivery and reconnect loop Avoid data URLs for qq channel images, reset reconnect backoff after healthy sessions, and fall back gracefully for malformed public image URLs. * fix(channel): restore qq media delivery and target resolution * fix(qq,mcp,agent): fix message/qq regressions and pass go lint * fix(qq,agent): validate inline base64 and sync heartbeat seq * fix(qq): validate remote voice mime for upload checks * fix(qq): fall back intents and restore adapter wiring * fix(qq): prevent final text leakage and dedupe persisted inbound query
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package qq
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestQQAccessTokenAcceptsStringExpiresIn(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path != "/app/getAppAccessToken" {
|
|
http.NotFound(w, r)
|
|
return
|
|
}
|
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
|
"access_token": "token-1",
|
|
"expires_in": "7200",
|
|
})
|
|
}))
|
|
defer server.Close()
|
|
|
|
client := &qqClient{
|
|
appID: "1024",
|
|
clientSecret: "secret",
|
|
httpClient: server.Client(),
|
|
tokenURL: server.URL + "/app/getAppAccessToken",
|
|
msgSeq: make(map[string]int),
|
|
}
|
|
|
|
token, err := client.accessToken(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("access token: %v", err)
|
|
}
|
|
if token != "token-1" {
|
|
t.Fatalf("unexpected token: %q", token)
|
|
}
|
|
if remaining := time.Until(client.expiresAt); remaining < 7100*time.Second || remaining > 7200*time.Second {
|
|
t.Fatalf("unexpected token ttl: %s", remaining)
|
|
}
|
|
}
|