From bb2fbbdd38f91a7338fced36c1c461d8f818ba63 Mon Sep 17 00:00:00 2001 From: gillespi314 <73313222+gillespi314@users.noreply.github.com> Date: Fri, 21 Apr 2023 11:08:09 -0500 Subject: [PATCH] Add `apple_bm_enabled_and_configured` to app config responses (#11255) --- ...ssue-11246-apple-bm-enabled-and-configured | 1 + cmd/fleet/serve.go | 2 + .../expectedGetConfigAppConfigJson.json | 191 +++++------ .../expectedGetConfigAppConfigYaml.yml | 1 + ...ectedGetConfigIncludeServerConfigJson.json | 315 +++++++++--------- ...pectedGetConfigIncludeServerConfigYaml.yml | 1 + docs/Using-Fleet/REST-API.md | 2 + server/datastore/mysql/schema.sql | 2 +- server/fleet/app.go | 9 +- server/service/appconfig.go | 8 +- server/service/integration_core_test.go | 10 +- 11 files changed, 281 insertions(+), 261 deletions(-) create mode 100644 changes/issue-11246-apple-bm-enabled-and-configured diff --git a/changes/issue-11246-apple-bm-enabled-and-configured b/changes/issue-11246-apple-bm-enabled-and-configured new file mode 100644 index 0000000000..a4cef7d476 --- /dev/null +++ b/changes/issue-11246-apple-bm-enabled-and-configured @@ -0,0 +1 @@ +- Added `apple_bm_enabled_and_configured` to app config responses. diff --git a/cmd/fleet/serve.go b/cmd/fleet/serve.go index 3c3eebb785..93a293c4a5 100644 --- a/cmd/fleet/serve.go +++ b/cmd/fleet/serve.go @@ -505,6 +505,7 @@ the way that the Fleet server works. // assume MDM is disabled until we verify that // everything is properly configured below appCfg.MDM.EnabledAndConfigured = false + appCfg.MDM.AppleBMEnabledAndConfigured = false // validate Apple BM config if config.MDM.IsAppleBMSet() { @@ -520,6 +521,7 @@ the way that the Fleet server works. if err != nil { initFatal(err, "initialize Apple BM DEP storage") } + appCfg.MDM.AppleBMEnabledAndConfigured = true } if config.MDM.IsAppleAPNsSet() && config.MDM.IsAppleSCEPSet() { diff --git a/cmd/fleetctl/testdata/expectedGetConfigAppConfigJson.json b/cmd/fleetctl/testdata/expectedGetConfigAppConfigJson.json index a57f0fd3bb..7f85241552 100644 --- a/cmd/fleetctl/testdata/expectedGetConfigAppConfigJson.json +++ b/cmd/fleetctl/testdata/expectedGetConfigAppConfigJson.json @@ -1,97 +1,98 @@ { - "kind": "config", - "apiVersion": "v1", - "spec": { - "org_info": { - "org_name": "", - "org_logo_url": "" - }, - "server_settings": { - "server_url": "", - "live_query_disabled": false, - "enable_analytics": false, - "deferred_save_host": false - }, - "smtp_settings": { - "enable_smtp": false, - "configured": false, - "sender_address": "", - "server": "", - "port": 0, - "authentication_type": "", - "user_name": "", - "password": "", - "enable_ssl_tls": false, - "authentication_method": "", - "domain": "", - "verify_ssl_certs": false, - "enable_start_tls": false - }, - "host_expiry_settings": { - "host_expiry_enabled": false, - "host_expiry_window": 0 - }, - "features": { - "enable_host_users": true, - "enable_software_inventory": false - }, - "sso_settings": { - "entity_id": "", - "issuer_uri": "", - "idp_image_url": "", - "metadata": "", - "metadata_url": "", - "idp_name": "", - "enable_jit_provisioning": false, - "enable_jit_role_sync": false, - "enable_sso": false, - "enable_sso_idp_login": false - }, - "fleet_desktop": { - "transparency_url": "https://fleetdm.com/transparency" - }, - "vulnerability_settings": { - "databases_path": "/some/path" - }, - "webhook_settings": { - "host_status_webhook": { - "enable_host_status_webhook": false, - "destination_url": "", - "host_percentage": 0, - "days_count": 0 - }, - "failing_policies_webhook": { - "enable_failing_policies_webhook": false, - "destination_url": "", - "policy_ids": null, - "host_batch_size": 0 - }, - "vulnerabilities_webhook": { - "enable_vulnerabilities_webhook": false, - "destination_url": "", - "host_batch_size": 0 - }, - "interval": "0s" - }, - "integrations": { - "jira": null, - "zendesk": null - }, - "mdm": { - "apple_bm_terms_expired": false, - "enabled_and_configured": false, - "apple_bm_default_team": "", - "macos_updates": { - "minimum_version": "", - "deadline": "" - }, - "macos_settings": { - "custom_settings": null, - "enable_disk_encryption": false - }, - "macos_setup": { - "bootstrap_package": "" - } - } - } + "kind": "config", + "apiVersion": "v1", + "spec": { + "org_info": { + "org_name": "", + "org_logo_url": "" + }, + "server_settings": { + "server_url": "", + "live_query_disabled": false, + "enable_analytics": false, + "deferred_save_host": false + }, + "smtp_settings": { + "enable_smtp": false, + "configured": false, + "sender_address": "", + "server": "", + "port": 0, + "authentication_type": "", + "user_name": "", + "password": "", + "enable_ssl_tls": false, + "authentication_method": "", + "domain": "", + "verify_ssl_certs": false, + "enable_start_tls": false + }, + "host_expiry_settings": { + "host_expiry_enabled": false, + "host_expiry_window": 0 + }, + "features": { + "enable_host_users": true, + "enable_software_inventory": false + }, + "sso_settings": { + "entity_id": "", + "issuer_uri": "", + "idp_image_url": "", + "metadata": "", + "metadata_url": "", + "idp_name": "", + "enable_jit_provisioning": false, + "enable_jit_role_sync": false, + "enable_sso": false, + "enable_sso_idp_login": false + }, + "fleet_desktop": { + "transparency_url": "https://fleetdm.com/transparency" + }, + "vulnerability_settings": { + "databases_path": "/some/path" + }, + "webhook_settings": { + "host_status_webhook": { + "enable_host_status_webhook": false, + "destination_url": "", + "host_percentage": 0, + "days_count": 0 + }, + "failing_policies_webhook": { + "enable_failing_policies_webhook": false, + "destination_url": "", + "policy_ids": null, + "host_batch_size": 0 + }, + "vulnerabilities_webhook": { + "enable_vulnerabilities_webhook": false, + "destination_url": "", + "host_batch_size": 0 + }, + "interval": "0s" + }, + "integrations": { + "jira": null, + "zendesk": null + }, + "mdm": { + "apple_bm_terms_expired": false, + "apple_bm_enabled_and_configured": false, + "enabled_and_configured": false, + "apple_bm_default_team": "", + "macos_updates": { + "minimum_version": "", + "deadline": "" + }, + "macos_settings": { + "custom_settings": null, + "enable_disk_encryption": false + }, + "macos_setup": { + "bootstrap_package": "" + } + } + } } diff --git a/cmd/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml b/cmd/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml index fbc95e94cc..902fa2e578 100644 --- a/cmd/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml +++ b/cmd/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml @@ -15,6 +15,7 @@ spec: zendesk: null mdm: apple_bm_terms_expired: false + apple_bm_enabled_and_configured: false enabled_and_configured: false apple_bm_default_team: "" macos_updates: diff --git a/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json b/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json index 3fbe9e5f51..54f1322b1d 100644 --- a/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json +++ b/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json @@ -1,159 +1,160 @@ { - "kind": "config", - "apiVersion": "v1", - "spec": { - "org_info": { - "org_name": "", - "org_logo_url": "" - }, - "server_settings": { - "server_url": "", - "live_query_disabled": false, - "enable_analytics": false, - "deferred_save_host": false - }, - "smtp_settings": { - "enable_smtp": false, - "configured": false, - "sender_address": "", - "server": "", - "port": 0, - "authentication_type": "", - "user_name": "", - "password": "", - "enable_ssl_tls": false, - "authentication_method": "", - "domain": "", - "verify_ssl_certs": false, - "enable_start_tls": false - }, - "host_expiry_settings": { - "host_expiry_enabled": false, - "host_expiry_window": 0 - }, - "features": { - "enable_host_users": true, - "enable_software_inventory": false - }, - "mdm": { - "apple_bm_default_team": "", - "apple_bm_terms_expired": false, - "enabled_and_configured": false, - "macos_updates": { - "minimum_version": "", - "deadline": "" - }, - "macos_settings": { - "custom_settings": null, - "enable_disk_encryption": false - }, - "macos_setup": { - "bootstrap_package": "" - } - }, - "sso_settings": { - "enable_jit_provisioning": false, - "enable_jit_role_sync": false, - "entity_id": "", - "issuer_uri": "", - "idp_image_url": "", - "metadata": "", - "metadata_url": "", - "idp_name": "", - "enable_sso": false, - "enable_sso_idp_login": false - }, - "fleet_desktop": { - "transparency_url": "https://fleetdm.com/transparency" - }, - "vulnerability_settings": { - "databases_path": "/some/path" - }, - "webhook_settings": { - "host_status_webhook": { - "enable_host_status_webhook": false, - "destination_url": "", - "host_percentage": 0, - "days_count": 0 - }, - "failing_policies_webhook": { - "enable_failing_policies_webhook": false, - "destination_url": "", - "policy_ids": null, - "host_batch_size": 0 - }, - "vulnerabilities_webhook": { - "enable_vulnerabilities_webhook": false, - "destination_url": "", - "host_batch_size": 0 - }, - "interval": "0s" - }, - "integrations": { - "jira": null, - "zendesk": null - }, - "update_interval": { - "osquery_detail": "1h0m0s", - "osquery_policy": "1h0m0s" - }, - "vulnerabilities": { - "databases_path": "", - "periodicity": "0s", - "cpe_database_url": "", - "cpe_translations_url": "", - "cve_feed_prefix_url": "", - "current_instance_checks": "", - "disable_data_sync": false, - "recent_vulnerability_max_age": "0s", - "disable_win_os_vulnerabilities": false - }, - "license": { - "tier": "free", - "expiration": "0001-01-01T00:00:00Z" - }, - "logging": { - "debug": true, - "json": false, - "result": { - "plugin": "filesystem", - "config": { - "enable_log_compression": false, - "enable_log_rotation": false, - "result_log_file": "/dev/null", - "status_log_file": "/dev/null", - "audit_log_file": "/dev/null", - "max_size": 500, - "max_age": 0, - "max_backups": 0 - } - }, - "status": { - "plugin": "filesystem", - "config": { - "enable_log_compression": false, - "enable_log_rotation": false, - "result_log_file": "/dev/null", - "status_log_file": "/dev/null", - "audit_log_file": "/dev/null", - "max_size": 500, - "max_age": 0, - "max_backups": 0 - } - }, - "audit": { - "plugin": "filesystem", - "config": { - "enable_log_compression": false, - "enable_log_rotation": false, - "result_log_file": "/dev/null", - "status_log_file": "/dev/null", - "audit_log_file": "/dev/null", - "max_size": 500, - "max_age": 0, - "max_backups": 0 - } - } - } - } + "kind": "config", + "apiVersion": "v1", + "spec": { + "org_info": { + "org_name": "", + "org_logo_url": "" + }, + "server_settings": { + "server_url": "", + "live_query_disabled": false, + "enable_analytics": false, + "deferred_save_host": false + }, + "smtp_settings": { + "enable_smtp": false, + "configured": false, + "sender_address": "", + "server": "", + "port": 0, + "authentication_type": "", + "user_name": "", + "password": "", + "enable_ssl_tls": false, + "authentication_method": "", + "domain": "", + "verify_ssl_certs": false, + "enable_start_tls": false + }, + "host_expiry_settings": { + "host_expiry_enabled": false, + "host_expiry_window": 0 + }, + "features": { + "enable_host_users": true, + "enable_software_inventory": false + }, + "mdm": { + "apple_bm_default_team": "", + "apple_bm_terms_expired": false, + "apple_bm_enabled_and_configured": false, + "enabled_and_configured": false, + "macos_updates": { + "minimum_version": "", + "deadline": "" + }, + "macos_settings": { + "custom_settings": null, + "enable_disk_encryption": false + }, + "macos_setup": { + "bootstrap_package": "" + } + }, + "sso_settings": { + "enable_jit_provisioning": false, + "enable_jit_role_sync": false, + "entity_id": "", + "issuer_uri": "", + "idp_image_url": "", + "metadata": "", + "metadata_url": "", + "idp_name": "", + "enable_sso": false, + "enable_sso_idp_login": false + }, + "fleet_desktop": { + "transparency_url": "https://fleetdm.com/transparency" + }, + "vulnerability_settings": { + "databases_path": "/some/path" + }, + "webhook_settings": { + "host_status_webhook": { + "enable_host_status_webhook": false, + "destination_url": "", + "host_percentage": 0, + "days_count": 0 + }, + "failing_policies_webhook": { + "enable_failing_policies_webhook": false, + "destination_url": "", + "policy_ids": null, + "host_batch_size": 0 + }, + "vulnerabilities_webhook": { + "enable_vulnerabilities_webhook": false, + "destination_url": "", + "host_batch_size": 0 + }, + "interval": "0s" + }, + "integrations": { + "jira": null, + "zendesk": null + }, + "update_interval": { + "osquery_detail": "1h0m0s", + "osquery_policy": "1h0m0s" + }, + "vulnerabilities": { + "databases_path": "", + "periodicity": "0s", + "cpe_database_url": "", + "cpe_translations_url": "", + "cve_feed_prefix_url": "", + "current_instance_checks": "", + "disable_data_sync": false, + "recent_vulnerability_max_age": "0s", + "disable_win_os_vulnerabilities": false + }, + "license": { + "tier": "free", + "expiration": "0001-01-01T00:00:00Z" + }, + "logging": { + "debug": true, + "json": false, + "result": { + "plugin": "filesystem", + "config": { + "enable_log_compression": false, + "enable_log_rotation": false, + "result_log_file": "/dev/null", + "status_log_file": "/dev/null", + "audit_log_file": "/dev/null", + "max_size": 500, + "max_age": 0, + "max_backups": 0 + } + }, + "status": { + "plugin": "filesystem", + "config": { + "enable_log_compression": false, + "enable_log_rotation": false, + "result_log_file": "/dev/null", + "status_log_file": "/dev/null", + "audit_log_file": "/dev/null", + "max_size": 500, + "max_age": 0, + "max_backups": 0 + } + }, + "audit": { + "plugin": "filesystem", + "config": { + "enable_log_compression": false, + "enable_log_rotation": false, + "result_log_file": "/dev/null", + "status_log_file": "/dev/null", + "audit_log_file": "/dev/null", + "max_size": 500, + "max_age": 0, + "max_backups": 0 + } + } + } + } } diff --git a/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml b/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml index 7b2bf0fa61..59bd64701a 100644 --- a/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml +++ b/cmd/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml @@ -15,6 +15,7 @@ spec: zendesk: null mdm: apple_bm_default_team: "" + apple_bm_enabled_and_configured: false apple_bm_terms_expired: false enabled_and_configured: false macos_updates: diff --git a/docs/Using-Fleet/REST-API.md b/docs/Using-Fleet/REST-API.md index e94dd01cdb..3ac8badf07 100644 --- a/docs/Using-Fleet/REST-API.md +++ b/docs/Using-Fleet/REST-API.md @@ -921,6 +921,7 @@ None. }, "mdm": { "apple_bm_terms_expired": false, + "apple_bm_enabled_and_configured": false, "enabled_and_configured": false, "apple_bm_default_team": "", "macos_updates": { @@ -1106,6 +1107,7 @@ Modifies the Fleet's configuration with the supplied information. "mdm": { "apple_bm_default_team": "", "apple_bm_terms_expired": false, + "apple_bm_enabled_and_configured": false, "enabled_and_configured": false, "macos_updates": { "minimum_version": "12.3.1", diff --git a/server/datastore/mysql/schema.sql b/server/datastore/mysql/schema.sql index ea77938cd8..675836f519 100644 --- a/server/datastore/mysql/schema.sql +++ b/server/datastore/mysql/schema.sql @@ -39,7 +39,7 @@ CREATE TABLE `app_config_json` ( UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO `app_config_json` VALUES (1,'{\"mdm\": {\"macos_setup\": {\"bootstrap_package\": \"\"}, \"macos_updates\": {\"deadline\": \"\", \"minimum_version\": \"\"}, \"macos_settings\": {\"custom_settings\": null, \"enable_disk_encryption\": false}, \"apple_bm_default_team\": \"\", \"apple_bm_terms_expired\": false, \"enabled_and_configured\": false}, \"features\": {\"enable_host_users\": true, \"enable_software_inventory\": false}, \"org_info\": {\"org_name\": \"\", \"org_logo_url\": \"\"}, \"integrations\": {\"jira\": null, \"zendesk\": null}, \"sso_settings\": {\"idp_name\": \"\", \"metadata\": \"\", \"entity_id\": \"\", \"enable_sso\": false, \"issuer_uri\": \"\", \"metadata_url\": \"\", \"idp_image_url\": \"\", \"enable_jit_role_sync\": false, \"enable_sso_idp_login\": false, \"enable_jit_provisioning\": false}, \"agent_options\": {\"config\": {\"options\": {\"logger_plugin\": \"tls\", \"pack_delimiter\": \"/\", \"logger_tls_period\": 10, \"distributed_plugin\": \"tls\", \"disable_distributed\": false, \"logger_tls_endpoint\": \"/api/osquery/log\", \"distributed_interval\": 10, \"distributed_tls_max_attempts\": 3}, \"decorators\": {\"load\": [\"SELECT uuid AS host_uuid FROM system_info;\", \"SELECT hostname AS hostname FROM system_info;\"]}}, \"overrides\": {}}, \"fleet_desktop\": {\"transparency_url\": \"\"}, \"smtp_settings\": {\"port\": 587, \"domain\": \"\", \"server\": \"\", \"password\": \"\", \"user_name\": \"\", \"configured\": false, \"enable_smtp\": false, \"enable_ssl_tls\": true, \"sender_address\": \"\", \"enable_start_tls\": true, \"verify_ssl_certs\": true, \"authentication_type\": \"0\", \"authentication_method\": \"0\"}, \"server_settings\": {\"server_url\": \"\", \"enable_analytics\": false, \"deferred_save_host\": false, \"live_query_disabled\": false}, \"webhook_settings\": {\"interval\": \"0s\", \"host_status_webhook\": {\"days_count\": 0, \"destination_url\": \"\", \"host_percentage\": 0, \"enable_host_status_webhook\": false}, \"vulnerabilities_webhook\": {\"destination_url\": \"\", \"host_batch_size\": 0, \"enable_vulnerabilities_webhook\": false}, \"failing_policies_webhook\": {\"policy_ids\": null, \"destination_url\": \"\", \"host_batch_size\": 0, \"enable_failing_policies_webhook\": false}}, \"host_expiry_settings\": {\"host_expiry_window\": 0, \"host_expiry_enabled\": false}, \"vulnerability_settings\": {\"databases_path\": \"\"}}','2020-01-01 01:01:01','2020-01-01 01:01:01'); +INSERT INTO `app_config_json` VALUES (1,'{\"mdm\": {\"macos_setup\": {\"bootstrap_package\": \"\"}, \"macos_updates\": {\"deadline\": \"\", \"minimum_version\": \"\"}, \"macos_settings\": {\"custom_settings\": null, \"enable_disk_encryption\": false}, \"apple_bm_default_team\": \"\", \"apple_bm_terms_expired\": false, \"enabled_and_configured\": false, \"apple_bm_enabled_and_configured\": false}, \"features\": {\"enable_host_users\": true, \"enable_software_inventory\": false}, \"org_info\": {\"org_name\": \"\", \"org_logo_url\": \"\"}, \"integrations\": {\"jira\": null, \"zendesk\": null}, \"sso_settings\": {\"idp_name\": \"\", \"metadata\": \"\", \"entity_id\": \"\", \"enable_sso\": false, \"issuer_uri\": \"\", \"metadata_url\": \"\", \"idp_image_url\": \"\", \"enable_jit_role_sync\": false, \"enable_sso_idp_login\": false, \"enable_jit_provisioning\": false}, \"agent_options\": {\"config\": {\"options\": {\"logger_plugin\": \"tls\", \"pack_delimiter\": \"/\", \"logger_tls_period\": 10, \"distributed_plugin\": \"tls\", \"disable_distributed\": false, \"logger_tls_endpoint\": \"/api/osquery/log\", \"distributed_interval\": 10, \"distributed_tls_max_attempts\": 3}, \"decorators\": {\"load\": [\"SELECT uuid AS host_uuid FROM system_info;\", \"SELECT hostname AS hostname FROM system_info;\"]}}, \"overrides\": {}}, \"fleet_desktop\": {\"transparency_url\": \"\"}, \"smtp_settings\": {\"port\": 587, \"domain\": \"\", \"server\": \"\", \"password\": \"\", \"user_name\": \"\", \"configured\": false, \"enable_smtp\": false, \"enable_ssl_tls\": true, \"sender_address\": \"\", \"enable_start_tls\": true, \"verify_ssl_certs\": true, \"authentication_type\": \"0\", \"authentication_method\": \"0\"}, \"server_settings\": {\"server_url\": \"\", \"enable_analytics\": false, \"deferred_save_host\": false, \"live_query_disabled\": false}, \"webhook_settings\": {\"interval\": \"0s\", \"host_status_webhook\": {\"days_count\": 0, \"destination_url\": \"\", \"host_percentage\": 0, \"enable_host_status_webhook\": false}, \"vulnerabilities_webhook\": {\"destination_url\": \"\", \"host_batch_size\": 0, \"enable_vulnerabilities_webhook\": false}, \"failing_policies_webhook\": {\"policy_ids\": null, \"destination_url\": \"\", \"host_batch_size\": 0, \"enable_failing_policies_webhook\": false}}, \"host_expiry_settings\": {\"host_expiry_window\": 0, \"host_expiry_enabled\": false}, \"vulnerability_settings\": {\"databases_path\": \"\"}}','2020-01-01 01:01:01','2020-01-01 01:01:01'); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `carve_blocks` ( diff --git a/server/fleet/app.go b/server/fleet/app.go index 203a9389a5..bff39f1a16 100644 --- a/server/fleet/app.go +++ b/server/fleet/app.go @@ -108,6 +108,13 @@ type VulnerabilitySettings struct { // MDM is part of AppConfig and defines the mdm settings. type MDM struct { AppleBMDefaultTeam string `json:"apple_bm_default_team"` + + // AppleBMEnabledAndConfigured is set to true if Fleet has been + // configured with the required Apple BM key pair or token. It can't be set + // manually via the PATCH /config API, it's only set automatically when + // the server starts. + AppleBMEnabledAndConfigured bool `json:"apple_bm_enabled_and_configured"` + // AppleBMTermsExpired is set to true if an Apple Business Manager request // failed due to Apple's terms and conditions having changed and need the // user to explicitly accept them. It cannot be set manually via the @@ -117,7 +124,7 @@ type MDM struct { AppleBMTermsExpired bool `json:"apple_bm_terms_expired"` // EnabledAndConfigured is set to true if Fleet has been - // configured with all the required certificates. It cant' be set + // configured with the required APNS and SCEP certificates. It can't be set // manually via the PATCH /config API, it's only set automatically when // the server starts. EnabledAndConfigured bool `json:"enabled_and_configured"` diff --git a/server/service/appconfig.go b/server/service/appconfig.go index 87dd95de07..523ced8c4d 100644 --- a/server/service/appconfig.go +++ b/server/service/appconfig.go @@ -320,11 +320,11 @@ func (svc *Service) ModifyAppConfig(ctx context.Context, p []byte, applyOpts fle return nil, ctxerr.Wrap(ctx, invalid) } - // ignore AppleBMTermsExpired and Enabled if provided in the modify - // payload we don't return an error in this case because it would - // prevent using the output of fleetctl get config as input to fleetctl - // apply or this endpoint. + // ignore MDM.EnabledAndConfigured MDM.AppleBMTermsExpired, and MDM.AppleBMEnabledAndConfigured + // if provided in the modify payload we don't return an error in this case because it would + // prevent using the output of fleetctl get config as input to fleetctl apply or this endpoint. appConfig.MDM.AppleBMTermsExpired = oldAppConfig.MDM.AppleBMTermsExpired + appConfig.MDM.AppleBMEnabledAndConfigured = oldAppConfig.MDM.AppleBMEnabledAndConfigured appConfig.MDM.EnabledAndConfigured = oldAppConfig.MDM.EnabledAndConfigured // do not send a test email in dry-run mode, so this is a good place to stop diff --git a/server/service/integration_core_test.go b/server/service/integration_core_test.go index ea36e7a3b5..ecd0f536bf 100644 --- a/server/service/integration_core_test.go +++ b/server/service/integration_core_test.go @@ -4632,12 +4632,13 @@ func (s *integrationTestSuite) TestAppConfig() { assert.Equal(t, "FleetTest", acResp.OrgInfo.OrgName) // set in SetupSuite assert.False(t, acResp.MDM.AppleBMTermsExpired) - // set the apple BM terms expired flag, and the mdm configured flag, + // set the apple BM terms expired flag, and the enabled and configured flags, // we'll check again at the end of this test to make sure they weren't // modified by any PATCH request (it cannot be set via this endpoint). appCfg, err := s.ds.AppConfig(ctx) require.NoError(t, err) appCfg.MDM.AppleBMTermsExpired = true + appCfg.MDM.AppleBMEnabledAndConfigured = true appCfg.MDM.EnabledAndConfigured = true err = s.ds.SaveAppConfig(ctx, appCfg) require.NoError(t, err) @@ -4645,6 +4646,7 @@ func (s *integrationTestSuite) TestAppConfig() { acResp = appConfigResponse{} s.DoJSON("GET", "/api/latest/fleet/config", nil, http.StatusOK, &acResp) assert.True(t, acResp.MDM.AppleBMTermsExpired) + assert.True(t, acResp.MDM.AppleBMEnabledAndConfigured) assert.True(t, acResp.MDM.EnabledAndConfigured) // no server settings set for the URL, so not possible to test the @@ -4821,12 +4823,13 @@ func (s *integrationTestSuite) TestAppConfig() { }`), http.StatusOK, &acResp) assert.True(t, acResp.MDM.AppleBMTermsExpired) - // try to update the mdm configured flag via PATCH /config + // try to update the mdm configured flags via PATCH /config // request is ok but modified value is ignored s.DoJSON("PATCH", "/api/latest/fleet/config", json.RawMessage(`{ - "mdm": { "enabled_and_configured": false } + "mdm": { "enabled_and_configured": false, "apple_bm_enabled_and_configured": false } }`), http.StatusOK, &acResp) assert.True(t, acResp.MDM.EnabledAndConfigured) + assert.True(t, acResp.MDM.AppleBMEnabledAndConfigured) // set the macos disk encryption field, fails due to license res := s.Do("PATCH", "/api/latest/fleet/config", json.RawMessage(`{ @@ -4849,6 +4852,7 @@ func (s *integrationTestSuite) TestAppConfig() { appCfg, err = s.ds.AppConfig(ctx) require.NoError(t, err) appCfg.MDM.AppleBMTermsExpired = false + appCfg.MDM.AppleBMEnabledAndConfigured = false appCfg.MDM.EnabledAndConfigured = false err = s.ds.SaveAppConfig(ctx, appCfg) require.NoError(t, err)