mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
update display name even if it's the only thing updated (#35352)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results
This commit is contained in:
parent
48a26f3fe5
commit
f1061dac62
2 changed files with 32 additions and 10 deletions
|
|
@ -344,13 +344,17 @@ func (svc *Service) UpdateSoftwareInstaller(ctx context.Context, payload *fleet.
|
|||
|
||||
if payload.SelfService == nil && payload.InstallerFile == nil && payload.PreInstallQuery == nil &&
|
||||
payload.InstallScript == nil && payload.PostInstallScript == nil && payload.UninstallScript == nil &&
|
||||
payload.LabelsIncludeAny == nil && payload.LabelsExcludeAny == nil {
|
||||
payload.LabelsIncludeAny == nil && payload.LabelsExcludeAny == nil && software.DisplayName == payload.DisplayName {
|
||||
return existingInstaller, nil // no payload, noop
|
||||
}
|
||||
|
||||
payload.InstallerID = existingInstaller.InstallerID
|
||||
dirty := make(map[string]bool)
|
||||
|
||||
if software.DisplayName != payload.DisplayName {
|
||||
dirty["DisplayName"] = true
|
||||
}
|
||||
|
||||
if payload.SelfService != nil && *payload.SelfService != existingInstaller.SelfService {
|
||||
dirty["SelfService"] = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,15 +61,11 @@ func (s *integrationMDMTestSuite) TestSoftwareTitleDisplayNames() {
|
|||
DisplayName: strings.Repeat("a", 256),
|
||||
}, http.StatusBadRequest, "The maximum display name length is 255 characters.")
|
||||
|
||||
// Should update the display name even if no other fields are passed
|
||||
s.updateSoftwareInstaller(t, &fleet.UpdateSoftwareInstallerPayload{
|
||||
SelfService: ptr.Bool(true),
|
||||
InstallScript: ptr.String("some install script"),
|
||||
PreInstallQuery: ptr.String("some pre install query"),
|
||||
PostInstallScript: ptr.String("some post install script"),
|
||||
Filename: "ruby.deb",
|
||||
TitleID: titleID,
|
||||
TeamID: &team.ID,
|
||||
DisplayName: "RubyUpdate1",
|
||||
TitleID: titleID,
|
||||
TeamID: &team.ID,
|
||||
DisplayName: "RubyUpdate1",
|
||||
}, http.StatusOK, "")
|
||||
|
||||
activityData := fmt.Sprintf(`
|
||||
|
|
@ -79,7 +75,7 @@ func (s *integrationMDMTestSuite) TestSoftwareTitleDisplayNames() {
|
|||
"software_icon_url": null,
|
||||
"team_name": "%s",
|
||||
"team_id": %d,
|
||||
"self_service": true,
|
||||
"self_service": false,
|
||||
"software_title_id": %d,
|
||||
"software_display_name": "%s"
|
||||
}`,
|
||||
|
|
@ -98,6 +94,28 @@ func (s *integrationMDMTestSuite) TestSoftwareTitleDisplayNames() {
|
|||
s.Assert().Len(resp.SoftwareTitles, 1)
|
||||
s.Assert().Equal("RubyUpdate1", resp.SoftwareTitles[0].DisplayName)
|
||||
|
||||
// set self service to true
|
||||
s.updateSoftwareInstaller(t, &fleet.UpdateSoftwareInstallerPayload{
|
||||
TitleID: titleID,
|
||||
TeamID: &team.ID,
|
||||
DisplayName: "RubyUpdate1",
|
||||
SelfService: ptr.Bool(true),
|
||||
}, http.StatusOK, "")
|
||||
|
||||
activityData = fmt.Sprintf(`
|
||||
{
|
||||
"software_title": "ruby",
|
||||
"software_package": "ruby.deb",
|
||||
"software_icon_url": null,
|
||||
"team_name": "%s",
|
||||
"team_id": %d,
|
||||
"self_service": true,
|
||||
"software_title_id": %d,
|
||||
"software_display_name": "%s"
|
||||
}`,
|
||||
team.Name, team.ID, titleID, "RubyUpdate1")
|
||||
s.lastActivityMatches(fleet.ActivityTypeEditedSoftware{}.ActivityName(), activityData, 0)
|
||||
|
||||
// My device self service has display name
|
||||
res := s.DoRawNoAuth("GET", "/api/latest/fleet/device/"+token+"/software?self_service=1", nil, http.StatusOK)
|
||||
getDeviceSw := getDeviceSoftwareResponse{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue