Adopt File type for trust logos and MCP

Trust GraphQL and MCP still exposed presigned URL strings for
trust-center logos while console and connect already serve stable
File.downloadUrl paths. Phase 1 migrates the seven public logo
fields on trust GraphQL and the trust-center file references on MCP
to the shared File type; trust GraphQL NDA stays on fileUrl for a
follow-up.

Trust resolvers load public files through filemanager and map them
with types.NewFile. The trust app Relay queries and components now
read logo.downloadUrl. MCP specification, resolvers, and helpers
are updated in sync, including NDA on MCP where callers already
have file access.

filemanager is split into focused files and its URL surface is
narrowed to GenerateFileURL(file) for stable app URLs and
GeneratePresignedURL for S3 redirects. GetPublicFile remains the
DB entry point when only a file ID is known.

Add trust and MCP e2e coverage for public logo download URLs.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-06-11 13:54:59 +02:00
parent e06f3e0520
commit eccef41767
60 changed files with 1004 additions and 400 deletions

View File

@@ -126,6 +126,10 @@ func (c *Client) DoConnect(query string, variables map[string]any) (*GraphQLResp
return c.doWithEndpoint("/api/connect/v1/graphql", query, variables)
}
func (c *Client) DoTrust(trustCenterID string, query string, variables map[string]any) (*GraphQLResponse, error) {
return c.doWithEndpoint(fmt.Sprintf("/trust/%s/api/trust/v1/graphql", trustCenterID), query, variables)
}
func (c *Client) Execute(query string, variables map[string]any, result any) error {
resp, err := c.Do(query, variables)
if err != nil {
@@ -156,6 +160,21 @@ func (c *Client) ExecuteConnect(query string, variables map[string]any, result a
return nil
}
func (c *Client) ExecuteTrust(trustCenterID string, query string, variables map[string]any, result any) error {
resp, err := c.DoTrust(trustCenterID, query, variables)
if err != nil {
return err
}
if result != nil && resp.Data != nil {
if err := json.Unmarshal(resp.Data, result); err != nil {
return fmt.Errorf("cannot unmarshal data: %w", err)
}
}
return nil
}
func (c *Client) MustExecute(query string, variables map[string]any, result any) {
c.T.Helper()
err := c.Execute(query, variables, result)

View File

@@ -15,6 +15,7 @@
package mcp_test
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -23,11 +24,16 @@ import (
"go.probo.inc/probo/e2e/internal/testutil"
)
type mcpFile struct {
DownloadURL string `json:"download_url"`
}
type trustCenter struct {
ID string `json:"id"`
CompanyName string `json:"companyName"`
PageTitle string `json:"pageTitle"`
TrustCenterVisible bool `json:"trustCenterVisible"`
ID string `json:"id"`
CompanyName string `json:"companyName"`
PageTitle string `json:"pageTitle"`
TrustCenterVisible bool `json:"trustCenterVisible"`
Logo *mcpFile `json:"logo,omitempty"`
}
type trustCenterReference struct {
@@ -49,6 +55,85 @@ func TestMCP_GetTrustCenter(t *testing.T) {
mc := testutil.NewMCPClient(t, owner)
orgID := owner.GetOrganizationID().String()
const trustCenterQuery = `
query($organizationId: ID!) {
node(id: $organizationId) {
... on Organization {
trustCenter {
id
}
}
}
}
`
var trustCenterLookup struct {
Node struct {
TrustCenter struct {
ID string `json:"id"`
} `json:"trustCenter"`
} `json:"node"`
}
err := owner.Execute(trustCenterQuery, map[string]any{
"organizationId": orgID,
}, &trustCenterLookup)
require.NoError(t, err)
require.NotEmpty(t, trustCenterLookup.Node.TrustCenter.ID)
trustCenterID := trustCenterLookup.Node.TrustCenter.ID
const uploadMutation = `
mutation UpdateTrustCenterBrand($input: UpdateTrustCenterBrandInput!) {
updateTrustCenterBrand(input: $input) {
trustCenter {
id
logo {
id
downloadUrl
}
}
}
}
`
pngContent := []byte{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82,
}
var uploadResult struct {
UpdateTrustCenterBrand struct {
TrustCenter struct {
ID string `json:"id"`
Logo *struct {
ID string `json:"id"`
DownloadURL string `json:"downloadUrl"`
} `json:"logo"`
} `json:"trustCenter"`
} `json:"updateTrustCenterBrand"`
}
err = owner.ExecuteWithFile(uploadMutation, map[string]any{
"input": map[string]any{
"trustCenterId": trustCenterID,
"logoFile": nil,
},
}, "input.logoFile", testutil.UploadFile{
Filename: "mcp-trust-center-logo.png",
ContentType: "image/png",
Content: pngContent,
}, &uploadResult)
require.NoError(t, err)
require.NotNil(t, uploadResult.UpdateTrustCenterBrand.TrustCenter.Logo)
var result struct {
TrustCenter trustCenter `json:"trustCenter"`
}
@@ -57,6 +142,13 @@ func TestMCP_GetTrustCenter(t *testing.T) {
}, &result)
assert.NotEmpty(t, result.TrustCenter.ID)
require.NotNil(t, result.TrustCenter.Logo)
assert.True(
t,
strings.Contains(result.TrustCenter.Logo.DownloadURL, "/api/files/v1/public/"),
"download_url must route through the public files API, got %q",
result.TrustCenter.Logo.DownloadURL,
)
}
func TestMCP_UpdateTrustCenter(t *testing.T) {

View File

@@ -0,0 +1,164 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package trust_test
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.probo.inc/probo/e2e/internal/testutil"
)
func TestTrustCenter_LogoFileDownloadURL(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
organizationID := owner.GetOrganizationID().String()
const trustCenterQuery = `
query($organizationId: ID!) {
node(id: $organizationId) {
... on Organization {
trustCenter {
id
}
}
}
}
`
var trustCenterLookup struct {
Node struct {
TrustCenter struct {
ID string `json:"id"`
} `json:"trustCenter"`
} `json:"node"`
}
err := owner.Execute(trustCenterQuery, map[string]any{
"organizationId": organizationID,
}, &trustCenterLookup)
require.NoError(t, err)
require.NotEmpty(t, trustCenterLookup.Node.TrustCenter.ID)
trustCenterID := trustCenterLookup.Node.TrustCenter.ID
const activateMutation = `
mutation($input: UpdateTrustCenterInput!) {
updateTrustCenter(input: $input) {
trustCenter {
id
active
}
}
}
`
err = owner.Execute(activateMutation, map[string]any{
"input": map[string]any{
"trustCenterId": trustCenterID,
"active": true,
},
}, nil)
require.NoError(t, err)
const uploadMutation = `
mutation UpdateTrustCenterBrand($input: UpdateTrustCenterBrandInput!) {
updateTrustCenterBrand(input: $input) {
trustCenter {
id
logo {
id
fileName
downloadUrl
}
}
}
}
`
pngContent := []byte{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82,
}
var uploadResult struct {
UpdateTrustCenterBrand struct {
TrustCenter struct {
ID string `json:"id"`
Logo *struct {
ID string `json:"id"`
FileName string `json:"fileName"`
DownloadURL string `json:"downloadUrl"`
} `json:"logo"`
} `json:"trustCenter"`
} `json:"updateTrustCenterBrand"`
}
err = owner.ExecuteWithFile(uploadMutation, map[string]any{
"input": map[string]any{
"trustCenterId": trustCenterID,
"logoFile": nil,
},
}, "input.logoFile", testutil.UploadFile{
Filename: "trust-center-logo.png",
ContentType: "image/png",
Content: pngContent,
}, &uploadResult)
require.NoError(t, err)
require.NotNil(t, uploadResult.UpdateTrustCenterBrand.TrustCenter.Logo)
const trustGraphQLQuery = `
query {
currentTrustCenter {
logo {
id
fileName
downloadUrl
}
}
}
`
var trustResult struct {
CurrentTrustCenter struct {
Logo *struct {
ID string `json:"id"`
FileName string `json:"fileName"`
DownloadURL string `json:"downloadUrl"`
} `json:"logo"`
} `json:"currentTrustCenter"`
}
err = owner.ExecuteTrust(trustCenterID, trustGraphQLQuery, nil, &trustResult)
require.NoError(t, err)
require.NotNil(t, trustResult.CurrentTrustCenter.Logo)
assert.Equal(t, uploadResult.UpdateTrustCenterBrand.TrustCenter.Logo.ID, trustResult.CurrentTrustCenter.Logo.ID)
assert.True(
t,
strings.Contains(trustResult.CurrentTrustCenter.Logo.DownloadURL, "/api/files/v1/public/"),
"downloadUrl must route through the public files API, got %q",
trustResult.CurrentTrustCenter.Logo.DownloadURL,
)
}