feat: sync host-based public app links

This commit is contained in:
A 2026-07-22 21:43:56 +08:00
parent 10de462191
commit 8cfb6f74c1
19 changed files with 375 additions and 26 deletions

View file

@ -0,0 +1,32 @@
package rpc
import (
"testing"
"github.com/iamxvbaba/td/clock"
"go.uber.org/zap"
)
func TestRouterPublicAppLinkUsesConfiguredBaseAndLegacyDefault(t *testing.T) {
legacy := New(Config{}, Deps{}, zap.NewNop(), clock.System)
if got, want := legacy.publicAppLink("business-bot"), "telesrv://business-bot"; got != want {
t.Fatalf("legacy business bot link = %q, want %q", got, want)
}
hosted := New(Config{
PublicAppScheme: "telesrv",
PublicAppLinkBase: "owpg://tenant.example.test",
}, Deps{}, zap.NewNop(), clock.System)
if got, want := hosted.publicAppLink("business-bot"), "owpg://tenant.example.test/business-bot"; got != want {
t.Fatalf("hosted business bot link = %q, want %q", got, want)
}
}
func TestRouterRejectsInvalidPublicAppLinkConfig(t *testing.T) {
defer func() {
if recover() == nil {
t.Fatal("New did not fail fast for an invalid public app link base")
}
}()
_ = New(Config{PublicAppLinkBase: "owpg://tenant.example.test/root"}, Deps{}, zap.NewNop(), clock.System)
}