Fix secrets updated nil pointer bug in batch profiles flow (#34102)
This commit is contained in:
@@ -4472,6 +4472,19 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfiles() {
|
||||
http.StatusUnprocessableEntity)
|
||||
require.Contains(t, extractServerErrorText(resp.Body), "Validation Failed: maximum configuration profile file size is 1 MB")
|
||||
|
||||
// invalid profile (bad mobileconfig)
|
||||
resp = s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
|
||||
{
|
||||
Name: "Bad mobileconfig", Contents: []byte(`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PayloadContent</key>
|
||||
<array/>`),
|
||||
},
|
||||
}}, http.StatusUnprocessableEntity)
|
||||
require.Contains(t, extractServerErrorText(resp.Body), "Validation Failed: new MDMAppleConfigProfile: plist: error parsing XML property list: XML syntax error")
|
||||
|
||||
// apply an empty set to no-team
|
||||
s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: nil}, http.StatusNoContent)
|
||||
// Nothing changed, so no activity items
|
||||
|
||||
@@ -2411,12 +2411,12 @@ func getAppleProfiles(
|
||||
}
|
||||
|
||||
mdmProf, err := fleet.NewMDMAppleConfigProfile(prof.Contents, tmID)
|
||||
mdmProf.SecretsUpdatedAt = prof.SecretsUpdatedAt
|
||||
if err != nil {
|
||||
return nil, nil, ctxerr.Wrap(ctx,
|
||||
fleet.NewInvalidArgumentError(prof.Name, err.Error()),
|
||||
"invalid mobileconfig profile")
|
||||
}
|
||||
mdmProf.SecretsUpdatedAt = prof.SecretsUpdatedAt
|
||||
|
||||
for _, labelName := range prof.LabelsIncludeAll {
|
||||
if lbl, ok := labelMap[labelName]; ok {
|
||||
|
||||
Reference in New Issue
Block a user