From 7a128bb97983e6acee853e36f1275e7948b8a123 Mon Sep 17 00:00:00 2001 From: Jonathan Katz <44128041+jkatz01@users.noreply.github.com> Date: Wed, 12 Nov 2025 09:37:54 -0500 Subject: [PATCH] Return icon in in-house app metadata (#35568) **Related issue:** Resolves #35559 # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [x] Added/updated automated tests - [ ] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually --- server/datastore/mysql/in_house_apps.go | 11 +++++++++++ server/datastore/mysql/software_title_icons_test.go | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/datastore/mysql/in_house_apps.go b/server/datastore/mysql/in_house_apps.go index 423dd48128..1b25065ba1 100644 --- a/server/datastore/mysql/in_house_apps.go +++ b/server/datastore/mysql/in_house_apps.go @@ -11,6 +11,7 @@ import ( "github.com/fleetdm/fleet/v4/server/contexts/ctxerr" "github.com/fleetdm/fleet/v4/server/fleet" "github.com/fleetdm/fleet/v4/server/mdm/nanomdm/mdm" + "github.com/fleetdm/fleet/v4/server/ptr" "github.com/go-kit/log/level" "github.com/jmoiron/sqlx" ) @@ -247,6 +248,16 @@ WHERE dest.Categories = categories } + if teamID != nil { + icon, err := ds.GetSoftwareTitleIcon(ctx, *teamID, titleID) + if err != nil && !fleet.IsNotFound(err) { + return nil, ctxerr.Wrap(ctx, err, "get software title icon") + } + if icon != nil { + dest.IconUrl = ptr.String(icon.IconUrl()) + } + } + return &dest, nil } diff --git a/server/datastore/mysql/software_title_icons_test.go b/server/datastore/mysql/software_title_icons_test.go index 89ec95f4a3..9fff424df8 100644 --- a/server/datastore/mysql/software_title_icons_test.go +++ b/server/datastore/mysql/software_title_icons_test.go @@ -775,7 +775,6 @@ func testDeleteIconsAssociatedWithTitlesWithoutInstallers(t *testing.T, ds *Data require.NoError(t, err) require.Len(t, softwareInstallerTitleIds, 2) // iha create 2 titles require.Equal(t, titleID, softwareInstallerTitleIds[1].ID) - _, err = ds.CreateOrUpdateSoftwareTitleIcon(ctx, &fleet.UploadSoftwareTitleIconPayload{ TeamID: team.ID, TitleID: titleID, @@ -784,6 +783,10 @@ func testDeleteIconsAssociatedWithTitlesWithoutInstallers(t *testing.T, ds *Data }) require.NoError(t, err) + meta, err := ds.GetInHouseAppMetadataByTeamAndTitleID(ctx, &team.ID, titleID) + require.NoError(t, err) + require.NotEmpty(t, meta.IconUrl) + result, err := ds.writer(ctx).ExecContext(ctx, ` INSERT INTO software_titles (name, source, bundle_identifier) VALUES (?, ?, ?) `, "foo2", "ios_apps", "foo2.bundle.id")