From 8b95155ae22216f194bcbc5d7fb7bc09487fd123 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Mon, 26 Jun 2023 09:16:42 -0400 Subject: [PATCH] Add mdm_enabled field to response of PATCH /config (#12498) --- changes/bug-add-mdm-feature-flag-in-modify-appconfig | 1 + server/service/appconfig.go | 9 +++++---- server/service/integration_core_test.go | 1 + server/service/integration_mdm_test.go | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changes/bug-add-mdm-feature-flag-in-modify-appconfig diff --git a/changes/bug-add-mdm-feature-flag-in-modify-appconfig b/changes/bug-add-mdm-feature-flag-in-modify-appconfig new file mode 100644 index 0000000000..b9c1f6788e --- /dev/null +++ b/changes/bug-add-mdm-feature-flag-in-modify-appconfig @@ -0,0 +1 @@ +* Added the `mdm_enabled` feature flag information to the response payload of the `PATCH /config` endpoint. diff --git a/server/service/appconfig.go b/server/service/appconfig.go index 4be0f4cdac..e9f482c3dd 100644 --- a/server/service/appconfig.go +++ b/server/service/appconfig.go @@ -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(), }, } diff --git a/server/service/integration_core_test.go b/server/service/integration_core_test.go index 1e5000d22c..dd47e43d35 100644 --- a/server/service/integration_core_test.go +++ b/server/service/integration_core_test.go @@ -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. diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go index 72e5870b8f..170265a998 100644 --- a/server/service/integration_mdm_test.go +++ b/server/service/integration_mdm_test.go @@ -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.