@sonde/packs 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -0
- package/.turbo/turbo-test.log +814 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +10 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/citrix.d.ts +13 -0
- package/dist/integrations/citrix.d.ts.map +1 -0
- package/dist/integrations/citrix.js +420 -0
- package/dist/integrations/citrix.js.map +1 -0
- package/dist/integrations/citrix.test.d.ts +2 -0
- package/dist/integrations/citrix.test.d.ts.map +1 -0
- package/dist/integrations/citrix.test.js +464 -0
- package/dist/integrations/citrix.test.js.map +1 -0
- package/dist/integrations/graph.d.ts +9 -0
- package/dist/integrations/graph.d.ts.map +1 -0
- package/dist/integrations/graph.js +290 -0
- package/dist/integrations/graph.js.map +1 -0
- package/dist/integrations/graph.test.d.ts +2 -0
- package/dist/integrations/graph.test.d.ts.map +1 -0
- package/dist/integrations/graph.test.js +356 -0
- package/dist/integrations/graph.test.js.map +1 -0
- package/dist/integrations/httpbin.d.ts +3 -0
- package/dist/integrations/httpbin.d.ts.map +1 -0
- package/dist/integrations/httpbin.js +70 -0
- package/dist/integrations/httpbin.js.map +1 -0
- package/dist/integrations/nutanix.d.ts +18 -0
- package/dist/integrations/nutanix.d.ts.map +1 -0
- package/dist/integrations/nutanix.js +1121 -0
- package/dist/integrations/nutanix.js.map +1 -0
- package/dist/integrations/nutanix.test.d.ts +2 -0
- package/dist/integrations/nutanix.test.d.ts.map +1 -0
- package/dist/integrations/nutanix.test.js +978 -0
- package/dist/integrations/nutanix.test.js.map +1 -0
- package/dist/integrations/proxmox.d.ts +12 -0
- package/dist/integrations/proxmox.d.ts.map +1 -0
- package/dist/integrations/proxmox.js +733 -0
- package/dist/integrations/proxmox.js.map +1 -0
- package/dist/integrations/proxmox.test.d.ts +2 -0
- package/dist/integrations/proxmox.test.d.ts.map +1 -0
- package/dist/integrations/proxmox.test.js +697 -0
- package/dist/integrations/proxmox.test.js.map +1 -0
- package/dist/integrations/servicenow.d.ts +3 -0
- package/dist/integrations/servicenow.d.ts.map +1 -0
- package/dist/integrations/servicenow.js +257 -0
- package/dist/integrations/servicenow.js.map +1 -0
- package/dist/integrations/servicenow.test.d.ts +2 -0
- package/dist/integrations/servicenow.test.d.ts.map +1 -0
- package/dist/integrations/servicenow.test.js +217 -0
- package/dist/integrations/servicenow.test.js.map +1 -0
- package/dist/integrations/splunk.d.ts +9 -0
- package/dist/integrations/splunk.d.ts.map +1 -0
- package/dist/integrations/splunk.js +242 -0
- package/dist/integrations/splunk.js.map +1 -0
- package/dist/integrations/splunk.test.d.ts +2 -0
- package/dist/integrations/splunk.test.d.ts.map +1 -0
- package/dist/integrations/splunk.test.js +323 -0
- package/dist/integrations/splunk.test.js.map +1 -0
- package/dist/mysql/index.d.ts +3 -0
- package/dist/mysql/index.d.ts.map +1 -0
- package/dist/mysql/index.js +13 -0
- package/dist/mysql/index.js.map +1 -0
- package/dist/mysql/manifest.d.ts +3 -0
- package/dist/mysql/manifest.d.ts.map +1 -0
- package/dist/mysql/manifest.js +69 -0
- package/dist/mysql/manifest.js.map +1 -0
- package/dist/mysql/probes/databases-list.d.ts +13 -0
- package/dist/mysql/probes/databases-list.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.js +31 -0
- package/dist/mysql/probes/databases-list.js.map +1 -0
- package/dist/mysql/probes/databases-list.test.d.ts +2 -0
- package/dist/mysql/probes/databases-list.test.d.ts.map +1 -0
- package/dist/mysql/probes/databases-list.test.js +54 -0
- package/dist/mysql/probes/databases-list.test.js.map +1 -0
- package/dist/mysql/probes/processlist.d.ts +18 -0
- package/dist/mysql/probes/processlist.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.js +36 -0
- package/dist/mysql/probes/processlist.js.map +1 -0
- package/dist/mysql/probes/processlist.test.d.ts +2 -0
- package/dist/mysql/probes/processlist.test.d.ts.map +1 -0
- package/dist/mysql/probes/processlist.test.js +41 -0
- package/dist/mysql/probes/processlist.test.js.map +1 -0
- package/dist/mysql/probes/status.d.ts +14 -0
- package/dist/mysql/probes/status.d.ts.map +1 -0
- package/dist/mysql/probes/status.js +40 -0
- package/dist/mysql/probes/status.js.map +1 -0
- package/dist/mysql/probes/status.test.d.ts +2 -0
- package/dist/mysql/probes/status.test.d.ts.map +1 -0
- package/dist/mysql/probes/status.test.js +43 -0
- package/dist/mysql/probes/status.test.js.map +1 -0
- package/dist/nginx/index.d.ts +3 -0
- package/dist/nginx/index.d.ts.map +1 -0
- package/dist/nginx/index.js +13 -0
- package/dist/nginx/index.js.map +1 -0
- package/dist/nginx/manifest.d.ts +3 -0
- package/dist/nginx/manifest.d.ts.map +1 -0
- package/dist/nginx/manifest.js +68 -0
- package/dist/nginx/manifest.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.d.ts +9 -0
- package/dist/nginx/probes/access-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.js +14 -0
- package/dist/nginx/probes/access-log-tail.js.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/access-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/access-log-tail.test.js +40 -0
- package/dist/nginx/probes/access-log-tail.test.js.map +1 -0
- package/dist/nginx/probes/config-test.d.ts +8 -0
- package/dist/nginx/probes/config-test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.js +18 -0
- package/dist/nginx/probes/config-test.js.map +1 -0
- package/dist/nginx/probes/config-test.test.d.ts +2 -0
- package/dist/nginx/probes/config-test.test.d.ts.map +1 -0
- package/dist/nginx/probes/config-test.test.js +35 -0
- package/dist/nginx/probes/config-test.test.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.d.ts +9 -0
- package/dist/nginx/probes/error-log-tail.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.js +14 -0
- package/dist/nginx/probes/error-log-tail.js.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts +2 -0
- package/dist/nginx/probes/error-log-tail.test.d.ts.map +1 -0
- package/dist/nginx/probes/error-log-tail.test.js +34 -0
- package/dist/nginx/probes/error-log-tail.test.js.map +1 -0
- package/dist/postgres/index.d.ts +3 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +13 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/manifest.d.ts +3 -0
- package/dist/postgres/manifest.d.ts.map +1 -0
- package/dist/postgres/manifest.js +90 -0
- package/dist/postgres/manifest.js.map +1 -0
- package/dist/postgres/probes/connections-active.d.ts +17 -0
- package/dist/postgres/probes/connections-active.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.js +37 -0
- package/dist/postgres/probes/connections-active.js.map +1 -0
- package/dist/postgres/probes/connections-active.test.d.ts +2 -0
- package/dist/postgres/probes/connections-active.test.d.ts.map +1 -0
- package/dist/postgres/probes/connections-active.test.js +36 -0
- package/dist/postgres/probes/connections-active.test.js.map +1 -0
- package/dist/postgres/probes/databases-list.d.ts +14 -0
- package/dist/postgres/probes/databases-list.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.js +34 -0
- package/dist/postgres/probes/databases-list.js.map +1 -0
- package/dist/postgres/probes/databases-list.test.d.ts +2 -0
- package/dist/postgres/probes/databases-list.test.d.ts.map +1 -0
- package/dist/postgres/probes/databases-list.test.js +49 -0
- package/dist/postgres/probes/databases-list.test.js.map +1 -0
- package/dist/postgres/probes/query-slow.d.ts +17 -0
- package/dist/postgres/probes/query-slow.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.js +37 -0
- package/dist/postgres/probes/query-slow.js.map +1 -0
- package/dist/postgres/probes/query-slow.test.d.ts +2 -0
- package/dist/postgres/probes/query-slow.test.d.ts.map +1 -0
- package/dist/postgres/probes/query-slow.test.js +30 -0
- package/dist/postgres/probes/query-slow.test.js.map +1 -0
- package/dist/proxmox/index.d.ts +3 -0
- package/dist/proxmox/index.d.ts.map +1 -0
- package/dist/proxmox/index.js +23 -0
- package/dist/proxmox/index.js.map +1 -0
- package/dist/proxmox/manifest.d.ts +3 -0
- package/dist/proxmox/manifest.d.ts.map +1 -0
- package/dist/proxmox/manifest.js +75 -0
- package/dist/proxmox/manifest.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.d.ts +36 -0
- package/dist/proxmox/probes/ceph-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.js +71 -0
- package/dist/proxmox/probes/ceph-status.js.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ceph-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ceph-status.test.js +115 -0
- package/dist/proxmox/probes/ceph-status.test.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.d.ts +31 -0
- package/dist/proxmox/probes/cluster-config.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.js +72 -0
- package/dist/proxmox/probes/cluster-config.js.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts +2 -0
- package/dist/proxmox/probes/cluster-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/cluster-config.test.js +107 -0
- package/dist/proxmox/probes/cluster-config.test.js.map +1 -0
- package/dist/proxmox/probes/ha-status.d.ts +18 -0
- package/dist/proxmox/probes/ha-status.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.js +38 -0
- package/dist/proxmox/probes/ha-status.js.map +1 -0
- package/dist/proxmox/probes/ha-status.test.d.ts +2 -0
- package/dist/proxmox/probes/ha-status.test.d.ts.map +1 -0
- package/dist/proxmox/probes/ha-status.test.js +66 -0
- package/dist/proxmox/probes/ha-status.test.js.map +1 -0
- package/dist/proxmox/probes/lvm.d.ts +35 -0
- package/dist/proxmox/probes/lvm.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.js +75 -0
- package/dist/proxmox/probes/lvm.js.map +1 -0
- package/dist/proxmox/probes/lvm.test.d.ts +2 -0
- package/dist/proxmox/probes/lvm.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lvm.test.js +128 -0
- package/dist/proxmox/probes/lvm.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.d.ts +29 -0
- package/dist/proxmox/probes/lxc-config.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.js +67 -0
- package/dist/proxmox/probes/lxc-config.js.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-config.test.js +77 -0
- package/dist/proxmox/probes/lxc-config.test.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.d.ts +20 -0
- package/dist/proxmox/probes/lxc-list.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.js +49 -0
- package/dist/proxmox/probes/lxc-list.js.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts +2 -0
- package/dist/proxmox/probes/lxc-list.test.d.ts.map +1 -0
- package/dist/proxmox/probes/lxc-list.test.js +51 -0
- package/dist/proxmox/probes/lxc-list.test.js.map +1 -0
- package/dist/proxmox/probes/vm-config.d.ts +21 -0
- package/dist/proxmox/probes/vm-config.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.js +58 -0
- package/dist/proxmox/probes/vm-config.js.map +1 -0
- package/dist/proxmox/probes/vm-config.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-config.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-config.test.js +80 -0
- package/dist/proxmox/probes/vm-config.test.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.d.ts +16 -0
- package/dist/proxmox/probes/vm-locks.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.js +35 -0
- package/dist/proxmox/probes/vm-locks.js.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts +2 -0
- package/dist/proxmox/probes/vm-locks.test.d.ts.map +1 -0
- package/dist/proxmox/probes/vm-locks.test.js +54 -0
- package/dist/proxmox/probes/vm-locks.test.js.map +1 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +13 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/redis/manifest.d.ts +3 -0
- package/dist/redis/manifest.d.ts.map +1 -0
- package/dist/redis/manifest.js +51 -0
- package/dist/redis/manifest.js.map +1 -0
- package/dist/redis/probes/info.d.ts +15 -0
- package/dist/redis/probes/info.d.ts.map +1 -0
- package/dist/redis/probes/info.js +32 -0
- package/dist/redis/probes/info.js.map +1 -0
- package/dist/redis/probes/info.test.d.ts +2 -0
- package/dist/redis/probes/info.test.d.ts.map +1 -0
- package/dist/redis/probes/info.test.js +64 -0
- package/dist/redis/probes/info.test.js.map +1 -0
- package/dist/redis/probes/keys-count.d.ts +13 -0
- package/dist/redis/probes/keys-count.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.js +24 -0
- package/dist/redis/probes/keys-count.js.map +1 -0
- package/dist/redis/probes/keys-count.test.d.ts +2 -0
- package/dist/redis/probes/keys-count.test.d.ts.map +1 -0
- package/dist/redis/probes/keys-count.test.js +37 -0
- package/dist/redis/probes/keys-count.test.js.map +1 -0
- package/dist/redis/probes/memory-usage.d.ts +16 -0
- package/dist/redis/probes/memory-usage.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.js +31 -0
- package/dist/redis/probes/memory-usage.js.map +1 -0
- package/dist/redis/probes/memory-usage.test.d.ts +2 -0
- package/dist/redis/probes/memory-usage.test.d.ts.map +1 -0
- package/dist/redis/probes/memory-usage.test.js +48 -0
- package/dist/redis/probes/memory-usage.test.js.map +1 -0
- package/dist/runbooks/nutanix.d.ts +3 -0
- package/dist/runbooks/nutanix.d.ts.map +1 -0
- package/dist/runbooks/nutanix.js +619 -0
- package/dist/runbooks/nutanix.js.map +1 -0
- package/dist/runbooks/nutanix.test.d.ts +2 -0
- package/dist/runbooks/nutanix.test.d.ts.map +1 -0
- package/dist/runbooks/nutanix.test.js +971 -0
- package/dist/runbooks/nutanix.test.js.map +1 -0
- package/dist/runbooks/proxmox.d.ts +3 -0
- package/dist/runbooks/proxmox.d.ts.map +1 -0
- package/dist/runbooks/proxmox.js +451 -0
- package/dist/runbooks/proxmox.js.map +1 -0
- package/dist/runbooks/proxmox.test.d.ts +2 -0
- package/dist/runbooks/proxmox.test.d.ts.map +1 -0
- package/dist/runbooks/proxmox.test.js +700 -0
- package/dist/runbooks/proxmox.test.js.map +1 -0
- package/dist/signatures.d.ts +2 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +2 -0
- package/dist/signatures.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +6 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +10 -1
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +60 -6
- package/src/integrations/citrix.test.ts +592 -0
- package/src/integrations/citrix.ts +557 -0
- package/src/integrations/graph.test.ts +478 -0
- package/src/integrations/graph.ts +413 -0
- package/src/integrations/httpbin.ts +72 -0
- package/src/integrations/nutanix.test.ts +1508 -0
- package/src/integrations/nutanix.ts +1460 -0
- package/src/integrations/proxmox.test.ts +1020 -0
- package/src/integrations/proxmox.ts +989 -0
- package/src/integrations/servicenow.test.ts +314 -0
- package/src/integrations/servicenow.ts +285 -0
- package/src/integrations/splunk.test.ts +440 -0
- package/src/integrations/splunk.ts +356 -0
- package/src/mysql/index.ts +14 -0
- package/src/mysql/manifest.ts +70 -0
- package/src/mysql/probes/databases-list.test.ts +62 -0
- package/src/mysql/probes/databases-list.ts +45 -0
- package/src/mysql/probes/processlist.test.ts +47 -0
- package/src/mysql/probes/processlist.ts +55 -0
- package/src/mysql/probes/status.test.ts +50 -0
- package/src/mysql/probes/status.ts +56 -0
- package/src/nginx/index.ts +14 -0
- package/src/nginx/manifest.ts +69 -0
- package/src/nginx/probes/access-log-tail.test.ts +51 -0
- package/src/nginx/probes/access-log-tail.ts +23 -0
- package/src/nginx/probes/config-test.test.ts +47 -0
- package/src/nginx/probes/config-test.ts +24 -0
- package/src/nginx/probes/error-log-tail.test.ts +44 -0
- package/src/nginx/probes/error-log-tail.ts +23 -0
- package/src/postgres/index.ts +14 -0
- package/src/postgres/manifest.ts +91 -0
- package/src/postgres/probes/connections-active.test.ts +42 -0
- package/src/postgres/probes/connections-active.ts +55 -0
- package/src/postgres/probes/databases-list.test.ts +57 -0
- package/src/postgres/probes/databases-list.ts +49 -0
- package/src/postgres/probes/query-slow.test.ts +37 -0
- package/src/postgres/probes/query-slow.ts +55 -0
- package/src/proxmox/index.ts +24 -0
- package/src/proxmox/manifest.ts +76 -0
- package/src/proxmox/probes/ceph-status.test.ts +126 -0
- package/src/proxmox/probes/ceph-status.ts +116 -0
- package/src/proxmox/probes/cluster-config.test.ts +118 -0
- package/src/proxmox/probes/cluster-config.ts +97 -0
- package/src/proxmox/probes/ha-status.test.ts +76 -0
- package/src/proxmox/probes/ha-status.ts +56 -0
- package/src/proxmox/probes/lvm.test.ts +140 -0
- package/src/proxmox/probes/lvm.ts +121 -0
- package/src/proxmox/probes/lxc-config.test.ts +89 -0
- package/src/proxmox/probes/lxc-config.ts +90 -0
- package/src/proxmox/probes/lxc-list.test.ts +60 -0
- package/src/proxmox/probes/lxc-list.ts +67 -0
- package/src/proxmox/probes/vm-config.test.ts +93 -0
- package/src/proxmox/probes/vm-config.ts +77 -0
- package/src/proxmox/probes/vm-locks.test.ts +63 -0
- package/src/proxmox/probes/vm-locks.ts +49 -0
- package/src/redis/index.ts +14 -0
- package/src/redis/manifest.ts +52 -0
- package/src/redis/probes/info.test.ts +73 -0
- package/src/redis/probes/info.ts +46 -0
- package/src/redis/probes/keys-count.test.ts +44 -0
- package/src/redis/probes/keys-count.ts +38 -0
- package/src/redis/probes/memory-usage.test.ts +54 -0
- package/src/redis/probes/memory-usage.ts +46 -0
- package/src/runbooks/nutanix.test.ts +1138 -0
- package/src/runbooks/nutanix.ts +941 -0
- package/src/runbooks/proxmox.test.ts +838 -0
- package/src/runbooks/proxmox.ts +626 -0
- package/src/signatures.ts +1 -0
- package/src/types.ts +62 -0
- package/src/validation.ts +21 -1
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import type { IntegrationConfig, IntegrationCredentials } from '@sonde/shared';
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { buildAuthHeaders, splunkGet, splunkPack, splunkPost } from './splunk.js';
|
|
4
|
+
|
|
5
|
+
const splunkConfig: IntegrationConfig = {
|
|
6
|
+
endpoint: 'https://splunk.company.com:8089',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const tokenCreds: IntegrationCredentials = {
|
|
10
|
+
packName: 'splunk',
|
|
11
|
+
authMethod: 'bearer_token',
|
|
12
|
+
credentials: { splunkToken: 'my-splunk-token-abc' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const basicCreds: IntegrationCredentials = {
|
|
16
|
+
packName: 'splunk',
|
|
17
|
+
authMethod: 'api_key',
|
|
18
|
+
credentials: { username: 'sonde_svc', password: 'secret123' },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handler = (name: string) => {
|
|
22
|
+
const h = splunkPack.handlers[name];
|
|
23
|
+
if (!h) throw new Error(`Handler ${name} not found`);
|
|
24
|
+
return h;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function callArgs(fn: ReturnType<typeof vi.fn>, index: number): unknown[] {
|
|
28
|
+
const args = fn.mock.calls[index];
|
|
29
|
+
if (!args) throw new Error(`No call at index ${index}`);
|
|
30
|
+
return args;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Mock a Splunk JSON response */
|
|
34
|
+
function mockSplunkResponse(body: unknown, status = 200) {
|
|
35
|
+
return vi.fn().mockResolvedValue(
|
|
36
|
+
new Response(JSON.stringify(body), {
|
|
37
|
+
status,
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function mockFetchError(status: number) {
|
|
44
|
+
return vi.fn().mockResolvedValue(new Response('Error', { status, statusText: 'Error' }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe('splunk pack', () => {
|
|
48
|
+
describe('auth headers', () => {
|
|
49
|
+
it('uses Bearer token for token auth', () => {
|
|
50
|
+
const headers = buildAuthHeaders(tokenCreds);
|
|
51
|
+
expect(headers.Authorization).toBe('Bearer my-splunk-token-abc');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('uses Basic auth for username:password', () => {
|
|
55
|
+
const headers = buildAuthHeaders(basicCreds);
|
|
56
|
+
const expected = `Basic ${Buffer.from('sonde_svc:secret123').toString('base64')}`;
|
|
57
|
+
expect(headers.Authorization).toBe(expected);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('returns empty headers when credentials are missing', () => {
|
|
61
|
+
const emptyCreds: IntegrationCredentials = {
|
|
62
|
+
packName: 'splunk',
|
|
63
|
+
authMethod: 'api_key',
|
|
64
|
+
credentials: {},
|
|
65
|
+
};
|
|
66
|
+
const headers = buildAuthHeaders(emptyCreds);
|
|
67
|
+
expect(headers.Authorization).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('splunkGet', () => {
|
|
72
|
+
it('appends output_mode=json to all requests', async () => {
|
|
73
|
+
const fetchFn = mockSplunkResponse({ entry: [] });
|
|
74
|
+
await splunkGet('/services/server/info', splunkConfig, tokenCreds, fetchFn);
|
|
75
|
+
|
|
76
|
+
const [url] = callArgs(fetchFn, 0);
|
|
77
|
+
expect(url).toContain('output_mode=json');
|
|
78
|
+
expect(url).toContain('/services/server/info');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('throws on non-200 response', async () => {
|
|
82
|
+
const fetchFn = mockFetchError(401);
|
|
83
|
+
await expect(
|
|
84
|
+
splunkGet('/services/server/info', splunkConfig, tokenCreds, fetchFn),
|
|
85
|
+
).rejects.toThrow('Splunk API returned 401');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('splunkPost', () => {
|
|
90
|
+
it('sends URL-encoded form data with output_mode=json', async () => {
|
|
91
|
+
const fetchFn = mockSplunkResponse({ sid: 'job-123' });
|
|
92
|
+
await splunkPost(
|
|
93
|
+
'/services/search/v2/jobs',
|
|
94
|
+
{ search: 'index=main | head 10', earliest_time: '-1h' },
|
|
95
|
+
splunkConfig,
|
|
96
|
+
tokenCreds,
|
|
97
|
+
fetchFn,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const [url, init] = callArgs(fetchFn, 0);
|
|
101
|
+
expect(url).toContain('output_mode=json');
|
|
102
|
+
expect((init as { method: string }).method).toBe('POST');
|
|
103
|
+
expect((init as { headers: Record<string, string> }).headers['Content-Type']).toBe(
|
|
104
|
+
'application/x-www-form-urlencoded',
|
|
105
|
+
);
|
|
106
|
+
const body = (init as { body: string }).body;
|
|
107
|
+
expect(body).toContain('search=');
|
|
108
|
+
expect(body).toContain('earliest_time=');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('throws on non-200 response', async () => {
|
|
112
|
+
const fetchFn = mockFetchError(403);
|
|
113
|
+
await expect(
|
|
114
|
+
splunkPost(
|
|
115
|
+
'/services/search/v2/jobs',
|
|
116
|
+
{ search: 'index=main' },
|
|
117
|
+
splunkConfig,
|
|
118
|
+
tokenCreds,
|
|
119
|
+
fetchFn,
|
|
120
|
+
),
|
|
121
|
+
).rejects.toThrow('Splunk API returned 403');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('testConnection', () => {
|
|
126
|
+
it('returns true when GET /services/server/info succeeds', async () => {
|
|
127
|
+
const fetchFn = mockSplunkResponse({
|
|
128
|
+
entry: [{ content: { serverName: 'splunk-01', version: '9.1.0' } }],
|
|
129
|
+
});
|
|
130
|
+
const result = await splunkPack.testConnection(splunkConfig, tokenCreds, fetchFn);
|
|
131
|
+
expect(result).toBe(true);
|
|
132
|
+
|
|
133
|
+
const [url] = callArgs(fetchFn, 0);
|
|
134
|
+
expect(url).toContain('/services/server/info');
|
|
135
|
+
expect(url).toContain('output_mode=json');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('returns false on non-200', async () => {
|
|
139
|
+
const fetchFn = mockFetchError(401);
|
|
140
|
+
const result = await splunkPack.testConnection(splunkConfig, tokenCreds, fetchFn);
|
|
141
|
+
expect(result).toBe(false);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('returns false on network error', async () => {
|
|
145
|
+
const fetchFn = vi.fn().mockRejectedValue(new Error('ECONNREFUSED'));
|
|
146
|
+
const result = await splunkPack.testConnection(splunkConfig, tokenCreds, fetchFn);
|
|
147
|
+
expect(result).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe('search', () => {
|
|
152
|
+
it('creates a job, polls, and fetches results', async () => {
|
|
153
|
+
let callCount = 0;
|
|
154
|
+
const fetchFn = vi.fn().mockImplementation(() => {
|
|
155
|
+
callCount++;
|
|
156
|
+
if (callCount === 1) {
|
|
157
|
+
// POST create job
|
|
158
|
+
return Promise.resolve(
|
|
159
|
+
new Response(JSON.stringify({ sid: 'job-abc' }), {
|
|
160
|
+
status: 200,
|
|
161
|
+
headers: { 'Content-Type': 'application/json' },
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (callCount === 2) {
|
|
166
|
+
// GET poll — DONE
|
|
167
|
+
return Promise.resolve(
|
|
168
|
+
new Response(
|
|
169
|
+
JSON.stringify({
|
|
170
|
+
entry: [{ content: { dispatchState: 'DONE' } }],
|
|
171
|
+
}),
|
|
172
|
+
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
// GET results
|
|
177
|
+
return Promise.resolve(
|
|
178
|
+
new Response(
|
|
179
|
+
JSON.stringify({
|
|
180
|
+
results: [{ _raw: 'error log line 1' }, { _raw: 'error log line 2' }],
|
|
181
|
+
}),
|
|
182
|
+
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const result = (await handler('search')(
|
|
188
|
+
{ query: 'search index=main error | head 10', earliest: '-1h', max_results: 50 },
|
|
189
|
+
splunkConfig,
|
|
190
|
+
tokenCreds,
|
|
191
|
+
fetchFn,
|
|
192
|
+
)) as { results: unknown[]; resultCount: number; sid: string; executionTimeMs: number };
|
|
193
|
+
|
|
194
|
+
expect(result.sid).toBe('job-abc');
|
|
195
|
+
expect(result.resultCount).toBe(2);
|
|
196
|
+
expect(result.results).toHaveLength(2);
|
|
197
|
+
expect(result.executionTimeMs).toBeGreaterThanOrEqual(0);
|
|
198
|
+
|
|
199
|
+
// Verify POST to v2 API
|
|
200
|
+
const [postUrl, postInit] = callArgs(fetchFn, 0);
|
|
201
|
+
expect(postUrl).toContain('/services/search/v2/jobs');
|
|
202
|
+
expect((postInit as { method: string }).method).toBe('POST');
|
|
203
|
+
expect((postInit as { headers: Record<string, string> }).headers['Content-Type']).toBe(
|
|
204
|
+
'application/x-www-form-urlencoded',
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
// Verify results fetch includes count param
|
|
208
|
+
const [resultsUrl] = callArgs(fetchFn, 2);
|
|
209
|
+
expect(resultsUrl).toContain('/services/search/v2/jobs/job-abc/results');
|
|
210
|
+
expect(resultsUrl).toContain('count=50');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('throws when query is missing', async () => {
|
|
214
|
+
const fetchFn = mockSplunkResponse({});
|
|
215
|
+
await expect(handler('search')({}, splunkConfig, tokenCreds, fetchFn)).rejects.toThrow(
|
|
216
|
+
'query parameter is required',
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('throws when no sid returned', async () => {
|
|
221
|
+
const fetchFn = mockSplunkResponse({});
|
|
222
|
+
await expect(
|
|
223
|
+
handler('search')({ query: 'search index=main' }, splunkConfig, tokenCreds, fetchFn),
|
|
224
|
+
).rejects.toThrow('Splunk did not return a search job ID');
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('throws when search job fails', async () => {
|
|
228
|
+
let callCount = 0;
|
|
229
|
+
const fetchFn = vi.fn().mockImplementation(() => {
|
|
230
|
+
callCount++;
|
|
231
|
+
if (callCount === 1) {
|
|
232
|
+
return Promise.resolve(
|
|
233
|
+
new Response(JSON.stringify({ sid: 'job-fail' }), {
|
|
234
|
+
status: 200,
|
|
235
|
+
headers: { 'Content-Type': 'application/json' },
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return Promise.resolve(
|
|
240
|
+
new Response(JSON.stringify({ entry: [{ content: { dispatchState: 'FAILED' } }] }), {
|
|
241
|
+
status: 200,
|
|
242
|
+
headers: { 'Content-Type': 'application/json' },
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
await expect(
|
|
248
|
+
handler('search')({ query: 'search index=main' }, splunkConfig, tokenCreds, fetchFn),
|
|
249
|
+
).rejects.toThrow('Splunk search job failed');
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
describe('indexes', () => {
|
|
254
|
+
it('returns index metadata', async () => {
|
|
255
|
+
const fetchFn = mockSplunkResponse({
|
|
256
|
+
entry: [
|
|
257
|
+
{
|
|
258
|
+
name: 'main',
|
|
259
|
+
content: {
|
|
260
|
+
currentDBSizeMB: 1024,
|
|
261
|
+
totalEventCount: '5000000',
|
|
262
|
+
minTime: '2025-01-01T00:00:00Z',
|
|
263
|
+
maxTime: '2026-02-17T12:00:00Z',
|
|
264
|
+
disabled: false,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: '_internal',
|
|
269
|
+
content: {
|
|
270
|
+
currentDBSizeMB: 256,
|
|
271
|
+
totalEventCount: '100000',
|
|
272
|
+
minTime: '2025-06-01T00:00:00Z',
|
|
273
|
+
maxTime: '2026-02-17T12:00:00Z',
|
|
274
|
+
disabled: false,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const result = (await handler('indexes')({}, splunkConfig, tokenCreds, fetchFn)) as {
|
|
281
|
+
indexes: Array<{ name: string; currentSizeMB: number; totalEventCount: string }>;
|
|
282
|
+
count: number;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
expect(result.count).toBe(2);
|
|
286
|
+
expect(result.indexes[0]?.name).toBe('main');
|
|
287
|
+
expect(result.indexes[0]?.currentSizeMB).toBe(1024);
|
|
288
|
+
expect(result.indexes[0]?.totalEventCount).toBe('5000000');
|
|
289
|
+
expect(result.indexes[1]?.name).toBe('_internal');
|
|
290
|
+
|
|
291
|
+
const [url] = callArgs(fetchFn, 0);
|
|
292
|
+
expect(url).toContain('/services/data/indexes');
|
|
293
|
+
expect(url).toContain('count=0');
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('saved_searches', () => {
|
|
298
|
+
it('returns saved searches', async () => {
|
|
299
|
+
const fetchFn = mockSplunkResponse({
|
|
300
|
+
entry: [
|
|
301
|
+
{
|
|
302
|
+
name: 'Error Alerts',
|
|
303
|
+
content: {
|
|
304
|
+
search: 'index=main level=error | stats count by host',
|
|
305
|
+
cron_schedule: '*/5 * * * *',
|
|
306
|
+
disabled: false,
|
|
307
|
+
triggered_alert_count: 42,
|
|
308
|
+
},
|
|
309
|
+
updated: '2026-02-17T10:00:00Z',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'Daily Summary',
|
|
313
|
+
content: {
|
|
314
|
+
search: 'index=main | stats count',
|
|
315
|
+
cron_schedule: '0 0 * * *',
|
|
316
|
+
disabled: true,
|
|
317
|
+
triggered_alert_count: 0,
|
|
318
|
+
},
|
|
319
|
+
updated: '2026-01-01T00:00:00Z',
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const result = (await handler('saved_searches')({}, splunkConfig, tokenCreds, fetchFn)) as {
|
|
325
|
+
savedSearches: Array<{ name: string; cronSchedule: string | null; disabled: boolean }>;
|
|
326
|
+
count: number;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
expect(result.count).toBe(2);
|
|
330
|
+
expect(result.savedSearches[0]?.name).toBe('Error Alerts');
|
|
331
|
+
expect(result.savedSearches[0]?.cronSchedule).toBe('*/5 * * * *');
|
|
332
|
+
expect(result.savedSearches[1]?.disabled).toBe(true);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('filters by name when provided', async () => {
|
|
336
|
+
const fetchFn = mockSplunkResponse({
|
|
337
|
+
entry: [
|
|
338
|
+
{
|
|
339
|
+
name: 'Error Alerts',
|
|
340
|
+
content: { search: 'index=main level=error', disabled: false },
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: 'Daily Summary',
|
|
344
|
+
content: { search: 'index=main | stats count', disabled: false },
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const result = (await handler('saved_searches')(
|
|
350
|
+
{ name: 'error' },
|
|
351
|
+
splunkConfig,
|
|
352
|
+
tokenCreds,
|
|
353
|
+
fetchFn,
|
|
354
|
+
)) as { savedSearches: Array<{ name: string }>; count: number };
|
|
355
|
+
|
|
356
|
+
expect(result.count).toBe(1);
|
|
357
|
+
expect(result.savedSearches[0]?.name).toBe('Error Alerts');
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
describe('health', () => {
|
|
362
|
+
it('returns overall health and per-feature breakdown', async () => {
|
|
363
|
+
const fetchFn = mockSplunkResponse({
|
|
364
|
+
entry: [
|
|
365
|
+
{
|
|
366
|
+
content: {
|
|
367
|
+
health: 'green',
|
|
368
|
+
features: {
|
|
369
|
+
'File Monitor Input': { health: 'green' },
|
|
370
|
+
Indexer: { health: 'green' },
|
|
371
|
+
'Search Scheduler': { health: 'yellow' },
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
const result = (await handler('health')({}, splunkConfig, tokenCreds, fetchFn)) as {
|
|
379
|
+
overallHealth: string;
|
|
380
|
+
features: Array<{ name: string; health: string }>;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
expect(result.overallHealth).toBe('green');
|
|
384
|
+
expect(result.features).toHaveLength(3);
|
|
385
|
+
|
|
386
|
+
const scheduler = result.features.find((f) => f.name === 'Search Scheduler');
|
|
387
|
+
expect(scheduler?.health).toBe('yellow');
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('handles missing features gracefully', async () => {
|
|
391
|
+
const fetchFn = mockSplunkResponse({ entry: [{ content: { health: 'red' } }] });
|
|
392
|
+
|
|
393
|
+
const result = (await handler('health')({}, splunkConfig, tokenCreds, fetchFn)) as {
|
|
394
|
+
overallHealth: string;
|
|
395
|
+
features: unknown[];
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
expect(result.overallHealth).toBe('red');
|
|
399
|
+
expect(result.features).toHaveLength(0);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe('manifest', () => {
|
|
404
|
+
it('has correct name and probe count', () => {
|
|
405
|
+
expect(splunkPack.manifest.name).toBe('splunk');
|
|
406
|
+
expect(splunkPack.manifest.probes).toHaveLength(4);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('all handlers match manifest probes', () => {
|
|
410
|
+
const probeNames = splunkPack.manifest.probes.map((p) => p.name);
|
|
411
|
+
const handlerNames = Object.keys(splunkPack.handlers);
|
|
412
|
+
expect(handlerNames.sort()).toEqual(probeNames.sort());
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('has correct timeouts (60s for search, 15s for others)', () => {
|
|
416
|
+
const probeMap = new Map(splunkPack.manifest.probes.map((p) => [p.name, p.timeout]));
|
|
417
|
+
expect(probeMap.get('search')).toBe(60000);
|
|
418
|
+
expect(probeMap.get('indexes')).toBe(15000);
|
|
419
|
+
expect(probeMap.get('saved_searches')).toBe(15000);
|
|
420
|
+
expect(probeMap.get('health')).toBe(15000);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('has observability runbook', () => {
|
|
424
|
+
expect(splunkPack.manifest.runbook).toEqual({
|
|
425
|
+
category: 'observability',
|
|
426
|
+
probes: ['health', 'indexes'],
|
|
427
|
+
parallel: true,
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
describe('error handling', () => {
|
|
433
|
+
it('throws on non-200 API response for probes', async () => {
|
|
434
|
+
const fetchFn = mockFetchError(403);
|
|
435
|
+
await expect(handler('indexes')({}, splunkConfig, tokenCreds, fetchFn)).rejects.toThrow(
|
|
436
|
+
'Splunk API returned 403',
|
|
437
|
+
);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
});
|