fleet/frontend/__mocks__/configMock.ts
Jordan Montgomery 994672ca20
Hydrant CA Feature Branch (#31807)
There are still some TODOs particularly within Gitops test code which
will be worked on in a followup PR

# 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)
- [x] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes

## 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)

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

For unreleased bug fixes in a release candidate, one of:

- [x] Confirmed that the fix is not expected to adversely impact load
test results
- [x] Alerted the release DRI if additional load testing is needed

## Database migrations

- [x] Checked table schema to confirm autoupdate
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).

## New Fleet configuration settings

- [ ] Setting(s) is/are explicitly excluded from GitOps

If you didn't check the box above, follow this checklist for
GitOps-enabled settings:

- [ ] Verified that the setting is exported via `fleetctl
generate-gitops`
- [x] Verified the setting is documented in a separate PR to [the GitOps
documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485)
- [x] Verified that the setting is cleared on the server if it is not
supplied in a YAML file (or that it is documented as being optional)
- [x] Verified that any relevant UI is disabled when GitOps mode is
enabled

---------

Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
Co-authored-by: Magnus Jensen <magnus@fleetdm.com>
Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
2025-09-04 12:39:41 -04:00

216 lines
5.3 KiB
TypeScript

import { IConfig, ILicense, IMdmConfig } from "interfaces/config";
const DEFAULT_CONFIG_MDM_MOCK: IMdmConfig = {
apple_server_url: "",
enable_disk_encryption: false,
windows_require_bitlocker_pin: false,
windows_enabled_and_configured: true,
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,
macos_updates: {
minimum_version: "",
deadline: "",
},
ios_updates: {
minimum_version: "",
deadline: "",
},
ipados_updates: {
minimum_version: "",
deadline: "",
},
macos_settings: {
custom_settings: null,
enable_disk_encryption: false,
},
macos_setup: {
bootstrap_package: "",
manual_agent_install: false,
enable_end_user_authentication: false,
macos_setup_assistant: null,
enable_release_device_manually: 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,
},
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,
},
fleet_desktop: { transparency_url: "https://fleetdm.com/transparency" },
mdm: createMockMdmConfig(),
gitops: {
gitops_mode_enabled: false,
repository_url: "",
},
};
export const createMockConfig = (overrides?: Partial<IConfig>): IConfig => {
return { ...DEFAULT_CONFIG_MOCK, ...overrides };
};
export default createMockConfig;