-
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.
Add experimental software title name update endpoint for titles with …
…a bundle ID (#26938) For #26933. # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated automated tests - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Rachael Shaw <[email protected]>
- Loading branch information
1 parent
6d1ce42
commit b742d43
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