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
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user