allow to set await_device_configured in DEP profile (#11789)

#10744
This commit is contained in:
Roberto Dip
2023-05-19 07:08:35 -03:00
committed by GitHub
parent 499a040c1b
commit dcc22f436b
3 changed files with 2 additions and 30 deletions
-15
View File
@@ -1237,9 +1237,6 @@ func TestApplyMacosSetup(t *testing.T) {
invalidWebURLMacosSetup := writeTmpJSON(t, map[string]any{
"configuration_web_url": "https://example.com",
})
invalidAwaitDeviceMacosSetup := writeTmpJSON(t, map[string]any{
"await_device_configured": true,
})
invalidURLMacosSetup := writeTmpJSON(t, map[string]any{
"url": "https://example.com",
})
@@ -1553,12 +1550,6 @@ spec:
require.ErrorContains(t, err, "The automatic enrollment profile cant include configuration_web_url.")
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
// apply appconfig with invalid key #2
name = writeTmpYml(t, fmt.Sprintf(appConfigSpec, "", invalidAwaitDeviceMacosSetup))
_, err = runAppNoChecks([]string{"apply", "-f", name})
require.ErrorContains(t, err, "The automatic enrollment profile cant include await_device_configured.")
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
// apply appconfig with invalid key #3
name = writeTmpYml(t, fmt.Sprintf(appConfigSpec, "", invalidURLMacosSetup))
_, err = runAppNoChecks([]string{"apply", "-f", name})
@@ -1572,12 +1563,6 @@ spec:
require.ErrorContains(t, err, "The automatic enrollment profile cant include configuration_web_url.")
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
// apply teams with invalid key #2
name = writeTmpYml(t, fmt.Sprintf(team1And2Spec, "", invalidAwaitDeviceMacosSetup, "", invalidAwaitDeviceMacosSetup))
_, err = runAppNoChecks([]string{"apply", "-f", name})
require.ErrorContains(t, err, "The automatic enrollment profile cant include await_device_configured.")
assert.False(t, ds.SetOrUpdateMDMAppleSetupAssistantFuncInvoked)
// apply teams with invalid key #3
name = writeTmpYml(t, fmt.Sprintf(team1And2Spec, "", invalidURLMacosSetup, "", invalidURLMacosSetup))
_, err = runAppNoChecks([]string{"apply", "-f", name})
+2 -3
View File
@@ -460,9 +460,8 @@ func (svc *Service) SetOrUpdateMDMAppleSetupAssistant(ctx context.Context, asst
}
deniedFields := map[string]string{
"configuration_web_url": `Couldnt edit macos_setup_assistant. The automatic enrollment profile cant include configuration_web_url. To require end user authentication, use the macos_setup.end_user_authentication option.`,
"await_device_configured": `Couldnt edit macos_setup_assistant. The automatic enrollment profile cant include await_device_configured.`,
"url": `Couldnt edit macos_setup_assistant. The automatic enrollment profile cant include url.`,
"configuration_web_url": `Couldnt edit macos_setup_assistant. The automatic enrollment profile cant include configuration_web_url. To require end user authentication, use the macos_setup.end_user_authentication option.`,
"url": `Couldnt edit macos_setup_assistant. The automatic enrollment profile cant include url.`,
}
for k, msg := range deniedFields {
if _, ok := m[k]; ok {
-12
View File
@@ -3687,18 +3687,6 @@ func (s *integrationMDMTestSuite) TestMacosSetupAssistant() {
s.lastActivityMatches(fleet.ActivityTypeChangedMacosSetupAssistant{}.ActivityName(),
fmt.Sprintf(`{"name": "team2", "team_id": %d, "team_name": %q}`, tm.ID, tm.Name), latestChangedActID)
// try to set the await_device_configured
tmProf = `{"await_device_configured": true}`
res = s.Do("POST", "/api/latest/fleet/mdm/apple/enrollment_profile", createMDMAppleSetupAssistantRequest{
TeamID: &tm.ID,
Name: "team4",
EnrollmentProfile: json.RawMessage(tmProf),
}, http.StatusUnprocessableEntity)
errMsg = extractServerErrorText(res.Body)
require.Contains(t, errMsg, `The automatic enrollment profile cant include await_device_configured.`)
s.lastActivityMatches(fleet.ActivityTypeChangedMacosSetupAssistant{}.ActivityName(),
fmt.Sprintf(`{"name": "team2", "team_id": %d, "team_name": %q}`, tm.ID, tm.Name), latestChangedActID)
// try to set the url
tmProf = `{"url": "https://example.com"}`
res = s.Do("POST", "/api/latest/fleet/mdm/apple/enrollment_profile", createMDMAppleSetupAssistantRequest{