UNPKG

cumulocity-cypress

Version:
94 lines (93 loc) 3.07 kB
import { C8yPact, C8yPactRecord } from "./c8ypact"; /** * Preprocessor for C8yPact objects. Use C8yPactPreprocessor to preprocess any * Cypress.Response, C8yPactRecord or C8yPact. The preprocessor could be used to * obfuscate or remove sensitive data from the pact objects. It is called on save * and load of the pact objects. */ export interface C8yPactPreprocessor { /** * Configuration options used by the preprocessor. */ readonly options?: C8yPactPreprocessorOptions; /** * Applies the preprocessor to the given object. * * @param obj Object to preprocess. * @param options Preprocessor options. */ apply: (obj: Partial<Cypress.Response<any> | C8yPactRecord | C8yPact>, options?: C8yPactPreprocessorOptions) => void; } /** * Configuration options for the C8yPactPreprocessor. */ export interface C8yPactPreprocessorOptions { /** * Key paths to obfuscate. * * @example * response.body.password */ obfuscate?: string[]; /** * Key paths to remove. * * @example * request.headers.Authorization */ ignore?: string[]; /** * Key paths to pick. All other keys (children) of the object will * be removed. * * @example * response.headers: ["content-type"] * ["request.headers", "response.headers"] */ pick?: { [key: string]: string[]; } | string[]; /** * Obfuscation pattern to use. Default is ********. */ obfuscationPattern?: string; /** * Whether to ignore case when matching keys. */ ignoreCase?: boolean; } export declare const C8yPactPreprocessorDefaultOptions: { ignore: string[]; obfuscate: string[]; obfuscationPattern: string; ignoreCase: boolean; }; /** * Default implementation of C8yPactPreprocessor. Preprocessor for C8yPact objects * that can be used to obfuscate or remove sensitive data from the pact objects. * Use C8ypactPreprocessorOptions to configure the preprocessor. * * Removes cookies and set-cookie headers by appending the key to the `cookie` or `set-cookie` * key as for example `headers.cookie.authorization` or `headers.set-cookie.authorization`. */ export declare class C8yDefaultPactPreprocessor implements C8yPactPreprocessor { static defaultObfuscationPattern: string; options?: C8yPactPreprocessorOptions; protected reservedKeys: string[]; constructor(options?: C8yPactPreprocessorOptions); apply(obj: Partial<Cypress.Response<any> | C8yPactRecord | C8yPact>, options?: C8yPactPreprocessorOptions): void; private filterObjectByKeepPaths; private applyKeepArray; private handleObfuscation; private handleRemoval; private removeKey; private removeSetCookie; private removeCookie; private filterValidKeys; private obfuscateKey; private obfuscateSetCookie; private obfuscateCookie; protected resolveOptions(options?: Partial<C8yPactPreprocessorOptions>): C8yPactPreprocessorOptions; private hasKey; private getCookieObject; }