-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a107c9
commit e2143e9
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const ruleYaml = `__praeco_query_builder: '{"query":{"logicalOperator":"all","children":[]}}' | ||
alert: | ||
- lark | ||
alert_subject: this is a test subject | ||
alert_subject_args: [] | ||
alert_text: this is a test body | ||
alert_text_args: [] | ||
alert_text_type: alert_text_only | ||
doc_type: syslog | ||
filter: | ||
- query: | ||
query_string: | ||
query: '@timestamp:*' | ||
import: BaseRule.config | ||
index: hannibal-* | ||
is_enabled: false | ||
name: test123 | ||
num_events: 10000 | ||
query_key: beat.hostname | ||
realert: | ||
minutes: 5 | ||
timeframe: | ||
minutes: 5 | ||
timestamp_field: '@timestamp' | ||
timestamp_type: iso | ||
type: frequency | ||
use_count_query: true | ||
use_strftime_index: false | ||
lark_bot_id: abcdefg | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect } from 'chai'; | ||
import store from '@/store'; | ||
import { mockAxios } from '../../setup'; | ||
import { ruleYaml } from '../../mockData/alert/ruleDataLark.js'; | ||
|
||
mockAxios.onGet('/api/rules/test123').reply(200, { yaml: ruleYaml }); | ||
|
||
describe('Lark YAML parsing', () => { | ||
it('renders the correct yaml', async () => { | ||
await store.dispatch('config/load', { type: 'rules', path: 'test123' }); | ||
|
||
let yaml = store.getters['config/yaml'](); | ||
|
||
let expected = `__praeco_full_path: "test123" | ||
__praeco_query_builder: "{\\"query\\":{\\"logicalOperator\\":\\"all\\",\\"children\\":[]}}" | ||
alert: | ||
- "lark" | ||
alert_subject: "this is a test subject" | ||
alert_text: "this is a test body" | ||
alert_text_type: "alert_text_only" | ||
doc_type: "syslog" | ||
filter: | ||
- query: | ||
query_string: | ||
query: "@timestamp:*" | ||
generate_kibana_discover_url: false | ||
import: "BaseRule.config" | ||
index: "hannibal-*" | ||
is_enabled: false | ||
lark_bot_id: "abcdefg" | ||
lark_msgtype: "text" | ||
match_enhancements: [] | ||
name: "test123" | ||
num_events: 10000 | ||
query_key: | ||
- "beat.hostname" | ||
realert: | ||
minutes: 5 | ||
terms_size: 50 | ||
timeframe: | ||
minutes: 5 | ||
timestamp_field: "@timestamp" | ||
timestamp_type: "iso" | ||
type: "frequency" | ||
use_count_query: true | ||
use_strftime_index: false | ||
`; | ||
|
||
return expect(yaml).to.equal(expected); | ||
}); | ||
}); |