load("@rules_apple//apple:macos.bzl", "macos_command_line_application")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//:helper.bzl", "SANTA_MINIMUM_OS_VERSION", "santa_unit_test")

licenses(["notice"])

objc_library(
    name = "FCM_lib",
    srcs = ["SNTSyncFCM.mm"],
    hdrs = ["SNTSyncFCM.h"],
    sdk_frameworks = ["Network"],
    deps = [
        "//Source/common:MOLAuthenticatingURLSession",
    ],
)

objc_library(
    name = "SNTPushNotifications",
    hdrs = ["SNTPushNotifications.h"],
    deps = [
        "//Source/common:MOLXPCConnection",
    ],
)

objc_library(
    name = "SNTSantaCommandHandler",
    srcs = [
        "SNTSantaCommandHandler.mm",
        "SNTSantaCommandHandler+BinaryUpload.mm",
        "SNTSantaCommandHandler+EventUpload.mm",
        "SNTSantaCommandHandler+Kill.mm",
        "SNTSantaCommandHandler+PackageInventory.mm",
    ],
    hdrs = [
        "SNTSantaCommandHandler.h",
        "SNTSantaCommandHandler+BinaryUpload.h",
        "SNTSantaCommandHandler+EventUpload.h",
        "SNTSantaCommandHandler+Kill.h",
        "SNTSantaCommandHandler+PackageInventory.h",
    ],
    deps = [
        ":SNTPushNotifications",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTKillCommand",
        "//Source/common:SNTLogging",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@northpolesec_protos//commands:v1_cc_proto",
        "@protobuf",
    ],
)

objc_library(
    name = "NATS_lib",
    srcs = [
        "SNTPushClientNATS.mm",
        "SNTPushClientNATS+Commands.mm",
    ],
    hdrs = [
        "SNTPushClientNATS.h",
        "SNTPushClientNATS+Commands.h",
    ],
    deps = [
        ":SNTPushNotifications",
        ":SNTSantaCommandHandler",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTLogging",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTSystemInfo",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@abseil-cpp//absl/cleanup:cleanup",
        "@nats_c//:nats",
        "@northpolesec_protos//commands:v1_cc_proto",
    ],
)

objc_library(
    name = "SNTSyncState",
    srcs = ["SNTSyncState.mm"],
    hdrs = ["SNTSyncState.h"],
    deps = [
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTExportConfiguration",
        "//Source/common:SNTModeTransition",
        "//Source/common:SNTSignal",
        "//Source/common:SNTTemporaryAdminPolicy",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
    ],
)

objc_library(
    name = "SNTSyncConfigBundle",
    srcs = ["SNTSyncConfigBundle.mm"],
    hdrs = ["SNTSyncConfigBundle.h"],
    deps = [
        ":SNTSyncState",
        "//Source/common:SNTCELFallbackRule",
        "//Source/common:SNTConfigBundle",
        "//Source/common:SNTExportConfiguration",
        "//Source/common:SNTModeTransition",
        "//Source/common:SNTTemporaryAdminPolicy",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
    ],
)

santa_unit_test(
    name = "SNTSyncConfigBundleTest",
    srcs = ["SNTSyncConfigBundleTest.mm"],
    deps = [
        ":SNTSyncConfigBundle",
        ":SNTSyncState",
        "//Source/common:SNTCELFallbackRule",
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTConfigBundle",
        "//Source/common:SNTModeTransition",
        "//Source/common:SNTTemporaryAdminPolicy",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
    ],
)

# This setting is used to enable storing all sync requests as JSON files on disk.
# This can be useful for debugging purposes.
config_setting(
    name = "store_json_uploads",
    values = {"define": "SANTA_STORE_SYNC_JSON=1"},
)

objc_library(
    name = "SNTSyncLogging",
    srcs = ["SNTSyncLogging.mm"],
    hdrs = ["SNTSyncLogging.h"],
    deps = [
        ":broadcaster_lib",
        "//Source/common:SNTLogging",
    ],
)

objc_library(
    name = "SNTSyncStage",
    srcs = ["SNTSyncStage.mm"],
    hdrs = ["SNTSyncStage.h"],
    defines = select({
        ":store_json_uploads": ["SANTA_STORE_SYNC_JSON"],
        "//conditions:default": [],
    }),
    deps = [
        ":SNTSyncLogging",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:NSData+Zlib",
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTError",
        "//Source/common:SNTLogging",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTPushNotificationsTracker",
    srcs = ["SNTPushNotificationsTracker.mm"],
    hdrs = ["SNTPushNotificationsTracker.h"],
    deps = [
        "//Source/common:SNTDeepCopy",
        "//Source/common:SNTLogging",
        "//Source/common:SNTSyncConstants",
    ],
)

objc_library(
    name = "ProtoTraits",
    hdrs = ["ProtoTraits.h"],
    deps = [
        "@northpolesec_protos//sync:v1_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
    ],
)

objc_library(
    name = "SNTSyncRuleDownload",
    srcs = ["SNTSyncRuleDownload.mm"],
    hdrs = ["SNTSyncRuleDownload.h"],
    deps = [
        ":ProtoTraits",
        ":SNTPushNotificationsTracker",
        ":SNTSyncConfigBundle",
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTFileAccessRule",
        "//Source/common:SNTNetworkFlowRule",
        "//Source/common:SNTRule",
        "//Source/common:SNTSignal",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "//Source/common/faa:WatchItemPolicy",
        "//Source/common/faa:WatchItems",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@santanetd//src/santanetd:NetworkFlowRuleValidator",
    ],
)

santa_unit_test(
    name = "SNTSyncRuleDownloadTest",
    srcs = [
        "SNTSyncRuleDownloadTest.mm",
    ],
    deps = [
        ":SNTSyncRuleDownload",
        "//Source/common:SNTFileAccessRule",
        "//Source/common:SNTNetworkFlowRule",
        "//Source/common:TestUtils",
        "//Source/common/faa:WatchItemPolicy",
        "//Source/common/faa:WatchItems",
        "@northpolesec_protos//syncv2:v2_cc_proto",
    ],
)

objc_library(
    name = "SNTPushClientFCM",
    srcs = ["SNTPushClientFCM.mm"],
    hdrs = ["SNTPushClientFCM.h"],
    deps = [
        ":FCM_lib",
        ":NATS_lib",
        ":SNTPushNotifications",
        ":SNTPushNotificationsTracker",
        ":SNTSyncState",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTLogging",
        "//Source/common:SNTStrengthify",
        "//Source/common:SNTSyncConstants",
    ],
)

objc_library(
    name = "SNTSyncPreflight",
    srcs = ["SNTSyncPreflight.mm"],
    hdrs = ["SNTSyncPreflight.h"],
    deps = [
        ":ProtoTraits",
        ":SNTSyncConfigBundle",
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTCELFallbackRule",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTExportConfiguration",
        "//Source/common:SNTLogging",
        "//Source/common:SNTModeTransition",
        "//Source/common:SNTSIPStatus",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTSystemInfo",
        "//Source/common:SNTTemporaryAdminPolicy",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTSyncPostflight",
    srcs = ["SNTSyncPostflight.mm"],
    hdrs = ["SNTSyncPostflight.h"],
    deps = [
        ":ProtoTraits",
        ":SNTSyncConfigBundle",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTLogging",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTSyncEventUpload",
    srcs = ["SNTSyncEventUpload.mm"],
    hdrs = ["SNTSyncEventUpload.h"],
    deps = [
        ":ProtoTraits",
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:EncodeEntitlements",
        "//Source/common:MOLCertificate",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTFileInfo",
        "//Source/common:SNTLogging",
        "//Source/common:SNTStoredEvent",
        "//Source/common:SNTStoredExecutionEvent",
        "//Source/common:SNTStoredFileAccessEvent",
        "//Source/common:SNTStoredNetworkFlowEvent",
        "//Source/common:SNTStoredNetworkMountEvent",
        "//Source/common:SNTStoredProcess",
        "//Source/common:SNTStoredTemporaryAdminModeAuditEvent",
        "//Source/common:SNTStoredTemporaryMonitorModeAuditEvent",
        "//Source/common:SNTStoredUSBMountEvent",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTSyncPublishMetrics",
    srcs = ["SNTSyncPublishMetrics.mm"],
    hdrs = ["SNTSyncPublishMetrics.h"],
    deps = [
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:SNTLogging",
        "//Source/common:SNTMetricSet",
        "//Source/common:String",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTSyncCommands",
    srcs = ["SNTSyncCommands.mm"],
    hdrs = ["SNTSyncCommands.h"],
    deps = [
        ":SNTSantaCommandHandler",
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:String",
        "@northpolesec_protos//commands:v1_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf",
    ],
)

objc_library(
    name = "SNTSyncSignalUpload",
    srcs = ["SNTSyncSignalUpload.mm"],
    hdrs = ["SNTSyncSignalUpload.h"],
    deps = [
        ":SNTSyncLogging",
        ":SNTSyncStage",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "@northpolesec_protos//common:signals_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf",
        "@protobuf//src/google/protobuf/json",
    ],
)

objc_library(
    name = "SNTSyncManager",
    srcs = ["SNTSyncManager.mm"],
    hdrs = ["SNTSyncManager.h"],
    sdk_frameworks = ["Network"],
    deps = [
        ":NATS_lib",
        ":SNTPushClientFCM",
        ":SNTPushNotifications",
        ":SNTSantaCommandHandler",
        ":SNTSyncCommands",
        ":SNTSyncConfigBundle",
        ":SNTSyncEventUpload",
        ":SNTSyncLogging",
        ":SNTSyncPostflight",
        ":SNTSyncPreflight",
        ":SNTSyncPublishMetrics",
        ":SNTSyncRuleDownload",
        ":SNTSyncSignalUpload",
        ":SNTSyncState",
        "//Source/common:MOLAuthenticatingURLSession",
        "//Source/common:MOLXPCConnection",
        "//Source/common:NKeyTokenValidator",
        "//Source/common:Pinning",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTLogging",
        "//Source/common:SNTStoredEvent",
        "//Source/common:SNTStoredSignalReport",
        "//Source/common:SNTStrengthify",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTXPCBundleServiceInterface",
        "//Source/common:SNTXPCControlInterface",
        "@abseil-cpp//absl/cleanup:cleanup",
    ],
)

objc_library(
    name = "sync_lib",
    sdk_dylibs = ["libz"],
    sdk_frameworks = ["Network"],
    deps = [
        ":FCM_lib",
        ":NATS_lib",
        ":ProtoTraits",
        ":SNTPushClientFCM",
        ":SNTPushNotifications",
        ":SNTPushNotificationsTracker",
        ":SNTSantaCommandHandler",
        ":SNTSyncCommands",
        ":SNTSyncConfigBundle",
        ":SNTSyncEventUpload",
        ":SNTSyncLogging",
        ":SNTSyncManager",
        ":SNTSyncPostflight",
        ":SNTSyncPreflight",
        ":SNTSyncPublishMetrics",
        ":SNTSyncRuleDownload",
        ":SNTSyncSignalUpload",
        ":SNTSyncStage",
        ":SNTSyncState",
        ":broadcaster_lib",
    ],
)

santa_unit_test(
    name = "SNTSyncTest",
    srcs = ["SNTSyncTest.mm"],
    resources = glob([
        "testdata/*.json",
        "testdata/*.plist",
    ]),
    sdk_dylibs = ["libz"],
    deps = [
        ":FCM_lib",
        ":NATS_lib",
        ":SNTPushClientFCM",
        ":SNTPushNotificationsTracker",
        ":SNTSyncConfigBundle",
        ":SNTSyncEventUpload",
        ":SNTSyncLogging",
        ":SNTSyncManager",
        ":SNTSyncPostflight",
        ":SNTSyncPreflight",
        ":SNTSyncPublishMetrics",
        ":SNTSyncRuleDownload",
        ":SNTSyncSignalUpload",
        ":SNTSyncStage",
        ":SNTSyncState",
        ":broadcaster_lib",
        "//Source/common:EncodeEntitlements",
        "//Source/common:MOLAuthenticatingURLSession",
        "//Source/common:MOLCertificate",
        "//Source/common:MOLXPCConnection",
        "//Source/common:NKeyTokenValidator",
        "//Source/common:NSData+Zlib",
        "//Source/common:Pinning",
        "//Source/common:SNTCELFallbackRule",
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTDropRootPrivs",
        "//Source/common:SNTError",
        "//Source/common:SNTFileInfo",
        "//Source/common:SNTLogging",
        "//Source/common:SNTMetricSet",
        "//Source/common:SNTModeTransition",
        "//Source/common:SNTRule",
        "//Source/common:SNTSIPStatus",
        "//Source/common:SNTSignal",
        "//Source/common:SNTStoredEvent",
        "//Source/common:SNTStoredExecutionEvent",
        "//Source/common:SNTStoredFileAccessEvent",
        "//Source/common:SNTStoredNetworkFlowEvent",
        "//Source/common:SNTStoredNetworkMountEvent",
        "//Source/common:SNTStoredProcess",
        "//Source/common:SNTStoredSignalReport",
        "//Source/common:SNTStoredTemporaryAdminModeAuditEvent",
        "//Source/common:SNTStoredTemporaryMonitorModeAuditEvent",
        "//Source/common:SNTStoredUSBMountEvent",
        "//Source/common:SNTStrengthify",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTSystemInfo",
        "//Source/common:SNTXPCBundleServiceInterface",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
        "@OCMock",
        "@abseil-cpp//absl/cleanup:cleanup",
        "@northpolesec_protos//sync:v1_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf//src/google/protobuf/json",
    ],
)

santa_unit_test(
    name = "SNTSyncManagerTest",
    srcs = ["SNTSyncManagerTest.mm"],
    sdk_dylibs = ["libz"],
    deps = [
        ":FCM_lib",
        ":NATS_lib",
        ":SNTPushClientFCM",
        ":SNTPushNotificationsTracker",
        ":SNTSyncConfigBundle",
        ":SNTSyncEventUpload",
        ":SNTSyncLogging",
        ":SNTSyncManager",
        ":SNTSyncPostflight",
        ":SNTSyncPreflight",
        ":SNTSyncPublishMetrics",
        ":SNTSyncRuleDownload",
        ":SNTSyncSignalUpload",
        ":SNTSyncStage",
        ":SNTSyncState",
        ":broadcaster_lib",
        "//Source/common:EncodeEntitlements",
        "//Source/common:MOLAuthenticatingURLSession",
        "//Source/common:MOLCertificate",
        "//Source/common:MOLXPCConnection",
        "//Source/common:NKeyTokenValidator",
        "//Source/common:NSData+Zlib",
        "//Source/common:Pinning",
        "//Source/common:SNTCELFallbackRule",
        "//Source/common:SNTCommonEnums",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTDropRootPrivs",
        "//Source/common:SNTFileInfo",
        "//Source/common:SNTLogging",
        "//Source/common:SNTMetricSet",
        "//Source/common:SNTNetworkFlowRule",
        "//Source/common:SNTRule",
        "//Source/common:SNTSIPStatus",
        "//Source/common:SNTSignal",
        "//Source/common:SNTStoredEvent",
        "//Source/common:SNTStoredExecutionEvent",
        "//Source/common:SNTStoredFileAccessEvent",
        "//Source/common:SNTStoredNetworkFlowEvent",
        "//Source/common:SNTStoredNetworkMountEvent",
        "//Source/common:SNTStoredProcess",
        "//Source/common:SNTStoredSignalReport",
        "//Source/common:SNTStoredTemporaryMonitorModeAuditEvent",
        "//Source/common:SNTStoredUSBMountEvent",
        "//Source/common:SNTStrengthify",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTSystemInfo",
        "//Source/common:SNTXPCBundleServiceInterface",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:String",
        "//Source/common/ne:SNTSyncNetworkExtensionSettings",
        "@OCMock",
        "@abseil-cpp//absl/cleanup:cleanup",
        "@northpolesec_protos//sync:v1_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
        "@protobuf//src/google/protobuf/json",
        "@santanetd//src/santanetd:NetworkFlowRuleValidator",
    ],
)

objc_library(
    name = "broadcaster_lib",
    srcs = ["SNTSyncBroadcaster.mm"],
    hdrs = ["SNTSyncBroadcaster.h"],
    deps = [
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTXPCSyncServiceInterface",
    ],
)

objc_library(
    name = "santass_lib",
    srcs = [
        "SNTSyncService.h",
        "SNTSyncService.mm",
        "main.mm",
    ],
    deps = [
        ":broadcaster_lib",
        ":sync_lib",
        "//Source/common:MOLCodesignChecker",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTDropRootPrivs",
        "//Source/common:SNTExportConfiguration",
        "//Source/common:SNTLogging",
        "//Source/common:SNTStrengthify",
        "//Source/common:SNTXPCControlInterface",
        "//Source/common:SNTXPCSyncServiceInterface",
    ],
)

macos_command_line_application(
    name = "santasyncservice",
    bundle_id = "com.northpolesec.santa.syncservice",
    codesignopts = [
        "--timestamp=none",
        "--force",
        "--options library,kill,runtime",
    ],
    infoplists = ["Info.plist"],
    minimum_os_version = SANTA_MINIMUM_OS_VERSION,
    provisioning_profile = select({
        "//:adhoc_build": None,
        "//conditions:default": "@profiles//:santa_dev",
    }),
    version = "//:version",
    visibility = ["//:santa_package_group"],
    deps = [":santass_lib"],
)

santa_unit_test(
    name = "SNTSantaCommandHandlerTest",
    srcs = ["SNTSantaCommandHandlerTest.mm"],
    deps = [
        ":SNTPushNotifications",
        ":SNTSantaCommandHandler",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTXPCControlInterface",
        "@OCMock",
        "@northpolesec_protos//commands:v1_cc_proto",
        "@protobuf",
    ],
)

santa_unit_test(
    name = "SNTSyncCommandsTest",
    srcs = ["SNTSyncCommandsTest.mm"],
    deps = [
        ":SNTPushNotifications",
        ":SNTSantaCommandHandler",
        ":SNTSyncCommands",
        ":SNTSyncState",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "@OCMock",
        "@northpolesec_protos//commands:v1_cc_proto",
        "@northpolesec_protos//syncv2:v2_cc_proto",
    ],
)

santa_unit_test(
    name = "SNTPushClientNATSTest",
    srcs = ["SNTPushClientNATSTest.mm"],
    deps = [
        ":NATS_lib",
        ":SNTSyncState",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTSyncConstants",
        "//Source/common:SNTSystemInfo",
        "@OCMock",
        "@boringssl//:crypto",
        "@northpolesec_protos//commands:v1_cc_proto",
    ],
)

santa_unit_test(
    name = "SNTPushClientNATSCommandTest",
    srcs = ["SNTPushClientNATSCommandTest.mm"],
    deps = [
        ":NATS_lib",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTSyncConstants",
        "@OCMock",
        "@northpolesec_protos//commands:v1_cc_proto",
    ],
)

santa_unit_test(
    name = "SNTPushClientNATSIntegrationTest",
    srcs = ["SNTPushClientNATSIntegrationTest.mm"],
    env = {
        "NATS_INTEGRATION_TEST": "1",
        "SANTA_NATS_DISABLE_TLS": "1",
        "SANTA_NATS_DISABLE_DOMAIN_SUFFIX": "1",
    },
    tags = ["manual"],  # Only run when explicitly requested
    deps = [
        ":NATS_lib",
        ":SNTSyncState",
        "//Source/common:SNTConfigurator",
        "//Source/common:SNTSyncConstants",
        "@OCMock",
        "@nats_c//:nats",
    ],
)

santa_unit_test(
    name = "SNTPushClientNATSConnectionTest",
    srcs = ["SNTPushClientNATSConnectionTest.mm"],
    env = {
        "NATS_INTEGRATION_TEST": "1",
        "SANTA_NATS_DISABLE_TLS": "1",
        "SANTA_NATS_DISABLE_DOMAIN_SUFFIX": "1",
    },
    tags = ["manual"],  # Only run when explicitly requested
    deps = [
        ":NATS_lib",
        "//Source/common:SNTConfigurator",
        "@OCMock",
        "@nats_c//:nats",
    ],
)

santa_unit_test(
    name = "SNTSyncManagerNATSTest",
    srcs = ["SNTSyncManagerNATSTest.mm"],
    deps = [
        ":sync_lib",
        "//Source/common:MOLXPCConnection",
        "//Source/common:SNTConfigurator",
        "@OCMock",
    ],
)

test_suite(
    name = "unit_tests",
    tests = [
        ":SNTPushClientNATSCommandTest",
        ":SNTPushClientNATSConnectionTest",
        ":SNTPushClientNATSTest",
        ":SNTSantaCommandHandlerTest",
        ":SNTSyncCommandsTest",
        ":SNTSyncConfigBundleTest",
        ":SNTSyncManagerNATSTest",
        ":SNTSyncManagerTest",
        ":SNTSyncRuleDownloadTest",
        ":SNTSyncTest",
    ],
    visibility = ["//:santa_package_group"],
)
