mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Custom installers translate no team to team_id 0 (#31846)
Custom installers for no team pass null for team_id. This needs to get translated to 0 for `getPoliciesBySoftwareTitleIDs` patch for https://github.com/fleetdm/fleet/pull/31746 For #31571
This commit is contained in:
parent
e5ff795111
commit
34518a62d6
2 changed files with 15 additions and 8 deletions
|
|
@ -146,7 +146,11 @@ func (svc *Service) UploadSoftwareInstaller(ctx context.Context, payload *fleet.
|
|||
}
|
||||
|
||||
// get values for response object
|
||||
addedInstaller, err := svc.ds.GetSoftwareInstallerMetadataByTeamAndTitleID(ctx, payload.TeamID, titleID, true)
|
||||
var tmID uint
|
||||
if payload.TeamID != nil {
|
||||
tmID = *payload.TeamID
|
||||
}
|
||||
addedInstaller, err := svc.ds.GetSoftwareInstallerMetadataByTeamAndTitleID(ctx, &tmID, titleID, true)
|
||||
if err != nil {
|
||||
return nil, ctxerr.Wrap(ctx, err, "getting added software installer")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9303,18 +9303,21 @@ func (s *integrationEnterpriseTestSuite) TestAllSoftwareTitles() {
|
|||
s.uploadSoftwareInstallerWithErrorNameReason(t, payloadEmacsMissingUnSecret, http.StatusUnprocessableEntity, "$FLEET_SECRET_INVALID",
|
||||
"uninstall script")
|
||||
|
||||
// not specifiying a team_id translates to "no team" or team_id of 0
|
||||
payloadEmacs := &fleet.UploadSoftwareInstallerPayload{
|
||||
InstallScript: "install",
|
||||
Filename: "emacs.deb",
|
||||
SelfService: true,
|
||||
InstallScript: "install",
|
||||
Filename: "emacs.deb",
|
||||
SelfService: true,
|
||||
AutomaticInstall: true,
|
||||
}
|
||||
s.uploadSoftwareInstaller(t, payloadEmacs, http.StatusOK, "")
|
||||
|
||||
payloadVim := &fleet.UploadSoftwareInstallerPayload{
|
||||
InstallScript: "install",
|
||||
Filename: "vim.deb",
|
||||
SelfService: true,
|
||||
TeamID: ptr.Uint(0),
|
||||
InstallScript: "install",
|
||||
Filename: "vim.deb",
|
||||
SelfService: true,
|
||||
TeamID: ptr.Uint(0),
|
||||
AutomaticInstall: true,
|
||||
}
|
||||
s.uploadSoftwareInstaller(t, payloadVim, http.StatusOK, "")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue