Add mdm_enabled field to response of PATCH /config (#12498)

This commit is contained in:
Martin Angers 2023-06-26 09:16:42 -04:00 committed by GitHub
parent a8ee03b457
commit 8b95155ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1 @@
* Added the `mdm_enabled` feature flag information to the response payload of the `PATCH /config` endpoint.

View File

@ -196,7 +196,7 @@ type modifyAppConfigRequest struct {
func modifyAppConfigEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (errorer, error) {
req := request.(*modifyAppConfigRequest)
config, err := svc.ModifyAppConfig(ctx, req.RawMessage, fleet.ApplySpecOptions{
appConfig, err := svc.ModifyAppConfig(ctx, req.RawMessage, fleet.ApplySpecOptions{
Force: req.Force,
DryRun: req.DryRun,
})
@ -212,10 +212,11 @@ func modifyAppConfigEndpoint(ctx context.Context, request interface{}, svc fleet
return nil, err
}
response := appConfigResponse{
AppConfig: *config,
AppConfig: *appConfig,
appConfigResponseFields: appConfigResponseFields{
License: license,
Logging: loggingConfig,
License: license,
Logging: loggingConfig,
MDMEnabled: config.IsMDMFeatureFlagEnabled(),
},
}

View File

@ -4692,6 +4692,7 @@ func (s *integrationTestSuite) TestAppConfig() {
}`), http.StatusOK, &acResp)
assert.Equal(t, "test", acResp.OrgInfo.OrgName)
assert.True(t, acResp.MDM.AppleBMTermsExpired)
assert.False(t, acResp.MDMEnabled)
// the global agent options were not modified by the last call, so the
// corresponding activity should not have been created.

View File

@ -5066,10 +5066,12 @@ func (s *integrationMDMTestSuite) TestAppConfigMicrosoftMDM() {
}
// enable Microsoft MDM
acResp = appConfigResponse{}
s.DoJSON("PATCH", "/api/latest/fleet/config", json.RawMessage(`{
"mdm": { "windows_enabled_and_configured": true }
}`), http.StatusOK, &acResp)
assert.True(t, acResp.MDM.MicrosoftEnabledAndConfigured)
assert.True(t, acResp.MDMEnabled)
// get the orbit config for each host, verify that only the expected ones
// receive the "needs enrollment to Microsoft MDM" notification.