feat(web): Go W-G12 rooms, Redis session, and API keys
Add mode=room with room_key hub APIs, optional redis:// session backend, and web_api_key_check (sha256 pepper:key) for anlian primitives. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
26955f4f36
commit
12d2c7be69
15 files changed
+541
-13
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/db"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/session"
|
||||
)
|
||||
@@ -84,3 +85,38 @@ func TestNewABI(t *testing.T) {
|
||||
t.Fatal(out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigureRedisURLNoPanic(t *testing.T) {
|
||||
session.CloseRedis()
|
||||
session.Configure(session.Config{RedisURL: "redis://127.0.0.1:16379/0", TTLSec: 60})
|
||||
session.CloseRedis()
|
||||
}
|
||||
|
||||
func TestConfigureRedisViaDBURL(t *testing.T) {
|
||||
session.CloseRedis()
|
||||
session.Configure(session.Config{DBURL: "redis://127.0.0.1:16379/1", TTLSec: 60})
|
||||
session.CloseRedis()
|
||||
}
|
||||
|
||||
func TestSessionPersistsInRedis(t *testing.T) {
|
||||
mr, err := miniredis.Run()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer mr.Close()
|
||||
url := "redis://" + mr.Addr() + "/0"
|
||||
session.CloseRedis()
|
||||
session.Configure(session.Config{RedisURL: url, TTLSec: 3600})
|
||||
session.Reset(3600)
|
||||
id := session.NewID(0)
|
||||
if !session.SetValue(id, "lang", "zh") {
|
||||
t.Fatal("set")
|
||||
}
|
||||
session.CloseRedis()
|
||||
session.Configure(session.Config{RedisURL: url, TTLSec: 3600})
|
||||
v, ok := session.GetValue(id, "lang")
|
||||
if !ok || v != "zh" {
|
||||
t.Fatalf("persist get=%v ok=%v", v, ok)
|
||||
}
|
||||
session.CloseRedis()
|
||||
}
|
||||
Reference in new issue
Block a user