From d59f1b988cfd76308c242670b7014d6deaad9da6 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Mon, 7 Feb 2022 18:08:35 +0200 Subject: [PATCH] Move assertWarningHeader to validations --- .../test/cases_api_integration/common/lib/utils.ts | 13 ------------- .../cases_api_integration/common/lib/validation.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/test/cases_api_integration/common/lib/utils.ts b/x-pack/test/cases_api_integration/common/lib/utils.ts index 10ccac3c12139..9c56db80e45fc 100644 --- a/x-pack/test/cases_api_integration/common/lib/utils.ts +++ b/x-pack/test/cases_api_integration/common/lib/utils.ts @@ -1143,16 +1143,3 @@ export const extractWarningValueFromWarningHeader = (warningHeader: string) => { const warningValue = warningHeader.substring(firstQuote + 1, lastQuote); return warningValue; }; - -/** - * Regular expression to test if a string matches the RFC7234 specification (without warn-date) for warning headers. This pattern assumes that the warn code - * is always 299. Further, this pattern assumes that the warn agent represents a version of Kibana. - * - * Example: 299 Kibana-8.2.0 "Deprecated endpoint" - */ -const WARNING_HEADER_REGEX = /299 Kibana-\d+.\d+.\d+ \".+\"/g; - -export const assertWarningHeader = (warningHeader: string) => { - const res = warningHeader.match(WARNING_HEADER_REGEX); - expect(res).not.to.be(null); -}; diff --git a/x-pack/test/cases_api_integration/common/lib/validation.ts b/x-pack/test/cases_api_integration/common/lib/validation.ts index 220074f22db86..d03c9494d6b99 100644 --- a/x-pack/test/cases_api_integration/common/lib/validation.ts +++ b/x-pack/test/cases_api_integration/common/lib/validation.ts @@ -37,3 +37,16 @@ export function arraysToEqual(array1?: object[], array2?: object[]) { const array1AsSet = new Set(array1); return array2.every((item) => array1AsSet.has(item)); } + +/** + * Regular expression to test if a string matches the RFC7234 specification (without warn-date) for warning headers. This pattern assumes that the warn code + * is always 299. Further, this pattern assumes that the warn agent represents a version of Kibana. + * + * Example: 299 Kibana-8.2.0 "Deprecated endpoint" + */ +const WARNING_HEADER_REGEX = /299 Kibana-\d+.\d+.\d+ \".+\"/g; + +export const assertWarningHeader = (warningHeader: string) => { + const res = warningHeader.match(WARNING_HEADER_REGEX); + expect(res).not.to.be(null); +};