Files
MeBox/internal/service/strm_account_test.go
truewhile b0fe40142a Rebrand MMTL to MeBox (name, logo, Docker image) (#17)
* Rebrand MMTL to MeBox across codebase and assets

Rename the project display name, Go module path, environment variable
prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl
to MeBox/mebox. Replace logo assets with the new MeBox icon and keep
legacy SQLite migration support for existing mmtl.db deployments.

Co-authored-by: truewhile <truewhile@users.noreply.github.com>

* Fix logo icons: use cube-only crop without truncated text

Previous icon generation cropped too much of the source image, including
partial MeBox wordmark text that was cut off in square icon containers.
Regenerate logo-64/192/512, favicon, and SVG from cube-only region.

Co-authored-by: truewhile <truewhile@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: truewhile <truewhile@users.noreply.github.com>
2026-09-02 16:26:28 +08:00

77 lines
1.8 KiB
Go

package service
import (
"context"
"encoding/json"
"testing"
"github.com/truewhile/MeBox/internal/model"
)
func TestStrmAccountConfigPreviewOf(t *testing.T) {
svc := testStrmService(t)
acct := &model.StrmAccount{
Provider: model.StrmProviderOpenList,
Config: mustJSON(map[string]string{
"server": "https://list.example.com",
"username": "alice",
"password": svc.crypto.Encrypt("secret"),
"token": svc.crypto.Encrypt("tok"),
}),
}
preview := svc.StrmAccountConfigPreviewOf(acct)
if preview.Server != "https://list.example.com" {
t.Fatalf("server = %q", preview.Server)
}
if preview.Username != "alice" {
t.Fatalf("username = %q", preview.Username)
}
if !preview.HasPassword || !preview.HasToken {
t.Fatalf("expected secret flags, got %#v", preview)
}
}
func TestUpdateStrmAccountMergesConfigWithoutClearingSecrets(t *testing.T) {
svc := testStrmService(t)
ctx := context.Background()
acct, err := svc.CreateStrmAccount(ctx, "openlist", model.StrmProviderOpenList, map[string]string{
"server": "https://list.example.com",
"username": "alice",
"password": "secret",
"token": "tok",
})
if err != nil {
t.Fatalf("create account: %v", err)
}
updated, err := svc.UpdateStrmAccount(ctx, acct.ID, "openlist-renamed", nil, map[string]string{
"server": "https://list.example.com",
"username": "alice",
})
if err != nil {
t.Fatalf("update account: %v", err)
}
if updated.Name != "openlist-renamed" {
t.Fatalf("name = %q", updated.Name)
}
cfg, err := svc.strmAccountConfig(updated)
if err != nil {
t.Fatalf("decode config: %v", err)
}
if cfg["password"] != "secret" {
t.Fatalf("password was cleared: %#v", cfg)
}
if cfg["token"] != "tok" {
t.Fatalf("token was cleared: %#v", cfg)
}
}
func mustJSON(v any) string {
data, err := json.Marshal(v)
if err != nil {
panic(err)
}
return string(data)
}