fleet/frontend/__mocks__/configMock.ts
Magnus Jensen d4f48b6f9c
ACME MDM -> main (#42926)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** The entire ACME feature branch merge

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements), JS
inline code is prevented especially for url redirects, and untrusted
data interpolated into shell scripts/commands is validated against shell
metacharacters.
- [x] Timeouts are implemented and retries are limited to avoid infinite
loops

## Testing

- [x] Added/updated automated tests
- [x] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)

- [x] QA'd all new/changed functionality manually

---------

Co-authored-by: Jordan Montgomery <elijah.jordan.montgomery@gmail.com>
Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
2026-04-02 15:56:31 -05:00

236 lines
5.9 KiB
TypeScript

import { IConfig, ILicense, IMdmConfig } from "interfaces/config";
const DEFAULT_CONFIG_MDM_MOCK: IMdmConfig = {
apple_server_url: "",
enable_disk_encryption: false,
enable_recovery_lock_password: false,
windows_require_bitlocker_pin: false,
enable_turn_on_windows_mdm_manually: false,
windows_enabled_and_configured: true,
windows_entra_tenant_ids: [],
apple_bm_default_team: "Apples",
apple_bm_enabled_and_configured: true,
apple_bm_terms_expired: false,
enabled_and_configured: true,
android_enabled_and_configured: false,
apple_require_hardware_attestation: false,
macos_updates: {
minimum_version: "",
deadline: "",
},
ios_updates: {
minimum_version: "",
deadline: "",
},
ipados_updates: {
minimum_version: "",
deadline: "",
},
apple_settings: {
configuration_profiles: null,
enable_disk_encryption: false,
},
setup_experience: {
macos_bootstrap_package: "",
macos_manual_agent_install: false,
enable_end_user_authentication: false,
apple_setup_assistant: null,
apple_enable_release_device_manually: false,
require_all_software_macos: false,
lock_end_user_info: false,
},
macos_migration: {
enable: false,
mode: "",
webhook_url: "",
},
windows_updates: {
deadline_days: null,
grace_period_days: null,
},
windows_migration_enabled: false,
end_user_authentication: {
entity_id: "",
issuer_uri: "",
metadata: "",
metadata_url: "",
idp_name: "",
},
};
export const createMockMdmConfig = (
overrides?: Partial<IMdmConfig>
): IMdmConfig => {
return { ...DEFAULT_CONFIG_MDM_MOCK, ...overrides };
};
export const DEFAULT_LICENSE_MOCK: ILicense = {
tier: "free",
expiration: "0001-01-01T00:00:00Z",
device_count: 4,
note: "",
organization: "",
managed_cloud: true,
allow_disable_telemetry: false,
};
const DEFAULT_CONFIG_MOCK: IConfig = {
org_info: {
org_name: "fleet",
org_logo_url: "",
org_logo_url_light_background: "",
contact_url: "https://fleetdm.com/company/contact",
},
server_settings: {
server_url: "https://localhost:8080",
live_query_disabled: false,
enable_analytics: true,
deferred_save_host: false,
query_reports_disabled: false,
scripts_disabled: false,
ai_features_disabled: false,
},
smtp_settings: {
enable_smtp: false,
configured: false,
sender_address: "",
server: "",
port: 587,
authentication_type: "authtype_username_password",
user_name: "",
password: "********",
enable_ssl_tls: true,
authentication_method: "authmethod_plain",
domain: "",
verify_ssl_certs: true,
enable_start_tls: true,
},
sso_settings: {
entity_id: "",
issuer_uri: "",
metadata: "",
metadata_url: "",
idp_name: "",
idp_image_url: "",
enable_sso: false,
enable_sso_idp_login: false,
enable_jit_provisioning: false,
enable_jit_role_sync: false,
},
conditional_access: {
microsoft_entra_tenant_id: "123",
microsoft_entra_connection_configured: true,
okta_idp_id: "",
okta_assertion_consumer_service_url: "",
okta_audience_uri: "",
okta_certificate: "",
},
host_expiry_settings: {
host_expiry_enabled: false,
host_expiry_window: 0,
},
activity_expiry_settings: {
activity_expiry_enabled: true,
activity_expiry_window: 90,
},
agent_options: "",
license: DEFAULT_LICENSE_MOCK,
webhook_settings: {
host_status_webhook: {
enable_host_status_webhook: true,
destination_url: "https://server.com",
host_percentage: 5,
days_count: 7,
},
failing_policies_webhook: {
enable_failing_policies_webhook: true,
destination_url: "https://server.com",
policy_ids: [1, 2, 3],
host_batch_size: 1000,
},
vulnerabilities_webhook: {
enable_vulnerabilities_webhook: true,
destination_url: "https://server.com",
host_batch_size: 1000,
},
activities_webhook: {
enable_activities_webhook: true,
destination_url: "https://server.com",
},
},
integrations: {
jira: [],
zendesk: [],
google_calendar: [],
},
logging: {
debug: false,
json: false,
result: {
plugin: "filesystem",
config: {
status_log_file:
"/var/folders/xh/bxm1d2615tv3vrg4zrxq540h0000gn/T/osquery_status",
result_log_file:
"/var/folders/xh/bxm1d2615tv3vrg4zrxq540h0000gn/T/osquery_result",
enable_log_rotation: false,
enable_log_compression: false,
},
},
status: {
plugin: "filesystem",
config: {
status_log_file:
"/var/folders/xh/bxm1d2615tv3vrg4zrxq540h0000gn/T/osquery_status",
result_log_file:
"/var/folders/xh/bxm1d2615tv3vrg4zrxq540h0000gn/T/osquery_result",
enable_log_rotation: false,
enable_log_compression: false,
},
},
audit: {
plugin: "",
config: null,
},
},
update_interval: {
osquery_detail: 3600000000000,
osquery_policy: 3600000000000,
},
vulnerabilities: {
cpe_database_url: "",
current_instance_checks: "auto",
cve_feed_prefix_url: "",
databases_path: "",
disable_data_sync: false,
periodicity: 3600000000000,
recent_vulnerability_max_age: 2592000000000000,
},
sandbox_enabled: false,
features: {
enable_host_users: true,
enable_software_inventory: true,
enable_conditional_access: true,
enable_conditional_access_bypass: true,
},
fleet_desktop: {
transparency_url: "https://fleetdm.com/transparency",
alternative_browser_host: "",
},
mdm: createMockMdmConfig(),
gitops: {
gitops_mode_enabled: false,
repository_url: "",
exceptions: {
labels: false,
software: false,
secrets: true,
},
},
};
export const createMockConfig = (overrides?: Partial<IConfig>): IConfig => {
return { ...DEFAULT_CONFIG_MOCK, ...overrides };
};
export default createMockConfig;