Skip to content

Commit

Permalink
Move assertWarningHeader to validations
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Feb 7, 2022
1 parent d4d8fe2 commit d59f1b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 0 additions & 13 deletions x-pack/test/cases_api_integration/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
13 changes: 13 additions & 0 deletions x-pack/test/cases_api_integration/common/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit d59f1b9

Please sign in to comment.