@@ -3870,6 +3870,101 @@ func TestFetchLogoSVG(t *testing.T) {
38703870 })
38713871}
38723872
3873+ func TestBrandURL (t * testing.T ) {
3874+ t .Run ("returns empty when not set" , func (t * testing.T ) {
3875+ p := & Platform {config : & Config {}}
3876+ if got := p .BrandURL (); got != "" {
3877+ t .Errorf ("BrandURL() = %q, want empty" , got )
3878+ }
3879+ })
3880+
3881+ t .Run ("returns cached value from injectPortalLogo" , func (t * testing.T ) {
3882+ p := & Platform {config : & Config {}}
3883+ cfg := map [string ]any {"brand_url" : "https://example.com" }
3884+ _ = p .injectPortalLogo (cfg )
3885+ if got := p .BrandURL (); got != "https://example.com" {
3886+ t .Errorf ("BrandURL() = %q, want %q" , got , "https://example.com" )
3887+ }
3888+ })
3889+ }
3890+
3891+ func TestInjectPortalLogo_CachesBrandURL (t * testing.T ) {
3892+ t .Run ("caches brand_url from config" , func (t * testing.T ) {
3893+ p := & Platform {config : & Config {}}
3894+ cfg := map [string ]any {"brand_url" : "https://platform.io" }
3895+ _ = p .injectPortalLogo (cfg )
3896+ if p .resolvedBrandURL != "https://platform.io" {
3897+ t .Errorf ("resolvedBrandURL = %q, want %q" , p .resolvedBrandURL , "https://platform.io" )
3898+ }
3899+ })
3900+
3901+ t .Run ("caches brand_url even without portal logo" , func (t * testing.T ) {
3902+ p := & Platform {config : & Config {}} // no Portal.Logo
3903+ cfg := map [string ]any {"brand_url" : "https://noportallogo.io" , "logo_svg" : "<svg/>" }
3904+ _ = p .injectPortalLogo (cfg )
3905+ if p .resolvedBrandURL != "https://noportallogo.io" {
3906+ t .Errorf ("resolvedBrandURL = %q, want %q" , p .resolvedBrandURL , "https://noportallogo.io" )
3907+ }
3908+ // Also verify logo_svg was cached even without portal.Logo
3909+ if p .resolvedBrandLogoSVG != "<svg/>" {
3910+ t .Errorf ("resolvedBrandLogoSVG = %q, want %q" , p .resolvedBrandLogoSVG , "<svg/>" )
3911+ }
3912+ })
3913+
3914+ t .Run ("does not set brand_url when absent" , func (t * testing.T ) {
3915+ p := & Platform {config : & Config {}}
3916+ cfg := map [string ]any {"brand_name" : "Test" }
3917+ _ = p .injectPortalLogo (cfg )
3918+ if p .resolvedBrandURL != "" {
3919+ t .Errorf ("resolvedBrandURL = %q, want empty" , p .resolvedBrandURL )
3920+ }
3921+ })
3922+ }
3923+
3924+ func TestResolveImplementorLogo (t * testing.T ) {
3925+ svgContent := `<svg viewBox="0 0 32 32"><rect width="32" height="32"/></svg>`
3926+
3927+ t .Run ("fetches and caches SVG" , func (t * testing.T ) {
3928+ srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
3929+ w .Header ().Set ("Content-Type" , "image/svg+xml" )
3930+ _ , _ = w .Write ([]byte (svgContent ))
3931+ }))
3932+ defer srv .Close ()
3933+
3934+ p := & Platform {config : & Config {
3935+ Portal : PortalConfig {Implementor : ImplementorConfig {Logo : srv .URL + "/impl.svg" }},
3936+ }}
3937+
3938+ got := p .ResolveImplementorLogo ()
3939+ if got != svgContent {
3940+ t .Errorf ("ResolveImplementorLogo() = %q, want %q" , got , svgContent )
3941+ }
3942+
3943+ // Second call should return cached value (no HTTP request)
3944+ srv .Close ()
3945+ got2 := p .ResolveImplementorLogo ()
3946+ if got2 != svgContent {
3947+ t .Errorf ("cached ResolveImplementorLogo() = %q, want %q" , got2 , svgContent )
3948+ }
3949+ })
3950+
3951+ t .Run ("returns empty when logo URL is empty" , func (t * testing.T ) {
3952+ p := & Platform {config : & Config {}}
3953+ if got := p .ResolveImplementorLogo (); got != "" {
3954+ t .Errorf ("ResolveImplementorLogo() = %q, want empty" , got )
3955+ }
3956+ })
3957+
3958+ t .Run ("returns empty on fetch failure" , func (t * testing.T ) {
3959+ p := & Platform {config : & Config {
3960+ Portal : PortalConfig {Implementor : ImplementorConfig {Logo : "http://127.0.0.1:1/unreachable.svg" }},
3961+ }}
3962+ if got := p .ResolveImplementorLogo (); got != "" {
3963+ t .Errorf ("ResolveImplementorLogo() = %q, want empty on fetch failure" , got )
3964+ }
3965+ })
3966+ }
3967+
38733968func TestNew_WorkflowGatingDisabled (t * testing.T ) {
38743969 cfg := & Config {
38753970 Server : ServerConfig {Name : testServerName },
0 commit comments