@api-client/core 0.9.21 → 0.9.23
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/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-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-flows/AssertionError.js.map +1 -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-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-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-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-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-flows/steps/assertion/EqualAssertion.js.map +1 -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-flows/steps/assertion/GreaterThanAssertion.js.map +1 -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-flows/steps/assertion/IncludesAssertion.js.map +1 -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-flows/steps/assertion/IsEmptyAssertion.js.map +1 -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-flows/steps/assertion/IsNotEmptyAssertion.js.map +1 -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-flows/steps/assertion/LengthOfAssertion.js.map +1 -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-flows/steps/assertion/LessThanAssertion.js.map +1 -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-flows/steps/assertion/MatchesAssertion.js.map +1 -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-flows/steps/assertion/MatchesSchemaAssertion.js.map +1 -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-flows/steps/assertion/NotEqualAssertion.js.map +1 -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-flows/steps/assertion/NotIncludesAssertion.js.map +1 -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-flows/steps/assertion/NotOkAssertion.js.map +1 -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-flows/steps/assertion/NotToBeAssertion.js.map +1 -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-flows/steps/assertion/OkAssertion.js.map +1 -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-flows/steps/assertion/ToBeAssertion.js.map +1 -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-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-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-flows/steps/data/ReadDataSourceStep.js.map +1 -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-flows/steps/data/ReadDataStep.js.map +1 -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-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-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-flows/steps/data/SetDataStep.js.map +1 -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-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-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-flows/steps/transformation/AsLowerCaseStep.js.map +1 -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-flows/steps/transformation/AsNumberStep.js.map +1 -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-flows/steps/transformation/AsUpperCaseStep.js.map +1 -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-flows/steps/transformation/RoundStep.js.map +1 -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-flows/steps/transformation/SubstringStep.js.map +1 -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-flows/steps/transformation/TrimStep.js.map +1 -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/build/src/models/http-flows/steps/transformation/index.js.map +1 -0
- package/build/src/proxy/HttpProjectProxy.d.ts +4 -0
- package/build/src/proxy/HttpProjectProxy.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts +6 -2
- package/build/src/proxy/RequestProxy.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/models/Request.ts +3 -3
- package/src/models/RequestLog.ts +1 -1
- 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}/HttpFlows.ts +5 -39
- package/src/models/{http-actions → http-flows}/HttpStep.ts +0 -0
- package/src/models/{http-actions → http-flows}/LegacyTranslator.ts +89 -31
- 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/DeleteCookieStep.ts +6 -1
- package/src/models/http-flows/steps/data/DeleteVariableStep.ts +78 -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/SetCookieStep.ts +4 -2
- 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
- package/src/proxy/HttpProjectProxy.ts +4 -0
- package/src/proxy/RequestProxy.ts +6 -2
- 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
|
@@ -1,232 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { RequestDataExtractor } from "../../data/RequestDataExtractor.js";
|
|
4
|
-
import { checkCondition } from "./ConditionCheck.js";
|
|
5
|
-
import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
|
|
6
|
-
import { ReadDataStep, ReadDataStepKind } from "../../models/http-actions/steps/data/ReadDataStep.js";
|
|
7
|
-
import { SetDataStep, SetDataStepKind } from "../../models/http-actions/steps/data/SetDataStep.js";
|
|
8
|
-
import { SetVariableStep, SetVariableStepKind } from "../../models/http-actions/steps/data/SetVariableStep.js";
|
|
9
|
-
import { SetCookieStep, SetCookieStepKind } from "../../models/http-actions/steps/data/SetCookieStep.js";
|
|
10
|
-
import { DeleteCookieStep, DeleteCookieStepKind } from "../../models/http-actions/steps/data/DeleteCookieStep.js";
|
|
11
|
-
export class HttpFlowRunner {
|
|
1
|
+
import { HttpFlows } from "./HttpFlows.js";
|
|
2
|
+
export class HttpFlowRunner extends HttpFlows {
|
|
12
3
|
/**
|
|
13
|
-
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
* These variables are passed by reference. Changes made anywhere to the variables will result
|
|
17
|
-
* with updating this list.
|
|
4
|
+
* Runs flows before the HTTP request is sent to the remote machine.
|
|
5
|
+
* The request has to be pre-processed, that is, variables should already be applied to it.
|
|
18
6
|
*/
|
|
19
|
-
variables;
|
|
20
|
-
/**
|
|
21
|
-
* An instance of a cookie jar (store) to put/read cookies.
|
|
22
|
-
*/
|
|
23
|
-
cookies;
|
|
24
7
|
async request(request, flows) {
|
|
25
8
|
if (!flows || !flows.length) {
|
|
26
9
|
return;
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
const { condition, actions } = flow;
|
|
30
|
-
if (condition) {
|
|
31
|
-
try {
|
|
32
|
-
const meet = await this._satisfied(condition, request);
|
|
33
|
-
if (!meet) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (_) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
for (const action of actions) {
|
|
42
|
-
await this._runAction(action, request);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
11
|
+
await this.runFlows(request, flows);
|
|
45
12
|
}
|
|
46
13
|
async response(request, response, flows) {
|
|
47
14
|
if (!flows || !flows.length) {
|
|
48
15
|
return;
|
|
49
16
|
}
|
|
17
|
+
await this.runFlows(request, flows, response);
|
|
18
|
+
}
|
|
19
|
+
async runFlows(request, flows, response) {
|
|
50
20
|
for (const flow of flows) {
|
|
51
|
-
|
|
52
|
-
|
|
21
|
+
const { condition, actions } = flow;
|
|
22
|
+
const passedCondition = await this.checkCondition(request, condition, response);
|
|
23
|
+
if (!passedCondition) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
for (const action of actions) {
|
|
27
|
+
try {
|
|
28
|
+
await this.runAction(action, request, response);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.warn(e);
|
|
33
|
+
// if the step fails then we stop execution.
|
|
34
|
+
// TODO: we should generate a report with the list of execution errors and present it in the UI.
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
53
37
|
}
|
|
54
38
|
}
|
|
55
39
|
}
|
|
56
|
-
async
|
|
40
|
+
async runAction(action, request, response) {
|
|
57
41
|
const { steps } = action;
|
|
58
42
|
if (!Array.isArray(steps) || !steps.length) {
|
|
59
43
|
return;
|
|
60
44
|
}
|
|
61
|
-
|
|
62
|
-
let lastResult;
|
|
63
|
-
for (const step of steps) {
|
|
64
|
-
lastResult = await this._runStep(step, lastResult, request, response);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async _satisfied(condition, request, response) {
|
|
68
|
-
const { source, data, path, operator, value } = condition;
|
|
69
|
-
if (!source || !operator) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
const extractor = new RequestDataExtractor(request, response);
|
|
73
|
-
const readValue = await extractor.extract(source, data, path);
|
|
74
|
-
return checkCondition(readValue, operator, value);
|
|
45
|
+
await this.runSteps(steps, request, response);
|
|
75
46
|
}
|
|
76
|
-
async
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case SetDataStepKind: return this._runSetDataStep(step);
|
|
80
|
-
case SetVariableStepKind: return this._runSetVariableStep(step, input);
|
|
81
|
-
case SetCookieStepKind: return this._runSetCookieStep(step, input, request);
|
|
82
|
-
case DeleteCookieStepKind: return this._runDeleteCookieStep(step, request);
|
|
83
|
-
default: return undefined;
|
|
47
|
+
async checkCondition(request, condition, response) {
|
|
48
|
+
if (!condition) {
|
|
49
|
+
return true;
|
|
84
50
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
* @param step The step configuration.
|
|
90
|
-
* @param request The HttpRequest or the SentRequest (for responses)
|
|
91
|
-
* @param response When available, the response data
|
|
92
|
-
* @returns The read value or undefined.
|
|
93
|
-
*/
|
|
94
|
-
async _runReadDataStep(step, request, response) {
|
|
95
|
-
const instance = new ReadDataStep(step);
|
|
96
|
-
if (instance.enabled === false || !instance.checkValidity()) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
const { source, data, path } = step;
|
|
100
|
-
if (source === FlowSourceEnum.request) {
|
|
101
|
-
const extractor = new RequestDataExtractor(request);
|
|
102
|
-
return extractor.extract(source, data, path);
|
|
103
|
-
}
|
|
104
|
-
if (source === FlowSourceEnum.response) {
|
|
105
|
-
const extractor = new RequestDataExtractor(request, response);
|
|
106
|
-
return extractor.extract(source, data, path);
|
|
107
|
-
}
|
|
108
|
-
if (source === FlowSourceEnum.variable && path && this.variables) {
|
|
109
|
-
return this.variables[path];
|
|
110
|
-
}
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* A step that returns a pre-configured value.
|
|
115
|
-
*
|
|
116
|
-
* @param step The step configuration.
|
|
117
|
-
* @returns The read value with applied data type.
|
|
118
|
-
*/
|
|
119
|
-
_runSetDataStep(step) {
|
|
120
|
-
const instance = new SetDataStep(step);
|
|
121
|
-
if (instance.enabled === false || !instance.checkValidity()) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
const { value, dataType } = step;
|
|
125
|
-
if (value === null || value === undefined) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
return ApiSchemaValues.parseScalar(value, dataType);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* A step that sets a variable in the current environment.
|
|
132
|
-
*
|
|
133
|
-
* @param step The step configuration.
|
|
134
|
-
* @param value The value to set. A value that is `null` or `undefined` deletes the variable.
|
|
135
|
-
*/
|
|
136
|
-
_runSetVariableStep(step, value) {
|
|
137
|
-
const instance = new SetVariableStep(step);
|
|
138
|
-
if (instance.enabled === false || !instance.checkValidity() || !this.variables) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
const { name } = step;
|
|
142
|
-
if (value === null || typeof value === undefined) {
|
|
143
|
-
delete this.variables[name];
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
this.variables[name] = String(value);
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* A step that sets a cookie.
|
|
152
|
-
*
|
|
153
|
-
* @param step The step configuration.
|
|
154
|
-
* @param value The value to sent on the cookie.
|
|
155
|
-
* @param request The request object.
|
|
156
|
-
*/
|
|
157
|
-
async _runSetCookieStep(step, value, request) {
|
|
158
|
-
const instance = new SetCookieStep(step);
|
|
159
|
-
const { cookies } = this;
|
|
160
|
-
if (instance.enabled === false || !instance.checkValidity() || !cookies) {
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
if (value === null || typeof value === undefined) {
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
const { name, expires, hostOnly, httpOnly, sameSite, secure, session } = step;
|
|
167
|
-
const typedValue = String(value);
|
|
168
|
-
let url;
|
|
169
|
-
if (step.url) {
|
|
170
|
-
url = step.url;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
url = request.url;
|
|
174
|
-
}
|
|
175
|
-
const cookie = new HttpCookie({
|
|
176
|
-
name: name,
|
|
177
|
-
value: typedValue,
|
|
178
|
-
sameSite: 'unspecified',
|
|
179
|
-
});
|
|
180
|
-
if (sameSite) {
|
|
181
|
-
const typed = sameSite;
|
|
182
|
-
switch (typed.toLowerCase()) {
|
|
183
|
-
case 'lax':
|
|
184
|
-
cookie.sameSite = 'lax';
|
|
185
|
-
break;
|
|
186
|
-
case 'strict':
|
|
187
|
-
cookie.sameSite = 'strict';
|
|
188
|
-
break;
|
|
189
|
-
case 'none':
|
|
190
|
-
cookie.sameSite = 'no_restriction';
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (expires) {
|
|
195
|
-
cookie.expirationDate = expires;
|
|
196
|
-
}
|
|
197
|
-
if (typeof hostOnly === 'boolean') {
|
|
198
|
-
cookie.hostOnly = hostOnly;
|
|
199
|
-
}
|
|
200
|
-
if (typeof httpOnly === 'boolean') {
|
|
201
|
-
cookie.httpOnly = httpOnly;
|
|
51
|
+
const { steps = [] } = condition;
|
|
52
|
+
if (!Array.isArray(steps) || !steps.length) {
|
|
53
|
+
return true;
|
|
202
54
|
}
|
|
203
|
-
|
|
204
|
-
|
|
55
|
+
// the condition works with assertions. If the condition throws then it is not satisfied.
|
|
56
|
+
try {
|
|
57
|
+
await this.runSteps(steps, request, response);
|
|
58
|
+
return true;
|
|
205
59
|
}
|
|
206
|
-
|
|
207
|
-
|
|
60
|
+
catch (_) {
|
|
61
|
+
return false;
|
|
208
62
|
}
|
|
209
|
-
await cookies.setCookies(url, [cookie]);
|
|
210
|
-
return undefined;
|
|
211
63
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
return undefined;
|
|
220
|
-
}
|
|
221
|
-
let url;
|
|
222
|
-
if (step.url) {
|
|
223
|
-
url = step.url;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
url = request.url;
|
|
64
|
+
async runSteps(steps, request, response) {
|
|
65
|
+
// this keeps a value from the last step to be passed to the next step.
|
|
66
|
+
let lastResult = {
|
|
67
|
+
value: undefined,
|
|
68
|
+
};
|
|
69
|
+
for (const step of steps) {
|
|
70
|
+
lastResult = await this.runStep(request, step, lastResult, response);
|
|
227
71
|
}
|
|
228
|
-
await cookies.deleteCookies(url, step.name);
|
|
229
|
-
return undefined;
|
|
230
72
|
}
|
|
231
73
|
}
|
|
232
74
|
//# sourceMappingURL=HttpFlowRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpFlowRunner.js","sourceRoot":"","sources":["../../../../src/runtime/http-runner/HttpFlowRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpFlowRunner.js","sourceRoot":"","sources":["../../../../src/runtime/http-runner/HttpFlowRunner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAc,MAAM,gBAAgB,CAAC;AAIvD,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqB,EAAE,KAAmB;QACtD,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC3B,OAAO;SACR;QACD,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAoC,EAAE,QAAoC,EAAE,KAAmB;QAC5G,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC3B,OAAO;SACR;QACD,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,OAAoC,EAAE,KAAkB,EAAE,QAAqC;QACtH,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YAChF,IAAI,CAAC,eAAe,EAAE;gBACpB,SAAS;aACV;YACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,IAAI;oBACF,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;iBACjD;gBAAC,OAAO,CAAC,EAAE;oBACV,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAChB,4CAA4C;oBAC5C,gGAAgG;oBAChG,MAAM;iBACP;aACF;SACF;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAmB,EAAE,OAAoC,EAAE,QAAqC;QAC9G,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1C,OAAO;SACR;QACD,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAoC,EAAE,SAAuB,EAAE,QAAqC;QACvH,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,IAAI,CAAC;SACb;QACD,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1C,OAAO,IAAI,CAAC;SACb;QACD,yFAAyF;QACzF,IAAI;YACF,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,KAAkB,EAAE,OAAoC,EAAE,QAAqC;QACtH,uEAAuE;QACvE,IAAI,UAAU,GAAe;YAC3B,KAAK,EAAE,SAAS;SACjB,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;SACtE;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { HttpRequest, IHttpRequest } from "../../models/HttpRequest.js";
|
|
2
|
+
import { ISentRequest } from "../../models/SentRequest.js";
|
|
3
|
+
import { CookieJar } from "../../cookies/CookieJar.js";
|
|
4
|
+
import { IResponse } from "../../models/Response.js";
|
|
5
|
+
import { ErrorResponse, IErrorResponse } from "../../models/ErrorResponse.js";
|
|
6
|
+
import { IHttpStep } from "../../models/http-flows/HttpStep.js";
|
|
7
|
+
import { FlowValue } from "./HttpFlowRunner.js";
|
|
8
|
+
import { FlowRequestDataEnum, FlowResponseDataEnum } from "../../models/http-flows/HttpFlows.js";
|
|
9
|
+
import { IReadDataSourceStep } from "../../models/http-flows/steps/data/ReadDataSourceStep.js";
|
|
10
|
+
import { IReadValueStep } from "../../models/http-flows/steps/data/ReadValueStep.js";
|
|
11
|
+
import { HttpResponse } from "../../models/HttpResponse.js";
|
|
12
|
+
import { IRoundStep } from "../../models/http-flows/steps/transformation/RoundStep.js";
|
|
13
|
+
import { ISubstringStep } from "../../models/http-flows/steps/transformation/SubstringStep.js";
|
|
14
|
+
import { IEqualAssertion } from "../../models/http-flows/steps/assertion/EqualAssertion.js";
|
|
15
|
+
import { INotEqualAssertion } from "../../models/http-flows/steps/assertion/NotEqualAssertion.js";
|
|
16
|
+
import { IGreaterThanAssertion } from "../../models/http-flows/steps/assertion/GreaterThanAssertion.js";
|
|
17
|
+
import { ILessThanAssertion } from "../../models/http-flows/steps/assertion/LessThanAssertion.js";
|
|
18
|
+
import { IIncludesAssertion } from "../../models/http-flows/steps/assertion/IncludesAssertion.js";
|
|
19
|
+
import { INotIncludesAssertion } from "../../models/http-flows/steps/assertion/NotIncludesAssertion.js";
|
|
20
|
+
import { IToBeAssertion } from '../../models/http-flows/steps/assertion/ToBeAssertion.js';
|
|
21
|
+
import { INotToBeAssertion } from '../../models/http-flows/steps/assertion/NotToBeAssertion.js';
|
|
22
|
+
import { ILengthOfAssertion } from '../../models/http-flows/steps/assertion/LengthOfAssertion.js';
|
|
23
|
+
import { IReadDataStep } from "../../models/http-flows/steps/data/ReadDataStep.js";
|
|
24
|
+
import { ISetDataStep } from "../../models/http-flows/steps/data/SetDataStep.js";
|
|
25
|
+
import { ISetVariableStep } from "../../models/http-flows/steps/data/SetVariableStep.js";
|
|
26
|
+
import { ISetCookieStep } from "../../models/http-flows/steps/data/SetCookieStep.js";
|
|
27
|
+
import { IDeleteCookieStep } from "../../models/http-flows/steps/data/DeleteCookieStep.js";
|
|
28
|
+
export interface IStepValue {
|
|
29
|
+
value: FlowValue;
|
|
30
|
+
type?: FlowRequestDataEnum | FlowResponseDataEnum;
|
|
31
|
+
bodyMime?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A class that supports both assertions and flows.
|
|
35
|
+
* The derived classes specializes in a specific user flow (either performing flow actions or running assertions).
|
|
36
|
+
*/
|
|
37
|
+
export declare class HttpFlows {
|
|
38
|
+
/**
|
|
39
|
+
* The cumulative list of all variables to be applied to the request and other properties.
|
|
40
|
+
* The variables must be already processed for variables in values (evaluated).
|
|
41
|
+
*
|
|
42
|
+
* These variables are passed by reference. Changes made anywhere to the variables will result
|
|
43
|
+
* with updating this list.
|
|
44
|
+
*/
|
|
45
|
+
variables?: Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* An instance of a cookie jar (store) to put/read cookies.
|
|
48
|
+
*/
|
|
49
|
+
cookies?: CookieJar;
|
|
50
|
+
protected runStep(request: ISentRequest | IHttpRequest, step: IHttpStep, input: IStepValue, response?: IResponse | IErrorResponse): Promise<IStepValue>;
|
|
51
|
+
/**
|
|
52
|
+
* Produces the data source.
|
|
53
|
+
*/
|
|
54
|
+
protected readDataSource(request: ISentRequest | IHttpRequest, step: IReadDataSourceStep, response?: IResponse | IErrorResponse): Promise<IStepValue>;
|
|
55
|
+
protected processBody(input: HttpRequest | HttpResponse | ErrorResponse): Promise<IStepValue>;
|
|
56
|
+
/**
|
|
57
|
+
* Produces the value from the current input.
|
|
58
|
+
*/
|
|
59
|
+
protected readValue(input: IStepValue, step: IReadValueStep): Promise<IStepValue>;
|
|
60
|
+
protected toLowerCase(input: IStepValue): Promise<IStepValue>;
|
|
61
|
+
protected toUpperCase(input: IStepValue): Promise<IStepValue>;
|
|
62
|
+
protected asNumber(input: IStepValue): Promise<IStepValue>;
|
|
63
|
+
protected round(input: IStepValue, step: IRoundStep): Promise<IStepValue>;
|
|
64
|
+
protected trim(input: IStepValue): Promise<IStepValue>;
|
|
65
|
+
protected substring(input: IStepValue, step: ISubstringStep): Promise<IStepValue>;
|
|
66
|
+
protected assertEqual(input: IStepValue, step: IEqualAssertion): Promise<IStepValue>;
|
|
67
|
+
protected assertNotEqual(input: IStepValue, step: INotEqualAssertion): Promise<IStepValue>;
|
|
68
|
+
protected assertGreaterThan(input: IStepValue, step: IGreaterThanAssertion): Promise<IStepValue>;
|
|
69
|
+
protected assertLessThan(input: IStepValue, step: ILessThanAssertion): Promise<IStepValue>;
|
|
70
|
+
protected assertIncludes(input: IStepValue, step: IIncludesAssertion): Promise<IStepValue>;
|
|
71
|
+
protected assertNotIncludes(input: IStepValue, step: INotIncludesAssertion): Promise<IStepValue>;
|
|
72
|
+
protected assertOk(input: IStepValue): Promise<IStepValue>;
|
|
73
|
+
protected assertNotOk(input: IStepValue): Promise<IStepValue>;
|
|
74
|
+
protected toBe(input: IStepValue, step: IToBeAssertion): Promise<IStepValue>;
|
|
75
|
+
protected notToBe(input: IStepValue, step: INotToBeAssertion): Promise<IStepValue>;
|
|
76
|
+
protected isEmpty(input: IStepValue): Promise<IStepValue>;
|
|
77
|
+
protected isNotEmpty(input: IStepValue): Promise<IStepValue>;
|
|
78
|
+
protected lengthOf(input: IStepValue, step: ILengthOfAssertion): Promise<IStepValue>;
|
|
79
|
+
protected isPrimitive(value: unknown): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* A step that reads data from the request, response, or variables.
|
|
82
|
+
*
|
|
83
|
+
* @param step The step configuration.
|
|
84
|
+
* @param request The HttpRequest or the SentRequest (for responses)
|
|
85
|
+
* @param response When available, the response data
|
|
86
|
+
* @returns The read value or undefined.
|
|
87
|
+
*/
|
|
88
|
+
runReadDataStep(input: IStepValue, step: IReadDataStep, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<IStepValue>;
|
|
89
|
+
/**
|
|
90
|
+
* A step that returns a pre-configured value.
|
|
91
|
+
*
|
|
92
|
+
* @param step The step configuration.
|
|
93
|
+
* @returns The read value with applied data type.
|
|
94
|
+
*/
|
|
95
|
+
runSetDataStep(input: IStepValue, step: ISetDataStep): IStepValue;
|
|
96
|
+
/**
|
|
97
|
+
* A step that sets a variable in the current environment.
|
|
98
|
+
* Note, this passes the step value through.
|
|
99
|
+
*
|
|
100
|
+
* @param step The step configuration.
|
|
101
|
+
* @param value The value to set. A value that is `null` or `undefined` deletes the variable.
|
|
102
|
+
*/
|
|
103
|
+
runSetVariableStep(input: IStepValue, step: ISetVariableStep): IStepValue;
|
|
104
|
+
/**
|
|
105
|
+
* A step that sets a cookie.
|
|
106
|
+
* Note, this passes the step value through.
|
|
107
|
+
*
|
|
108
|
+
* @param step The step configuration.
|
|
109
|
+
* @param value The value to sent on the cookie.
|
|
110
|
+
* @param request The request object.
|
|
111
|
+
*/
|
|
112
|
+
runSetCookieStep(input: IStepValue, step: ISetCookieStep, request: IHttpRequest | ISentRequest): Promise<IStepValue>;
|
|
113
|
+
/**
|
|
114
|
+
* A step to delete cookies from the cookie jar.
|
|
115
|
+
*
|
|
116
|
+
* Note, this passes the step value through.
|
|
117
|
+
*/
|
|
118
|
+
runDeleteCookieStep(input: IStepValue, step: IDeleteCookieStep, request: IHttpRequest | ISentRequest): Promise<IStepValue>;
|
|
119
|
+
}
|