-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-Pick: Add experimental software title name update endpoint for…
… titles with a bundle ID (#26959) Merged into `main` in #26938. Co-authored-by: Rachael Shaw <[email protected]>
- Loading branch information
1 parent
6d1ce42
commit 40f31cb
Showing
11 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Added `PATCH /api/latest/fleet/software/titles/:id/name` endpoint for cleaning up incorrect software titles for software that has a bundle ID. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ func TestSoftwareTitles(t *testing.T) { | |
{"ListSoftwareTitlesAllTeams", testListSoftwareTitlesAllTeams}, | ||
{"UploadedSoftwareExists", testUploadedSoftwareExists}, | ||
{"ListSoftwareTitlesVulnerabilityFilters", testListSoftwareTitlesVulnerabilityFilters}, | ||
{"UpdateSoftwareTitleName", testUpdateSoftwareTitleName}, | ||
} | ||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
|
@@ -1700,3 +1701,46 @@ func testListSoftwareTitlesVulnerabilityFilters(t *testing.T, ds *Datastore) { | |
}) | ||
} | ||
} | ||
|
||
func testUpdateSoftwareTitleName(t *testing.T, ds *Datastore) { | ||
ctx := context.Background() | ||
|
||
tm, err := ds.NewTeam(ctx, &fleet.Team{Name: "Team Foo"}) | ||
require.NoError(t, err) | ||
user1 := test.NewUser(t, ds, "Alice", "[email protected]", true) | ||
|
||
installer1, _, err := ds.MatchOrCreateSoftwareInstaller(ctx, &fleet.UploadSoftwareInstallerPayload{ | ||
Title: "installer1", | ||
Source: "apps", | ||
InstallScript: "echo", | ||
Filename: "installer1.pkg", | ||
BundleIdentifier: "com.foo.installer1", | ||
UserID: user1.ID, | ||
ValidatedLabels: &fleet.LabelIdentsWithScope{}, | ||
}) | ||
require.NoError(t, err) | ||
require.NotZero(t, installer1) | ||
installer2, _, err := ds.MatchOrCreateSoftwareInstaller(ctx, &fleet.UploadSoftwareInstallerPayload{ | ||
Title: "installer2", | ||
Source: "programs", | ||
InstallScript: "echo", | ||
Filename: "installer2.msi", | ||
TeamID: &tm.ID, | ||
UserID: user1.ID, | ||
ValidatedLabels: &fleet.LabelIdentsWithScope{}, | ||
}) | ||
require.NoError(t, err) | ||
require.NotZero(t, installer2) | ||
|
||
// Changes name with bundle ID | ||
require.NoError(t, ds.UpdateSoftwareTitleName(ctx, installer1, "A new name")) | ||
title1, err := ds.SoftwareTitleByID(ctx, installer1, nil, fleet.TeamFilter{User: user1}) | ||
require.NoError(t, err) | ||
require.Equal(t, "A new name", title1.Name) | ||
|
||
// Doesn't change name with no bundle ID | ||
require.NoError(t, ds.UpdateSoftwareTitleName(ctx, installer2, "A newer name")) | ||
title2, err := ds.SoftwareTitleByID(ctx, installer2, &tm.ID, fleet.TeamFilter{User: user1}) | ||
require.NoError(t, err) | ||
require.Equal(t, "installer2", title2.Name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters