fix: use correct copy in fleetctl error when applying profiles (#17318)
> Related issue: #16335, fixes issue QA found here: https://github.com/fleetdm/fleet/issues/16335#issuecomment-1971560894 # 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/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- Updates copy in `fleetctl` error when attempting to upload malformed profiles.
|
||||
@@ -11205,14 +11205,14 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfiles() {
|
||||
{Name: "N3", Contents: []byte(`<Exec></Exec>`)},
|
||||
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
|
||||
errMsg = extractServerErrorText(res.Body)
|
||||
require.Contains(t, errMsg, "Only <Replace> supported as a top level element")
|
||||
require.Contains(t, errMsg, "Windows configuration profiles can only have <Replace> or <Add> top level elements.")
|
||||
|
||||
// invalid xml
|
||||
res = s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
|
||||
{Name: "N3", Contents: []byte(`foo`)},
|
||||
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
|
||||
errMsg = extractServerErrorText(res.Body)
|
||||
require.Contains(t, errMsg, "Only <Replace> supported as a top level element")
|
||||
require.Contains(t, errMsg, "Windows configuration profiles can only have <Replace> or <Add> top level elements.")
|
||||
|
||||
// successfully apply windows and macOS a profiles for the team, but it's a dry run
|
||||
s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
|
||||
@@ -11332,14 +11332,14 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfilesBackwardsCompat() {
|
||||
"N3": []byte(`<Exec></Exec>`),
|
||||
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
|
||||
errMsg = extractServerErrorText(res.Body)
|
||||
require.Contains(t, errMsg, "Only <Replace> supported as a top level element")
|
||||
require.Contains(t, errMsg, "Windows configuration profiles can only have <Replace> or <Add> top level elements.")
|
||||
|
||||
// invalid xml
|
||||
res = s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", map[string]any{"profiles": map[string][]byte{
|
||||
"N3": []byte(`foo`),
|
||||
}}, http.StatusUnprocessableEntity, "team_id", strconv.Itoa(int(tm.ID)))
|
||||
errMsg = extractServerErrorText(res.Body)
|
||||
require.Contains(t, errMsg, "Only <Replace> supported as a top level element")
|
||||
require.Contains(t, errMsg, "Windows configuration profiles can only have <Replace> or <Add> top level elements.")
|
||||
|
||||
// successfully apply windows and macOS a profiles for the team, but it's a dry run
|
||||
s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", map[string]any{"profiles": map[string][]byte{
|
||||
|
||||
@@ -1695,7 +1695,7 @@ func validateProfiles(profiles []fleet.MDMProfileBatchPayload) error {
|
||||
platform := mdm.GetRawProfilePlatform(profile.Contents)
|
||||
if platform != "darwin" && platform != "windows" {
|
||||
// TODO(roberto): there's ongoing feedback with Marko about improving this message, as it's too windows specific
|
||||
return fleet.NewInvalidArgumentError("mdm", "Only <Replace> supported as a top level element. Make sure you don’t have other top level elements.")
|
||||
return fleet.NewInvalidArgumentError("mdm", "Windows configuration profiles can only have <Replace> or <Add> top level elements.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user