Fixed software install API endpoint in tests.

This commit is contained in:
Victor Lyuboslavsky 2024-09-09 11:46:06 -05:00
parent b4b3a8e8e2
commit a429089aca
No known key found for this signature in database
3 changed files with 13 additions and 10 deletions

View file

@ -370,7 +370,7 @@ type SoftwarePackageOrApp struct {
IconURL *string `json:"icon_url"`
LastInstall *HostSoftwareInstall `json:"last_install"`
LastUninstall *HostSoftwareUninstall `json:"last_uninstall"`
PackageURL *string `json:"package_url"`
PackageURL *string `json:"package_url"`
}
type SoftwarePackageSpec struct {

View file

@ -11341,12 +11341,12 @@ func (s *integrationEnterpriseTestSuite) TestSelfServiceSoftwareInstall() {
titleIDSS := getSoftwareTitleID(t, s.ds, payloadSS.Title, "deb_packages")
// cannot self-install if software installer does not allow it
res := s.DoRawNoAuth("POST", fmt.Sprintf("/api/v1/fleet/device/%s/software/%d/install", token, titleIDNoSS), nil, http.StatusBadRequest)
res := s.DoRawNoAuth("POST", fmt.Sprintf("/api/v1/fleet/device/%s/software/install/%d", token, titleIDNoSS), nil, http.StatusBadRequest)
errMsg := extractServerErrorText(res.Body)
require.Contains(t, errMsg, "Software title is not available through self-service")
// request self-install of software that allows it
s.DoRawNoAuth("POST", fmt.Sprintf("/api/v1/fleet/device/%s/software/%d/install", token, titleIDSS), nil, http.StatusAccepted)
s.DoRawNoAuth("POST", fmt.Sprintf("/api/v1/fleet/device/%s/software/install/%d", token, titleIDSS), nil, http.StatusAccepted)
// it shows up as "self-installed" in the upcoming activities of the host
var listUpcomingAct listHostUpcomingActivitiesResponse
@ -13036,7 +13036,8 @@ func (s *integrationEnterpriseTestSuite) TestVPPAppsWithoutMDM() {
}, &team.ID)
require.NoError(t, err)
r := s.Do("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", orbitHost.ID, app.TitleID), &installSoftwareRequest{}, http.StatusUnprocessableEntity)
r := s.Do("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", orbitHost.ID, app.TitleID), &installSoftwareRequest{},
http.StatusUnprocessableEntity)
require.Contains(t, extractServerErrorText(r.Body), "Couldn't install. MDM is turned off. Please make sure that MDM is turned on to install App Store apps.")
}
@ -13399,7 +13400,7 @@ func (s *integrationEnterpriseTestSuite) TestPolicyAutomationsSoftwareInstallers
// Request a manual installation on the host for the same installer, which should fail.
var installResp installSoftwareResponse
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d",
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install",
host1Team1.ID, dummyInstallerPkgTitleID), nil, http.StatusBadRequest, &installResp)
// Submit same results as before, which should not trigger a installation because the policy is already failing.

View file

@ -10510,7 +10510,7 @@ func (s *integrationMDMTestSuite) TestVPPApps() {
// attempt to install a VPP app on the non-MDM enrolled host
installResp := installSoftwareResponse{}
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", orbitHost.ID, macOSTitleID), &installSoftwareRequest{},
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", orbitHost.ID, macOSTitleID), &installSoftwareRequest{},
http.StatusBadRequest, &installResp)
// Disable all teams token
@ -10541,7 +10541,8 @@ func (s *integrationMDMTestSuite) TestVPPApps() {
s.DoJSON("PATCH", fmt.Sprintf("/api/latest/fleet/vpp_tokens/%d/teams", validToken.Token.ID), patchVPPTokensTeamsRequest{TeamIDs: []uint{}}, http.StatusOK, &resPatchVPP)
// Attempt to install non-existent app
r := s.Do("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", mdmHost.ID, 99999), &installSoftwareRequest{}, http.StatusBadRequest)
r := s.Do("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", mdmHost.ID, 99999), &installSoftwareRequest{},
http.StatusBadRequest)
require.Contains(t, extractServerErrorText(r.Body), "Couldn't install software. Software title is not available for install. Please add software package or App Store app to install.")
// Add app 1 as self-service
@ -10560,7 +10561,8 @@ func (s *integrationMDMTestSuite) TestVPPApps() {
// Trigger install to the host
installResp = installSoftwareResponse{}
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", mdmHost.ID, errTitleID), &installSoftwareRequest{}, http.StatusAccepted, &installResp)
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", mdmHost.ID, errTitleID), &installSoftwareRequest{},
http.StatusAccepted, &installResp)
s.Do("DELETE", fmt.Sprintf("/api/latest/fleet/vpp_tokens/%d", vppRes.Token.ID), &deleteVPPTokenRequest{}, http.StatusNoContent)
@ -10612,7 +10614,7 @@ func (s *integrationMDMTestSuite) TestVPPApps() {
// Trigger install to the host
installResp = installSoftwareResponse{}
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", mdmHost.ID, macOSTitleID), &installSoftwareRequest{},
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", mdmHost.ID, macOSTitleID), &installSoftwareRequest{},
http.StatusAccepted, &installResp)
countResp = countHostsResponse{}
s.DoJSON("GET", "/api/latest/fleet/hosts/count", nil, http.StatusOK, &countResp, "software_status", "pending", "team_id",
@ -10791,7 +10793,7 @@ func (s *integrationMDMTestSuite) TestVPPApps() {
&fleetSelfServiceSoftwareInstallRequest{}, http.StatusAccepted, &ssInstallResp)
} else {
installResp = installSoftwareResponse{}
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/install/%d", installHost.ID, titleID),
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/software/%d/install", installHost.ID, titleID),
&installSoftwareRequest{}, http.StatusAccepted, &installResp)
}
countResp = countHostsResponse{}