@api-client/core 0.9.22 → 0.9.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser.d.ts +11 -11
- package/build/browser.js +13 -16
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +11 -11
- package/build/index.js +13 -16
- package/build/index.js.map +1 -1
- package/build/src/data/DataExtractor.d.ts +66 -0
- package/build/src/data/DataExtractor.js +177 -0
- package/build/src/data/DataExtractor.js.map +1 -0
- package/build/src/data/RequestDataExtractor.d.ts +4 -1
- package/build/src/data/RequestDataExtractor.js +13 -26
- package/build/src/data/RequestDataExtractor.js.map +1 -1
- package/build/src/lib/Buffer.d.ts +2 -2
- package/build/src/lib/Buffer.js +46 -18
- package/build/src/lib/Buffer.js.map +1 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Request.d.ts +2 -2
- package/build/src/models/Request.js +1 -1
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/RequestLog.d.ts +1 -1
- package/build/src/models/http-flows/AssertionError.js.map +1 -0
- package/build/src/models/http-flows/HttpAssertion.js.map +1 -0
- package/build/src/models/{http-actions → http-flows}/HttpFlows.d.ts +5 -38
- package/build/src/models/{http-actions → http-flows}/HttpFlows.js +4 -0
- package/build/src/models/http-flows/HttpFlows.js.map +1 -0
- package/build/src/models/http-flows/HttpStep.js.map +1 -0
- package/build/src/models/{http-actions → http-flows}/LegacyTranslator.d.ts +2 -2
- package/build/src/models/{http-actions → http-flows}/LegacyTranslator.js +92 -46
- package/build/src/models/http-flows/LegacyTranslator.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/EqualAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/GreaterThanAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/IncludesAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/IsEmptyAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/IsNotEmptyAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/LengthOfAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/LessThanAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/MatchesAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/MatchesSchemaAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/NotEqualAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/NotIncludesAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/NotOkAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/NotToBeAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/OkAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/ToBeAssertion.js.map +1 -0
- package/build/src/models/http-flows/steps/assertion/index.js.map +1 -0
- package/build/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.d.ts +5 -1
- package/build/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.js +6 -1
- package/build/src/models/http-flows/steps/data/DeleteCookieStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/DeleteVariableStep.d.ts +36 -0
- package/build/src/models/http-flows/steps/data/DeleteVariableStep.js +44 -0
- package/build/src/models/http-flows/steps/data/DeleteVariableStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/ReadDataSourceStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/ReadDataStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/ReadValueStep.js.map +1 -0
- package/build/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.d.ts +2 -1
- package/build/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.js +2 -1
- package/build/src/models/http-flows/steps/data/SetCookieStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/SetDataStep.js.map +1 -0
- package/build/src/models/http-flows/steps/data/SetVariableStep.js.map +1 -0
- package/build/src/models/{http-actions → http-flows}/steps/data/index.d.ts +1 -0
- package/build/src/models/{http-actions → http-flows}/steps/data/index.js +1 -0
- package/build/src/models/http-flows/steps/data/index.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/AsLowerCaseStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/AsNumberStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/AsUpperCaseStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/RoundStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/SubstringStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/TrimStep.js.map +1 -0
- package/build/src/models/http-flows/steps/transformation/index.js.map +1 -0
- package/build/src/proxy/RequestProxy.d.ts +2 -2
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/http-runner/ConditionCheck.d.ts +1 -1
- package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +7 -57
- package/build/src/runtime/http-runner/HttpAssertionRunner.js +24 -382
- package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -1
- package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +10 -57
- package/build/src/runtime/http-runner/HttpFlowRunner.js +45 -203
- package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
- package/build/src/runtime/http-runner/HttpFlows.d.ts +119 -0
- package/build/src/runtime/http-runner/HttpFlows.js +541 -0
- package/build/src/runtime/http-runner/HttpFlows.js.map +1 -0
- package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +2 -2
- package/package.json +1 -1
- package/src/data/DataExtractor.ts +188 -0
- package/src/data/RequestDataExtractor.ts +14 -26
- package/src/lib/Buffer.ts +51 -23
- package/src/models/ClientCertificate.ts +1 -1
- package/src/models/Request.ts +3 -3
- package/src/models/RequestLog.ts +1 -1
- package/src/models/{http-actions → http-flows}/HttpFlows.ts +5 -39
- package/src/models/{http-actions → http-flows}/LegacyTranslator.ts +89 -31
- package/src/models/{http-actions → http-flows}/steps/data/DeleteCookieStep.ts +6 -1
- package/src/models/http-flows/steps/data/DeleteVariableStep.ts +78 -0
- package/src/models/{http-actions → http-flows}/steps/data/SetCookieStep.ts +4 -2
- package/src/proxy/RequestProxy.ts +2 -2
- package/src/runtime/http-engine/HttpEngine.ts +3 -3
- package/src/runtime/http-runner/ConditionCheck.ts +1 -1
- package/src/runtime/http-runner/HttpAssertionRunner.ts +28 -410
- package/src/runtime/http-runner/HttpFlowRunner.ts +47 -212
- package/src/runtime/http-runner/HttpFlows.ts +576 -0
- package/src/runtime/http-runner/HttpRequestRunner.ts +2 -2
- package/build/src/data/DataUtils.d.ts +0 -40
- package/build/src/data/DataUtils.js +0 -106
- package/build/src/data/DataUtils.js.map +0 -1
- package/build/src/models/http-actions/AssertionError.js.map +0 -1
- package/build/src/models/http-actions/HttpAssertion.js.map +0 -1
- package/build/src/models/http-actions/HttpFlows.js.map +0 -1
- package/build/src/models/http-actions/HttpStep.js.map +0 -1
- package/build/src/models/http-actions/LegacyTranslator.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +0 -1
- package/build/src/models/http-actions/steps/assertion/index.js.map +0 -1
- package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/SetDataStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +0 -1
- package/build/src/models/http-actions/steps/data/index.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +0 -1
- package/build/src/models/http-actions/steps/transformation/index.js.map +0 -1
- package/src/data/DataUtils.ts +0 -108
- /package/build/src/models/{http-actions → http-flows}/AssertionError.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/AssertionError.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/HttpAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/HttpAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/HttpStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/HttpStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/index.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/assertion/index.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/SetDataStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/SetDataStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.js +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/index.d.ts +0 -0
- /package/build/src/models/{http-actions → http-flows}/steps/transformation/index.js +0 -0
- /package/src/models/{http-actions → http-flows}/AssertionError.ts +0 -0
- /package/src/models/{http-actions → http-flows}/HttpAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/HttpStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/EqualAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/GreaterThanAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/IncludesAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/IsEmptyAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/IsNotEmptyAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/LengthOfAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/LessThanAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/MatchesAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/MatchesSchemaAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/NotEqualAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/NotIncludesAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/NotOkAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/NotToBeAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/OkAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/assertion/ToBeAssertion.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/data/ReadDataSourceStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/data/ReadDataStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/data/ReadValueStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/data/SetDataStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/data/SetVariableStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/AsLowerCaseStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/AsNumberStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/AsUpperCaseStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/RoundStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/SubstringStep.ts +0 -0
- /package/src/models/{http-actions → http-flows}/steps/transformation/TrimStep.ts +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { HttpStep, IHttpStep } from "../../HttpStep.js";
|
|
2
|
+
|
|
3
|
+
export const DeleteVariableStepKind = 'HttpAction#DeleteVariable';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A step that deletes a variable.
|
|
7
|
+
*/
|
|
8
|
+
export interface IDeleteVariableStep extends IHttpStep {
|
|
9
|
+
kind: typeof DeleteVariableStepKind;
|
|
10
|
+
/**
|
|
11
|
+
* The name of the variable to delete
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export class DeleteVariableStep extends HttpStep {
|
|
18
|
+
override kind = DeleteVariableStepKind;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The name of the variable to delete
|
|
22
|
+
*/
|
|
23
|
+
name = '';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates the step from values.
|
|
27
|
+
* @param name The name of the variable to delete
|
|
28
|
+
*/
|
|
29
|
+
constructor(name: string);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates the step from serialized schema.
|
|
33
|
+
* @param init The serialized step values.
|
|
34
|
+
*/
|
|
35
|
+
constructor(init: IDeleteVariableStep);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates an empty step.
|
|
39
|
+
*/
|
|
40
|
+
constructor();
|
|
41
|
+
|
|
42
|
+
constructor(nameOrInit?: string | IDeleteVariableStep) {
|
|
43
|
+
super();
|
|
44
|
+
if (!nameOrInit) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (typeof nameOrInit === 'object') {
|
|
48
|
+
const typed = nameOrInit as IDeleteVariableStep;
|
|
49
|
+
this.new(typed);
|
|
50
|
+
} else if (typeof nameOrInit === 'string') {
|
|
51
|
+
this.new({
|
|
52
|
+
kind: DeleteVariableStepKind,
|
|
53
|
+
name: nameOrInit,
|
|
54
|
+
enabled: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override new(init: IDeleteVariableStep): void {
|
|
60
|
+
super.new(init);
|
|
61
|
+
this.kind = DeleteVariableStepKind;
|
|
62
|
+
this.name = init.name;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
checkValidity(): boolean {
|
|
66
|
+
const { name } = this;
|
|
67
|
+
return !!name;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override toJSON(): IDeleteVariableStep {
|
|
71
|
+
const result: IDeleteVariableStep = {
|
|
72
|
+
...super.toJSON(),
|
|
73
|
+
kind: DeleteVariableStepKind,
|
|
74
|
+
name: this.name,
|
|
75
|
+
};
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -97,8 +97,9 @@ export class SetCookieStep extends HttpStep {
|
|
|
97
97
|
/**
|
|
98
98
|
* Creates the step from values.
|
|
99
99
|
* @param name The name of the variable to set
|
|
100
|
+
* @param url Optional URL of the cookie to set.
|
|
100
101
|
*/
|
|
101
|
-
constructor(name: string);
|
|
102
|
+
constructor(name: string, url?: string);
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
105
|
* Creates the step from serialized schema.
|
|
@@ -111,7 +112,7 @@ export class SetCookieStep extends HttpStep {
|
|
|
111
112
|
*/
|
|
112
113
|
constructor();
|
|
113
114
|
|
|
114
|
-
constructor(nameOrInit?: string | ISetCookieStepInit) {
|
|
115
|
+
constructor(nameOrInit?: string | ISetCookieStepInit, url?: string) {
|
|
115
116
|
super();
|
|
116
117
|
if (!nameOrInit) {
|
|
117
118
|
return;
|
|
@@ -124,6 +125,7 @@ export class SetCookieStep extends HttpStep {
|
|
|
124
125
|
kind: SetCookieStepKind,
|
|
125
126
|
name: nameOrInit,
|
|
126
127
|
enabled: true,
|
|
128
|
+
url,
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
}
|
|
@@ -3,12 +3,12 @@ import { IRequestAuthorization } from '../models/RequestAuthorization.js';
|
|
|
3
3
|
import { IRequestConfig } from '../models/RequestConfig.js';
|
|
4
4
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
5
5
|
import { HttpCertificate } from '../models/ClientCertificate.js';
|
|
6
|
-
import { IHttpFlow } from '../models/http-actions/HttpFlows.js';
|
|
7
6
|
import { ApiError } from '../runtime/store/Errors.js';
|
|
8
7
|
import { DummyLogger } from '../lib/logging/DummyLogger.js';
|
|
9
8
|
import { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js';
|
|
10
9
|
import { IRequestLog } from "../models/RequestLog.js";
|
|
11
|
-
import {
|
|
10
|
+
import { IHttpFlow } from '../models/http-flows/HttpFlows.js';
|
|
11
|
+
import { IHttpAssertion } from '../models/http-flows/HttpAssertion.js';
|
|
12
12
|
|
|
13
13
|
export interface IRequestProxyInit {
|
|
14
14
|
kind: typeof HttpRequestKind;
|
|
@@ -810,7 +810,7 @@ Check your request parameters.`);
|
|
|
810
810
|
options.pfx = [];
|
|
811
811
|
}
|
|
812
812
|
const struct: tls.PxfObject = {
|
|
813
|
-
buf: Buffer.from(cert.cert.data as
|
|
813
|
+
buf: Buffer.from(cert.cert.data as ArrayBuffer | Buffer | Uint8Array),
|
|
814
814
|
};
|
|
815
815
|
if (cert.cert.passphrase) {
|
|
816
816
|
struct.passphrase = cert.cert.passphrase;
|
|
@@ -835,7 +835,7 @@ Check your request parameters.`);
|
|
|
835
835
|
options.cert = [];
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
|
-
const added = Buffer.from(typed.cert.data as
|
|
838
|
+
const added = Buffer.from(typed.cert.data as ArrayBuffer | Buffer | Uint8Array);
|
|
839
839
|
options.cert.push(added);
|
|
840
840
|
if (typed.certKey) {
|
|
841
841
|
if (!Array.isArray(options.key)) {
|
|
@@ -846,7 +846,7 @@ Check your request parameters.`);
|
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
848
|
const struct: tls.KeyObject = {
|
|
849
|
-
pem: Buffer.from(typed.certKey.data as
|
|
849
|
+
pem: Buffer.from(typed.certKey.data as ArrayBuffer | Buffer | Uint8Array),
|
|
850
850
|
};
|
|
851
851
|
if (typed.certKey.passphrase) {
|
|
852
852
|
struct.passphrase = typed.certKey.passphrase;
|
|
@@ -1,53 +1,32 @@
|
|
|
1
|
-
import { assert } from '@esm-bundle/chai';
|
|
2
|
-
import { HttpRequest } from "../../models/HttpRequest.js";
|
|
3
1
|
import { ISentRequest } from "../../models/SentRequest.js";
|
|
4
2
|
import { IResponse } from "../../models/Response.js";
|
|
5
|
-
import {
|
|
6
|
-
import { AssertionResult, IHttpAssertion } from "../../models/http-
|
|
7
|
-
import { IHttpStep } from "../../models/http-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
|
|
28
|
-
import { AssertionError } from "../../models/http-actions/AssertionError.js";
|
|
29
|
-
import { GreaterThanAssertionKind, IGreaterThanAssertion } from "../../models/http-actions/steps/assertion/GreaterThanAssertion.js";
|
|
30
|
-
import { ILessThanAssertion, LessThanAssertionKind } from "../../models/http-actions/steps/assertion/LessThanAssertion.js";
|
|
31
|
-
import { IIncludesAssertion, IncludesAssertionKind } from "../../models/http-actions/steps/assertion/IncludesAssertion.js";
|
|
32
|
-
import { INotIncludesAssertion, NotIncludesAssertionKind } from "../../models/http-actions/steps/assertion/NotIncludesAssertion.js";
|
|
33
|
-
import { OkAssertionKind } from "../../models/http-actions/steps/assertion/OkAssertion.js";
|
|
34
|
-
import { NotOkAssertionKind } from "../../models/http-actions/steps/assertion/NotOkAssertion.js";
|
|
35
|
-
import { IToBeAssertion, ToBeAssertionKind, ToBeTypes } from '../../models/http-actions/steps/assertion/ToBeAssertion.js';
|
|
36
|
-
import { INotToBeAssertion, NotToBeAssertionKind } from '../../models/http-actions/steps/assertion/NotToBeAssertion.js';
|
|
37
|
-
import { IsEmptyAssertionKind } from '../../models/http-actions/steps/assertion/IsEmptyAssertion.js';
|
|
38
|
-
import { IsNotEmptyAssertionKind } from '../../models/http-actions/steps/assertion/IsNotEmptyAssertion.js';
|
|
39
|
-
import { ILengthOfAssertion, LengthOfAssertionKind } from '../../models/http-actions/steps/assertion/LengthOfAssertion.js';
|
|
40
|
-
|
|
41
|
-
interface IStepValue {
|
|
42
|
-
value: FlowValue;
|
|
43
|
-
type?: FlowRequestDataEnum | FlowResponseDataEnum;
|
|
44
|
-
bodyMime?: string;
|
|
45
|
-
}
|
|
3
|
+
import { IErrorResponse } from "../../models/ErrorResponse.js";
|
|
4
|
+
import { AssertionResult, IHttpAssertion } from "../../models/http-flows/HttpAssertion.js";
|
|
5
|
+
import { IHttpStep } from "../../models/http-flows/HttpStep.js";
|
|
6
|
+
import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from "../../models/http-flows/HttpFlows.js";
|
|
7
|
+
import { IReadDataSourceStep, ReadDataSourceStepKind } from "../../models/http-flows/steps/data/ReadDataSourceStep.js";
|
|
8
|
+
import { IReadValueStep, ReadValueStepKind } from "../../models/http-flows/steps/data/ReadValueStep.js";
|
|
9
|
+
import { AsLowerCaseStepKind } from "../../models/http-flows/steps/transformation/AsLowerCaseStep.js";
|
|
10
|
+
import { AsUpperCaseStepKind } from "../../models/http-flows/steps/transformation/AsUpperCaseStep.js";
|
|
11
|
+
import { AsNumberStepKind } from "../../models/http-flows/steps/transformation/AsNumberStep.js";
|
|
12
|
+
import { RoundStepKind } from "../../models/http-flows/steps/transformation/RoundStep.js";
|
|
13
|
+
import { SubstringStepKind } from "../../models/http-flows/steps/transformation/SubstringStep.js";
|
|
14
|
+
import { TrimStepKind } from "../../models/http-flows/steps/transformation/TrimStep.js";
|
|
15
|
+
import { EqualAssertionKind, IEqualAssertion } from "../../models/http-flows/steps/assertion/EqualAssertion.js";
|
|
16
|
+
import { INotEqualAssertion, NotEqualAssertionKind } from "../../models/http-flows/steps/assertion/NotEqualAssertion.js";
|
|
17
|
+
import { AssertionError } from "../../models/http-flows/AssertionError.js";
|
|
18
|
+
import { GreaterThanAssertionKind, IGreaterThanAssertion } from "../../models/http-flows/steps/assertion/GreaterThanAssertion.js";
|
|
19
|
+
import { ILessThanAssertion, LessThanAssertionKind } from "../../models/http-flows/steps/assertion/LessThanAssertion.js";
|
|
20
|
+
import { IIncludesAssertion, IncludesAssertionKind } from "../../models/http-flows/steps/assertion/IncludesAssertion.js";
|
|
21
|
+
import { INotIncludesAssertion, NotIncludesAssertionKind } from "../../models/http-flows/steps/assertion/NotIncludesAssertion.js";
|
|
22
|
+
import { OkAssertionKind } from "../../models/http-flows/steps/assertion/OkAssertion.js";
|
|
23
|
+
import { NotOkAssertionKind } from "../../models/http-flows/steps/assertion/NotOkAssertion.js";
|
|
24
|
+
import { HttpFlows, IStepValue } from './HttpFlows.js';
|
|
46
25
|
|
|
47
26
|
/**
|
|
48
27
|
* A class that perform assertions that have been defined on an HTTP request.
|
|
49
28
|
*/
|
|
50
|
-
export class HttpAssertionRunner {
|
|
29
|
+
export class HttpAssertionRunner extends HttpFlows {
|
|
51
30
|
report: AssertionResult[] = [];
|
|
52
31
|
|
|
53
32
|
/**
|
|
@@ -71,6 +50,10 @@ export class HttpAssertionRunner {
|
|
|
71
50
|
protected async runAssertion(request: ISentRequest, response: IResponse | IErrorResponse, assertion: IHttpAssertion): Promise<void> {
|
|
72
51
|
const { steps } = assertion;
|
|
73
52
|
|
|
53
|
+
if (!Array.isArray(steps) || !steps.length) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
74
57
|
// this keeps a value from the last step to be passed to the next step.
|
|
75
58
|
let lastResult: IStepValue = {
|
|
76
59
|
value: undefined,
|
|
@@ -78,7 +61,7 @@ export class HttpAssertionRunner {
|
|
|
78
61
|
let error: AssertionError | undefined;
|
|
79
62
|
for (const step of steps) {
|
|
80
63
|
try {
|
|
81
|
-
lastResult = await this.runStep(request,
|
|
64
|
+
lastResult = await this.runStep(request, step, lastResult, response);
|
|
82
65
|
} catch (e) {
|
|
83
66
|
const typed = e as AssertionError;
|
|
84
67
|
if (typed.name === 'AssertionError') {
|
|
@@ -172,369 +155,4 @@ export class HttpAssertionRunner {
|
|
|
172
155
|
const { path } = step;
|
|
173
156
|
return path || '';
|
|
174
157
|
}
|
|
175
|
-
|
|
176
|
-
protected async runStep(request: ISentRequest, response: IResponse | IErrorResponse, step: IHttpStep, input: IStepValue): Promise<IStepValue> {
|
|
177
|
-
switch (step.kind) {
|
|
178
|
-
// data reading
|
|
179
|
-
case ReadDataSourceStepKind: return this.readDataSource(request, response, step);
|
|
180
|
-
case ReadValueStepKind: return this.readValue(input, step as IReadValueStep);
|
|
181
|
-
// transformations
|
|
182
|
-
case AsLowerCaseStepKind: return this.toLowerCase(input);
|
|
183
|
-
case AsUpperCaseStepKind: return this.toUpperCase(input);
|
|
184
|
-
case AsNumberStepKind: return this.asNumber(input);
|
|
185
|
-
case RoundStepKind: return this.round(input, step as IRoundStep);
|
|
186
|
-
case TrimStepKind: return this.trim(input);
|
|
187
|
-
case SubstringStepKind: return this.substring(input, step as ISubstringStep);
|
|
188
|
-
// assertions
|
|
189
|
-
case EqualAssertionKind: return this.assertEqual(input, step as IEqualAssertion);
|
|
190
|
-
case NotEqualAssertionKind: return this.assertNotEqual(input, step as INotEqualAssertion);
|
|
191
|
-
case GreaterThanAssertionKind: return this.assertGreaterThan(input, step as IGreaterThanAssertion);
|
|
192
|
-
case LessThanAssertionKind: return this.assertLessThan(input, step as ILessThanAssertion);
|
|
193
|
-
case IncludesAssertionKind: return this.assertIncludes(input, step as IIncludesAssertion);
|
|
194
|
-
case NotIncludesAssertionKind: return this.assertNotIncludes(input, step as INotIncludesAssertion);
|
|
195
|
-
case OkAssertionKind: return this.assertOk(input);
|
|
196
|
-
case NotOkAssertionKind: return this.assertNotOk(input);
|
|
197
|
-
case ToBeAssertionKind: return this.toBe(input, step as IToBeAssertion);
|
|
198
|
-
case NotToBeAssertionKind: return this.notToBe(input, step as INotToBeAssertion);
|
|
199
|
-
case IsEmptyAssertionKind: return this.isEmpty(input);
|
|
200
|
-
case IsNotEmptyAssertionKind: return this.isNotEmpty(input);
|
|
201
|
-
case LengthOfAssertionKind: return this.lengthOf(input, step as ILengthOfAssertion);
|
|
202
|
-
default: return { value: undefined };
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Produces the data source.
|
|
208
|
-
*/
|
|
209
|
-
protected async readDataSource(request: ISentRequest, response: IResponse | IErrorResponse, step: IReadDataSourceStep): Promise<IStepValue> {
|
|
210
|
-
const instance = new ReadDataSourceStep(step);
|
|
211
|
-
if (instance.enabled === false || !instance.checkValidity()) {
|
|
212
|
-
return { value: undefined };
|
|
213
|
-
}
|
|
214
|
-
const { source, data } = step;
|
|
215
|
-
if (source === FlowSourceEnum.request) {
|
|
216
|
-
if (data === FlowRequestDataEnum.url) {
|
|
217
|
-
return {
|
|
218
|
-
value: request.url,
|
|
219
|
-
type: data,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
if (data === FlowRequestDataEnum.headers) {
|
|
223
|
-
return {
|
|
224
|
-
value: request.headers,
|
|
225
|
-
type: data,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
if (data === FlowRequestDataEnum.method) {
|
|
229
|
-
return {
|
|
230
|
-
value: request.method,
|
|
231
|
-
type: data,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
if (data === FlowRequestDataEnum.body) {
|
|
235
|
-
const instance = new HttpRequest(request);
|
|
236
|
-
const value = await this.processBody(instance);
|
|
237
|
-
return {
|
|
238
|
-
...value,
|
|
239
|
-
type: data,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (source === FlowSourceEnum.response) {
|
|
244
|
-
if (data === FlowResponseDataEnum.url) {
|
|
245
|
-
return {
|
|
246
|
-
value: request.url,
|
|
247
|
-
type: data,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
if (data === FlowResponseDataEnum.headers) {
|
|
251
|
-
return {
|
|
252
|
-
value: response.headers,
|
|
253
|
-
type: data,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
if (data === FlowResponseDataEnum.status) {
|
|
257
|
-
return {
|
|
258
|
-
value: response.status,
|
|
259
|
-
type: data,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
if (data === FlowResponseDataEnum.statusText) {
|
|
263
|
-
return {
|
|
264
|
-
value: response.statusText,
|
|
265
|
-
type: data,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (data === FlowResponseDataEnum.body) {
|
|
269
|
-
let instance: ErrorResponse | HttpResponse;
|
|
270
|
-
if (ErrorResponse.isErrorResponse(response)) {
|
|
271
|
-
instance = new ErrorResponse(response as IErrorResponse);
|
|
272
|
-
} else {
|
|
273
|
-
instance = new HttpResponse(response);
|
|
274
|
-
}
|
|
275
|
-
const value = await this.processBody(instance);
|
|
276
|
-
return {
|
|
277
|
-
...value,
|
|
278
|
-
type: data,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return { value: undefined };
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
protected async processBody(input: HttpRequest | HttpResponse | ErrorResponse): Promise<IStepValue> {
|
|
286
|
-
const { headers } = input;
|
|
287
|
-
if (!headers) {
|
|
288
|
-
return { value: undefined };
|
|
289
|
-
}
|
|
290
|
-
const body = await input.readPayloadAsString();
|
|
291
|
-
if (!body) {
|
|
292
|
-
return { value: undefined };
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const parser = new Headers(headers);
|
|
296
|
-
const mime = parser.get('content-type');
|
|
297
|
-
if (!mime) {
|
|
298
|
-
return { value: undefined };
|
|
299
|
-
}
|
|
300
|
-
return {
|
|
301
|
-
value: body,
|
|
302
|
-
bodyMime: mime,
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Produces the value from the current input.
|
|
308
|
-
*/
|
|
309
|
-
protected async readValue(input: IStepValue, step: IReadValueStep): Promise<IStepValue> {
|
|
310
|
-
const instance = new ReadValueStep(step);
|
|
311
|
-
if (instance.enabled === false || !instance.checkValidity() || input.value === undefined || input.value === null) {
|
|
312
|
-
return { value: undefined };
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const { path } = step;
|
|
316
|
-
const { type, value } = input;
|
|
317
|
-
const args = path ? path.split('.') : [];
|
|
318
|
-
if (type === FlowRequestDataEnum.url || type === FlowResponseDataEnum.url) {
|
|
319
|
-
if (!value) {
|
|
320
|
-
return { value: undefined };
|
|
321
|
-
}
|
|
322
|
-
const v = String(input.value);
|
|
323
|
-
return {
|
|
324
|
-
value: DataUtils.getDataUrl(v, args),
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
if (type === FlowRequestDataEnum.headers || type === FlowResponseDataEnum.headers) {
|
|
328
|
-
if (!value) {
|
|
329
|
-
return { value: undefined };
|
|
330
|
-
}
|
|
331
|
-
const v = String(input.value);
|
|
332
|
-
return {
|
|
333
|
-
value: DataUtils.getDataHeaders(v, args),
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (type === FlowRequestDataEnum.body || type === FlowResponseDataEnum.body) {
|
|
337
|
-
if (!input.bodyMime || !path) {
|
|
338
|
-
return { value: undefined };
|
|
339
|
-
}
|
|
340
|
-
let reader: DataReader | undefined;
|
|
341
|
-
if (input.bodyMime.includes('json')) {
|
|
342
|
-
reader = new JmespathReader();
|
|
343
|
-
} else if (input.bodyMime.includes('xml')) {
|
|
344
|
-
reader = new XmlReader();
|
|
345
|
-
} else if (input.bodyMime.includes('x-www-form-urlencoded')) {
|
|
346
|
-
reader = new UrlEncodedReader();
|
|
347
|
-
}
|
|
348
|
-
if (!reader) {
|
|
349
|
-
return { value: undefined };
|
|
350
|
-
}
|
|
351
|
-
await reader.writePayload(String(value));
|
|
352
|
-
const readValue = await reader.getValue(path);
|
|
353
|
-
return {
|
|
354
|
-
value: readValue,
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (type === FlowResponseDataEnum.status) {
|
|
358
|
-
const v = Number(input.value);
|
|
359
|
-
if (Number.isNaN(v)) {
|
|
360
|
-
return { value: undefined };
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
value: v,
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (type === FlowResponseDataEnum.statusText) {
|
|
368
|
-
if (!value) {
|
|
369
|
-
return { value: undefined };
|
|
370
|
-
}
|
|
371
|
-
return {
|
|
372
|
-
value,
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return { value: undefined };
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
protected async toLowerCase(input: IStepValue): Promise<IStepValue> {
|
|
379
|
-
if (input.value === null || input.value === undefined) {
|
|
380
|
-
return { value: undefined };
|
|
381
|
-
}
|
|
382
|
-
const value = String(input.value);
|
|
383
|
-
return { value: value.toLowerCase() };
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
protected async toUpperCase(input: IStepValue): Promise<IStepValue> {
|
|
387
|
-
if (input.value === null || input.value === undefined) {
|
|
388
|
-
return { value: undefined };
|
|
389
|
-
}
|
|
390
|
-
const value = String(input.value);
|
|
391
|
-
return { value: value.toUpperCase() };
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
protected async asNumber(input: IStepValue): Promise<IStepValue> {
|
|
395
|
-
if (input.value === null || input.value === undefined) {
|
|
396
|
-
return { value: undefined };
|
|
397
|
-
}
|
|
398
|
-
const value = String(input.value);
|
|
399
|
-
const parsed = Number(value);
|
|
400
|
-
if (Number.isNaN(parsed)) {
|
|
401
|
-
return { value: undefined };
|
|
402
|
-
}
|
|
403
|
-
return { value: parsed };
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
protected async round(input: IStepValue, step: IRoundStep): Promise<IStepValue> {
|
|
407
|
-
if (input.value === null || input.value === undefined) {
|
|
408
|
-
return { value: undefined };
|
|
409
|
-
}
|
|
410
|
-
const value = String(input.value);
|
|
411
|
-
const parsed = typeof input.value === 'number' ? input.value : Number(value);
|
|
412
|
-
if (Number.isNaN(parsed)) {
|
|
413
|
-
return { value: undefined };
|
|
414
|
-
}
|
|
415
|
-
return { value: parsed.toFixed(step.precision) };
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
protected async trim(input: IStepValue): Promise<IStepValue> {
|
|
419
|
-
if (input.value === null || input.value === undefined) {
|
|
420
|
-
return { value: undefined };
|
|
421
|
-
}
|
|
422
|
-
const value = String(input.value);
|
|
423
|
-
return { ...input, value: value.trim() };
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
protected async substring(input: IStepValue, step: ISubstringStep): Promise<IStepValue> {
|
|
427
|
-
if (input.value === null || input.value === undefined) {
|
|
428
|
-
return { value: undefined };
|
|
429
|
-
}
|
|
430
|
-
if (typeof step.start !== 'number') {
|
|
431
|
-
return input;
|
|
432
|
-
}
|
|
433
|
-
const value = String(input.value);
|
|
434
|
-
return { ...input, value: value.substring(step.start, step.end) };
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
protected async assertEqual(input: IStepValue, step: IEqualAssertion): Promise<IStepValue> {
|
|
438
|
-
const { value } = input;
|
|
439
|
-
if (step.strict) {
|
|
440
|
-
const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
|
|
441
|
-
assert.strictEqual(value, comparator);
|
|
442
|
-
} else {
|
|
443
|
-
assert.equal(String(value), step.value);
|
|
444
|
-
}
|
|
445
|
-
return input;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
protected async assertNotEqual(input: IStepValue, step: INotEqualAssertion): Promise<IStepValue> {
|
|
449
|
-
const { value } = input;
|
|
450
|
-
if (step.strict) {
|
|
451
|
-
const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
|
|
452
|
-
assert.notStrictEqual(value, comparator);
|
|
453
|
-
} else {
|
|
454
|
-
assert.notEqual(value, step.value);
|
|
455
|
-
}
|
|
456
|
-
return input;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
protected async assertGreaterThan(input: IStepValue, step: IGreaterThanAssertion): Promise<IStepValue> {
|
|
460
|
-
assert.typeOf(input.value, 'number');
|
|
461
|
-
const value = input.value as number;
|
|
462
|
-
if (step.equal) {
|
|
463
|
-
assert.isAtLeast(value as number, step.value as number);
|
|
464
|
-
} else {
|
|
465
|
-
assert.isAbove(value as number, step.value as number);
|
|
466
|
-
}
|
|
467
|
-
return input;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
protected async assertLessThan(input: IStepValue, step: ILessThanAssertion): Promise<IStepValue> {
|
|
471
|
-
assert.typeOf(input.value, 'number');
|
|
472
|
-
const value = input.value as number;
|
|
473
|
-
if (step.equal) {
|
|
474
|
-
assert.isAtMost(value, step.value as number);
|
|
475
|
-
} else {
|
|
476
|
-
assert.isBelow(value, step.value as number);
|
|
477
|
-
}
|
|
478
|
-
return input;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
protected async assertIncludes(input: IStepValue, step: IIncludesAssertion): Promise<IStepValue> {
|
|
482
|
-
if (this.isPrimitive(input.value)) {
|
|
483
|
-
assert.include(String(input.value), String(step.value));
|
|
484
|
-
} else {
|
|
485
|
-
assert.include(JSON.stringify(input.value), String(step.value));
|
|
486
|
-
}
|
|
487
|
-
return input;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
protected async assertNotIncludes(input: IStepValue, step: INotIncludesAssertion): Promise<IStepValue> {
|
|
491
|
-
if (this.isPrimitive(input.value)) {
|
|
492
|
-
assert.notInclude(String(input.value), String(step.value));
|
|
493
|
-
} else {
|
|
494
|
-
assert.notInclude(JSON.stringify(input.value), String(step.value));
|
|
495
|
-
}
|
|
496
|
-
return input;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
protected async assertOk(input: IStepValue): Promise<IStepValue> {
|
|
500
|
-
assert.ok(input.value);
|
|
501
|
-
return input;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
protected async assertNotOk(input: IStepValue): Promise<IStepValue> {
|
|
505
|
-
assert.notOk(input.value);
|
|
506
|
-
return input;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
protected async toBe(input: IStepValue, step: IToBeAssertion): Promise<IStepValue> {
|
|
510
|
-
assert.typeOf(input.value, step.value as string);
|
|
511
|
-
return input;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
protected async notToBe(input: IStepValue, step: INotToBeAssertion): Promise<IStepValue> {
|
|
515
|
-
if (Array.isArray(input.value) && step.value === ToBeTypes.object) {
|
|
516
|
-
assert(false, 'expected [Array] to be an object');
|
|
517
|
-
}
|
|
518
|
-
assert.notTypeOf(input.value, step.value as string);
|
|
519
|
-
return input;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
protected async isEmpty(input: IStepValue): Promise<IStepValue> {
|
|
523
|
-
assert.isEmpty(input.value);
|
|
524
|
-
return input;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
protected async isNotEmpty(input: IStepValue): Promise<IStepValue> {
|
|
528
|
-
assert.isNotEmpty(input.value);
|
|
529
|
-
return input;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
protected async lengthOf(input: IStepValue, step: ILengthOfAssertion): Promise<IStepValue> {
|
|
533
|
-
assert.lengthOf(input.value as unknown[], step.value as number);
|
|
534
|
-
return input;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
protected isPrimitive(value: unknown): boolean {
|
|
538
|
-
return (typeof value !== 'object' && typeof value !== 'function') || value === null;
|
|
539
|
-
}
|
|
540
158
|
}
|