Skip to content

Commit 1e0d246

Browse files
committed
refactor
1 parent ecc8240 commit 1e0d246

3 files changed

Lines changed: 94 additions & 11 deletions

File tree

x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/ml_conditional_links/ml_conditional_links.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import {
1818
mlHostMultiHostKqlQuery,
1919
mlHostVariableHostNullKqlQuery,
2020
mlHostVariableHostKqlQuery,
21-
} from '../../lib/ml_conditional_links';
22-
import { loginAndWaitForPage } from '../../lib/util/helpers';
23-
import { KQL_INPUT } from '../../lib/url_state';
21+
} from '../../../urls/ml_conditional_links';
22+
import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login';
23+
import { KQL_INPUT } from '../../../screens/header';
2424

2525
describe('ml conditional links', () => {
2626
it('sets the KQL from a single IP with a value for the query', () => {
2727
loginAndWaitForPage(mlNetworkSingleIpKqlQuery);
28-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
28+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
2929
'have.attr',
3030
'value',
3131
'(process.name: "conhost.exe" or process.name: "sc.exe")'
@@ -34,7 +34,7 @@ describe('ml conditional links', () => {
3434

3535
it('sets the KQL from a multiple IPs with a null for the query', () => {
3636
loginAndWaitForPage(mlNetworkMultipleIpNullKqlQuery);
37-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
37+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
3838
'have.attr',
3939
'value',
4040
'((source.ip: "127.0.0.1" or destination.ip: "127.0.0.1") or (source.ip: "127.0.0.2" or destination.ip: "127.0.0.2"))'
@@ -43,7 +43,7 @@ describe('ml conditional links', () => {
4343

4444
it('sets the KQL from a multiple IPs with a value for the query', () => {
4545
loginAndWaitForPage(mlNetworkMultipleIpKqlQuery);
46-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
46+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
4747
'have.attr',
4848
'value',
4949
'((source.ip: "127.0.0.1" or destination.ip: "127.0.0.1") or (source.ip: "127.0.0.2" or destination.ip: "127.0.0.2")) and ((process.name: "conhost.exe" or process.name: "sc.exe"))'
@@ -52,7 +52,7 @@ describe('ml conditional links', () => {
5252

5353
it('sets the KQL from a $ip$ with a value for the query', () => {
5454
loginAndWaitForPage(mlNetworkKqlQuery);
55-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
55+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
5656
'have.attr',
5757
'value',
5858
'(process.name: "conhost.exe" or process.name: "sc.exe")'
@@ -61,7 +61,7 @@ describe('ml conditional links', () => {
6161

6262
it('sets the KQL from a single host name with a value for query', () => {
6363
loginAndWaitForPage(mlHostSingleHostKqlQuery);
64-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
64+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
6565
'have.attr',
6666
'value',
6767
'(process.name: "conhost.exe" or process.name: "sc.exe")'
@@ -70,7 +70,7 @@ describe('ml conditional links', () => {
7070

7171
it('sets the KQL from a multiple host names with null for query', () => {
7272
loginAndWaitForPage(mlHostMultiHostNullKqlQuery);
73-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
73+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
7474
'have.attr',
7575
'value',
7676
'(host.name: "siem-windows" or host.name: "siem-suricata")'
@@ -79,7 +79,7 @@ describe('ml conditional links', () => {
7979

8080
it('sets the KQL from a multiple host names with a value for query', () => {
8181
loginAndWaitForPage(mlHostMultiHostKqlQuery);
82-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
82+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
8383
'have.attr',
8484
'value',
8585
'(host.name: "siem-windows" or host.name: "siem-suricata") and ((process.name: "conhost.exe" or process.name: "sc.exe"))'
@@ -88,7 +88,7 @@ describe('ml conditional links', () => {
8888

8989
it('sets the KQL from a undefined/null host name but with a value for query', () => {
9090
loginAndWaitForPage(mlHostVariableHostKqlQuery);
91-
cy.get(KQL_INPUT, { timeout: 5000 }).should(
91+
cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should(
9292
'have.attr',
9393
'value',
9494
'(process.name: "conhost.exe" or process.name: "sc.exe")'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export const KQL_INPUT = '[data-test-subj="queryInput"]';
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/*
8+
* These links are for different test scenarios that try and capture different drill downs into
9+
* ml-network and ml-hosts and are of the flavor of testing:
10+
* A filter being null: (query:!n)
11+
* A filter being set with single values: query=(query:%27process.name%20:%20%22conhost.exe%22%27,language:kuery)
12+
* A filter being set with multiple values: query=(query:%27process.name%20:%20%22conhost.exe,sc.exe%22%27,language:kuery)
13+
* A filter containing variables not replaced: query=(query:%27process.name%20:%20%$process.name$%22%27,language:kuery)
14+
*
15+
* In different combination with:
16+
* network not being set: $ip$
17+
* host not being set: $host.name$
18+
* ...or...
19+
* network being set normally: 127.0.0.1
20+
* host being set normally: suricata-iowa
21+
* ...or...
22+
* network having multiple values: 127.0.0.1,127.0.0.2
23+
* host having multiple values: suricata-iowa,siem-windows
24+
*/
25+
26+
// Single IP with a null for the Query:
27+
export const mlNetworkSingleIpNullKqlQuery =
28+
"/app/siem#/ml-network/ip/127.0.0.1?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
29+
30+
// Single IP with a value for the Query:
31+
export const mlNetworkSingleIpKqlQuery =
32+
"/app/siem#/ml-network/ip/127.0.0.1?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
33+
34+
// Multiple IPs with a null for the Query:
35+
export const mlNetworkMultipleIpNullKqlQuery =
36+
"/app/siem#/ml-network/ip/127.0.0.1,127.0.0.2?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
37+
38+
// Multiple IPs with a value for the Query:
39+
export const mlNetworkMultipleIpKqlQuery =
40+
"/app/siem#/ml-network/ip/127.0.0.1,127.0.0.2?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
41+
42+
// $ip$ with a null Query:
43+
export const mlNetworkNullKqlQuery =
44+
"/app/siem#/ml-network/ip/$ip$?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
45+
46+
// $ip$ with a value for the Query:
47+
export const mlNetworkKqlQuery =
48+
"/app/siem#/ml-network/ip/$ip$?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))";
49+
50+
// Single host name with a null for the Query:
51+
export const mlHostSingleHostNullKqlQuery =
52+
"/app/siem#/ml-hosts/siem-windows?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
53+
54+
// Single host name with a variable in the Query:
55+
export const mlHostSingleHostKqlQueryVariable =
56+
"/app/siem#/ml-hosts/siem-windows?query=(language:kuery,query:'process.name%20:%20%22$process.name$%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
57+
58+
// Single host name with a value for Query:
59+
export const mlHostSingleHostKqlQuery =
60+
"/app/siem#/ml-hosts/siem-windows?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
61+
62+
// Multiple host names with null for Query:
63+
export const mlHostMultiHostNullKqlQuery =
64+
"/app/siem#/ml-hosts/siem-windows,siem-suricata?query=!n&&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
65+
66+
// Multiple host names with a value for Query:
67+
export const mlHostMultiHostKqlQuery =
68+
"/app/siem#/ml-hosts/siem-windows,siem-suricata?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
69+
70+
// Undefined/null host name with a null for the KQL:
71+
export const mlHostVariableHostNullKqlQuery =
72+
"/app/siem#/ml-hosts/$host.name$?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";
73+
74+
// Undefined/null host name but with a value for Query:
75+
export const mlHostVariableHostKqlQuery =
76+
"/app/siem#/ml-hosts/$host.name$?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))";

0 commit comments

Comments
 (0)