@api-client/core 0.9.22 → 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/RequestProxy.d.ts +2 -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/RequestProxy.ts +2 -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
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { assert } from '@esm-bundle/chai';
|
|
2
|
+
import { HttpRequest, IHttpRequest } from "../../models/HttpRequest.js";
|
|
3
|
+
import { ISentRequest } from "../../models/SentRequest.js";
|
|
4
|
+
import { CookieJar } from "../../cookies/CookieJar.js";
|
|
5
|
+
import { IResponse } from "../../models/Response.js";
|
|
6
|
+
import { ErrorResponse, IErrorResponse } from "../../models/ErrorResponse.js";
|
|
7
|
+
import { IHttpStep } from "../../models/http-flows/HttpStep.js";
|
|
8
|
+
import { FlowValue } from "./HttpFlowRunner.js";
|
|
9
|
+
import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from "../../models/http-flows/HttpFlows.js";
|
|
10
|
+
import { IReadDataSourceStep, ReadDataSourceStep, ReadDataSourceStepKind } from "../../models/http-flows/steps/data/ReadDataSourceStep.js";
|
|
11
|
+
import { IReadValueStep, ReadValueStep, ReadValueStepKind } from "../../models/http-flows/steps/data/ReadValueStep.js";
|
|
12
|
+
import { HttpCookie } from "../../models/HttpCookie.js";
|
|
13
|
+
import { HttpResponse } from "../../models/HttpResponse.js";
|
|
14
|
+
import { Headers } from '../../lib/headers/Headers.js';
|
|
15
|
+
import { DataExtractor } from '../../data/DataExtractor.js';
|
|
16
|
+
import { RequestDataExtractor } from "../../data/RequestDataExtractor.js";
|
|
17
|
+
import { SameSiteValue } from "../../cookies/CookieParser.js";
|
|
18
|
+
import { AsLowerCaseStepKind } from "../../models/http-flows/steps/transformation/AsLowerCaseStep.js";
|
|
19
|
+
import { AsUpperCaseStepKind } from "../../models/http-flows/steps/transformation/AsUpperCaseStep.js";
|
|
20
|
+
import { AsNumberStepKind } from "../../models/http-flows/steps/transformation/AsNumberStep.js";
|
|
21
|
+
import { IRoundStep, RoundStepKind } from "../../models/http-flows/steps/transformation/RoundStep.js";
|
|
22
|
+
import { ISubstringStep, SubstringStepKind } from "../../models/http-flows/steps/transformation/SubstringStep.js";
|
|
23
|
+
import { TrimStepKind } from "../../models/http-flows/steps/transformation/TrimStep.js";
|
|
24
|
+
import { EqualAssertionKind, IEqualAssertion } from "../../models/http-flows/steps/assertion/EqualAssertion.js";
|
|
25
|
+
import { INotEqualAssertion, NotEqualAssertionKind } from "../../models/http-flows/steps/assertion/NotEqualAssertion.js";
|
|
26
|
+
import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
|
|
27
|
+
import { GreaterThanAssertionKind, IGreaterThanAssertion } from "../../models/http-flows/steps/assertion/GreaterThanAssertion.js";
|
|
28
|
+
import { ILessThanAssertion, LessThanAssertionKind } from "../../models/http-flows/steps/assertion/LessThanAssertion.js";
|
|
29
|
+
import { IIncludesAssertion, IncludesAssertionKind } from "../../models/http-flows/steps/assertion/IncludesAssertion.js";
|
|
30
|
+
import { INotIncludesAssertion, NotIncludesAssertionKind } from "../../models/http-flows/steps/assertion/NotIncludesAssertion.js";
|
|
31
|
+
import { OkAssertionKind } from "../../models/http-flows/steps/assertion/OkAssertion.js";
|
|
32
|
+
import { NotOkAssertionKind } from "../../models/http-flows/steps/assertion/NotOkAssertion.js";
|
|
33
|
+
import { IToBeAssertion, ToBeAssertionKind, ToBeTypes } from '../../models/http-flows/steps/assertion/ToBeAssertion.js';
|
|
34
|
+
import { INotToBeAssertion, NotToBeAssertionKind } from '../../models/http-flows/steps/assertion/NotToBeAssertion.js';
|
|
35
|
+
import { IsEmptyAssertionKind } from '../../models/http-flows/steps/assertion/IsEmptyAssertion.js';
|
|
36
|
+
import { IsNotEmptyAssertionKind } from '../../models/http-flows/steps/assertion/IsNotEmptyAssertion.js';
|
|
37
|
+
import { ILengthOfAssertion, LengthOfAssertionKind } from '../../models/http-flows/steps/assertion/LengthOfAssertion.js';
|
|
38
|
+
import { IReadDataStep, ReadDataStep, ReadDataStepKind } from "../../models/http-flows/steps/data/ReadDataStep.js";
|
|
39
|
+
import { ISetDataStep, SetDataStep, SetDataStepKind } from "../../models/http-flows/steps/data/SetDataStep.js";
|
|
40
|
+
import { ISetVariableStep, SetVariableStep, SetVariableStepKind } from "../../models/http-flows/steps/data/SetVariableStep.js";
|
|
41
|
+
import { ISetCookieStep, SetCookieStep, SetCookieStepKind } from "../../models/http-flows/steps/data/SetCookieStep.js";
|
|
42
|
+
import { DeleteCookieStep, DeleteCookieStepKind, IDeleteCookieStep } from "../../models/http-flows/steps/data/DeleteCookieStep.js";
|
|
43
|
+
|
|
44
|
+
export interface IStepValue {
|
|
45
|
+
value: FlowValue;
|
|
46
|
+
type?: FlowRequestDataEnum | FlowResponseDataEnum;
|
|
47
|
+
bodyMime?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A class that supports both assertions and flows.
|
|
52
|
+
* The derived classes specializes in a specific user flow (either performing flow actions or running assertions).
|
|
53
|
+
*/
|
|
54
|
+
export class HttpFlows {
|
|
55
|
+
/**
|
|
56
|
+
* The cumulative list of all variables to be applied to the request and other properties.
|
|
57
|
+
* The variables must be already processed for variables in values (evaluated).
|
|
58
|
+
*
|
|
59
|
+
* These variables are passed by reference. Changes made anywhere to the variables will result
|
|
60
|
+
* with updating this list.
|
|
61
|
+
*/
|
|
62
|
+
variables?: Record<string, string>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An instance of a cookie jar (store) to put/read cookies.
|
|
66
|
+
*/
|
|
67
|
+
cookies?: CookieJar;
|
|
68
|
+
|
|
69
|
+
protected async runStep(request: ISentRequest | IHttpRequest, step: IHttpStep, input: IStepValue, response?: IResponse | IErrorResponse): Promise<IStepValue> {
|
|
70
|
+
switch (step.kind) {
|
|
71
|
+
// data reading
|
|
72
|
+
case ReadDataSourceStepKind: return this.readDataSource(request, step, response);
|
|
73
|
+
case ReadValueStepKind: return this.readValue(input, step as IReadValueStep);
|
|
74
|
+
case ReadDataStepKind: return this.runReadDataStep(input, step as IReadDataStep, request, response);
|
|
75
|
+
case SetDataStepKind: return this.runSetDataStep(input, step as ISetDataStep);
|
|
76
|
+
case SetVariableStepKind: return this.runSetVariableStep(input, step as ISetVariableStep);
|
|
77
|
+
case SetCookieStepKind: return this.runSetCookieStep(input, step as ISetCookieStep, request);
|
|
78
|
+
case DeleteCookieStepKind: return this.runDeleteCookieStep(input, step as IDeleteCookieStep, request);
|
|
79
|
+
// transformations
|
|
80
|
+
case AsLowerCaseStepKind: return this.toLowerCase(input);
|
|
81
|
+
case AsUpperCaseStepKind: return this.toUpperCase(input);
|
|
82
|
+
case AsNumberStepKind: return this.asNumber(input);
|
|
83
|
+
case RoundStepKind: return this.round(input, step as IRoundStep);
|
|
84
|
+
case TrimStepKind: return this.trim(input);
|
|
85
|
+
case SubstringStepKind: return this.substring(input, step as ISubstringStep);
|
|
86
|
+
// assertions
|
|
87
|
+
case EqualAssertionKind: return this.assertEqual(input, step as IEqualAssertion);
|
|
88
|
+
case NotEqualAssertionKind: return this.assertNotEqual(input, step as INotEqualAssertion);
|
|
89
|
+
case GreaterThanAssertionKind: return this.assertGreaterThan(input, step as IGreaterThanAssertion);
|
|
90
|
+
case LessThanAssertionKind: return this.assertLessThan(input, step as ILessThanAssertion);
|
|
91
|
+
case IncludesAssertionKind: return this.assertIncludes(input, step as IIncludesAssertion);
|
|
92
|
+
case NotIncludesAssertionKind: return this.assertNotIncludes(input, step as INotIncludesAssertion);
|
|
93
|
+
case OkAssertionKind: return this.assertOk(input);
|
|
94
|
+
case NotOkAssertionKind: return this.assertNotOk(input);
|
|
95
|
+
case ToBeAssertionKind: return this.toBe(input, step as IToBeAssertion);
|
|
96
|
+
case NotToBeAssertionKind: return this.notToBe(input, step as INotToBeAssertion);
|
|
97
|
+
case IsEmptyAssertionKind: return this.isEmpty(input);
|
|
98
|
+
case IsNotEmptyAssertionKind: return this.isNotEmpty(input);
|
|
99
|
+
case LengthOfAssertionKind: return this.lengthOf(input, step as ILengthOfAssertion);
|
|
100
|
+
default: return { value: undefined };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Produces the data source.
|
|
106
|
+
*/
|
|
107
|
+
protected async readDataSource(request: ISentRequest | IHttpRequest, step: IReadDataSourceStep, response?: IResponse | IErrorResponse): Promise<IStepValue> {
|
|
108
|
+
const instance = new ReadDataSourceStep(step);
|
|
109
|
+
if (instance.enabled === false || !instance.checkValidity()) {
|
|
110
|
+
return { value: undefined };
|
|
111
|
+
}
|
|
112
|
+
const { source, data } = step;
|
|
113
|
+
if (data && [FlowRequestDataEnum.headers, FlowResponseDataEnum.headers].includes(data)) {
|
|
114
|
+
return {
|
|
115
|
+
value: DataExtractor.readHeaders(source === FlowSourceEnum.request ? request : response),
|
|
116
|
+
type: data,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (data && [FlowRequestDataEnum.url, FlowResponseDataEnum.url].includes(data)) {
|
|
120
|
+
return {
|
|
121
|
+
value: request.method,
|
|
122
|
+
type: data,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (source === FlowSourceEnum.request) {
|
|
127
|
+
if (data === FlowRequestDataEnum.method) {
|
|
128
|
+
return {
|
|
129
|
+
value: request.method,
|
|
130
|
+
type: data,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (data === FlowRequestDataEnum.body) {
|
|
134
|
+
const instance = new HttpRequest(request);
|
|
135
|
+
const value = await this.processBody(instance);
|
|
136
|
+
return {
|
|
137
|
+
...value,
|
|
138
|
+
type: data,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (source === FlowSourceEnum.response) {
|
|
143
|
+
if (!response) {
|
|
144
|
+
return {
|
|
145
|
+
type: data,
|
|
146
|
+
value: undefined,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (data === FlowResponseDataEnum.status) {
|
|
150
|
+
return {
|
|
151
|
+
value: response.status,
|
|
152
|
+
type: data,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (data === FlowResponseDataEnum.statusText) {
|
|
156
|
+
return {
|
|
157
|
+
value: response.statusText,
|
|
158
|
+
type: data,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (data === FlowResponseDataEnum.body) {
|
|
162
|
+
let instance: ErrorResponse | HttpResponse;
|
|
163
|
+
if (ErrorResponse.isErrorResponse(response)) {
|
|
164
|
+
instance = new ErrorResponse(response as IErrorResponse);
|
|
165
|
+
} else {
|
|
166
|
+
instance = new HttpResponse(response);
|
|
167
|
+
}
|
|
168
|
+
const value = await this.processBody(instance);
|
|
169
|
+
return {
|
|
170
|
+
...value,
|
|
171
|
+
type: data,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { value: undefined };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
protected async processBody(input: HttpRequest | HttpResponse | ErrorResponse): Promise<IStepValue> {
|
|
179
|
+
const { headers } = input;
|
|
180
|
+
if (!headers) {
|
|
181
|
+
return { value: undefined };
|
|
182
|
+
}
|
|
183
|
+
const body = await input.readPayloadAsString();
|
|
184
|
+
if (!body) {
|
|
185
|
+
return { value: undefined };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const parser = new Headers(headers);
|
|
189
|
+
const mime = parser.get('content-type');
|
|
190
|
+
if (!mime) {
|
|
191
|
+
return { value: undefined };
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
value: body,
|
|
195
|
+
bodyMime: mime,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Produces the value from the current input.
|
|
201
|
+
*/
|
|
202
|
+
protected async readValue(input: IStepValue, step: IReadValueStep): Promise<IStepValue> {
|
|
203
|
+
const instance = new ReadValueStep(step);
|
|
204
|
+
if (instance.enabled === false || !instance.checkValidity() || input.value === undefined || input.value === null) {
|
|
205
|
+
return { value: undefined };
|
|
206
|
+
}
|
|
207
|
+
const { path } = step;
|
|
208
|
+
const { type, value } = input;
|
|
209
|
+
const args = path ? path.split('.') : [];
|
|
210
|
+
if (type === FlowRequestDataEnum.url || type === FlowResponseDataEnum.url) {
|
|
211
|
+
if (!value) {
|
|
212
|
+
return { value: undefined };
|
|
213
|
+
}
|
|
214
|
+
const v = String(input.value);
|
|
215
|
+
return {
|
|
216
|
+
value: DataExtractor.getDataUrl(v, args),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
if (type === FlowRequestDataEnum.headers || type === FlowResponseDataEnum.headers) {
|
|
220
|
+
if (!value) {
|
|
221
|
+
return { value: undefined };
|
|
222
|
+
}
|
|
223
|
+
const v = String(input.value);
|
|
224
|
+
return {
|
|
225
|
+
value: DataExtractor.getDataHeaders(v, args),
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (type === FlowRequestDataEnum.body || type === FlowResponseDataEnum.body) {
|
|
229
|
+
if (!input.bodyMime || !path) {
|
|
230
|
+
return { value: undefined };
|
|
231
|
+
}
|
|
232
|
+
const readValue = await DataExtractor.extractBody(String(value), input.bodyMime, path);
|
|
233
|
+
return {
|
|
234
|
+
value: readValue,
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (type === FlowResponseDataEnum.status) {
|
|
238
|
+
const v = Number(input.value);
|
|
239
|
+
if (Number.isNaN(v)) {
|
|
240
|
+
return { value: undefined };
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
value: v,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (type === FlowResponseDataEnum.statusText) {
|
|
248
|
+
if (!value) {
|
|
249
|
+
return { value: undefined };
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
value,
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return { value: undefined };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
protected async toLowerCase(input: IStepValue): Promise<IStepValue> {
|
|
259
|
+
if (input.value === null || input.value === undefined) {
|
|
260
|
+
return { value: undefined };
|
|
261
|
+
}
|
|
262
|
+
const value = String(input.value);
|
|
263
|
+
return { value: value.toLowerCase() };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
protected async toUpperCase(input: IStepValue): Promise<IStepValue> {
|
|
267
|
+
if (input.value === null || input.value === undefined) {
|
|
268
|
+
return { value: undefined };
|
|
269
|
+
}
|
|
270
|
+
const value = String(input.value);
|
|
271
|
+
return { value: value.toUpperCase() };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
protected async asNumber(input: IStepValue): Promise<IStepValue> {
|
|
275
|
+
if (input.value === null || input.value === undefined) {
|
|
276
|
+
return { value: undefined };
|
|
277
|
+
}
|
|
278
|
+
const value = String(input.value);
|
|
279
|
+
const parsed = Number(value);
|
|
280
|
+
if (Number.isNaN(parsed)) {
|
|
281
|
+
return { value: undefined };
|
|
282
|
+
}
|
|
283
|
+
return { value: parsed };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
protected async round(input: IStepValue, step: IRoundStep): Promise<IStepValue> {
|
|
287
|
+
if (input.value === null || input.value === undefined) {
|
|
288
|
+
return { value: undefined };
|
|
289
|
+
}
|
|
290
|
+
const value = String(input.value);
|
|
291
|
+
const parsed = typeof input.value === 'number' ? input.value : Number(value);
|
|
292
|
+
if (Number.isNaN(parsed)) {
|
|
293
|
+
return { value: undefined };
|
|
294
|
+
}
|
|
295
|
+
return { value: parsed.toFixed(step.precision) };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
protected async trim(input: IStepValue): Promise<IStepValue> {
|
|
299
|
+
if (input.value === null || input.value === undefined) {
|
|
300
|
+
return { value: undefined };
|
|
301
|
+
}
|
|
302
|
+
const value = String(input.value);
|
|
303
|
+
return { ...input, value: value.trim() };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
protected async substring(input: IStepValue, step: ISubstringStep): Promise<IStepValue> {
|
|
307
|
+
if (input.value === null || input.value === undefined) {
|
|
308
|
+
return { value: undefined };
|
|
309
|
+
}
|
|
310
|
+
if (typeof step.start !== 'number') {
|
|
311
|
+
return input;
|
|
312
|
+
}
|
|
313
|
+
const value = String(input.value);
|
|
314
|
+
return { ...input, value: value.substring(step.start, step.end) };
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
protected async assertEqual(input: IStepValue, step: IEqualAssertion): Promise<IStepValue> {
|
|
318
|
+
const { value } = input;
|
|
319
|
+
if (step.strict) {
|
|
320
|
+
const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
|
|
321
|
+
assert.strictEqual(value, comparator);
|
|
322
|
+
} else {
|
|
323
|
+
assert.equal(String(value), step.value);
|
|
324
|
+
}
|
|
325
|
+
return input;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
protected async assertNotEqual(input: IStepValue, step: INotEqualAssertion): Promise<IStepValue> {
|
|
329
|
+
const { value } = input;
|
|
330
|
+
if (step.strict) {
|
|
331
|
+
const comparator = ApiSchemaValues.readTypedValue(step.value, step.dataType);
|
|
332
|
+
assert.notStrictEqual(value, comparator);
|
|
333
|
+
} else {
|
|
334
|
+
assert.notEqual(value, step.value);
|
|
335
|
+
}
|
|
336
|
+
return input;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
protected async assertGreaterThan(input: IStepValue, step: IGreaterThanAssertion): Promise<IStepValue> {
|
|
340
|
+
assert.typeOf(input.value, 'number');
|
|
341
|
+
const value = input.value as number;
|
|
342
|
+
if (step.equal) {
|
|
343
|
+
assert.isAtLeast(value as number, step.value as number);
|
|
344
|
+
} else {
|
|
345
|
+
assert.isAbove(value as number, step.value as number);
|
|
346
|
+
}
|
|
347
|
+
return input;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
protected async assertLessThan(input: IStepValue, step: ILessThanAssertion): Promise<IStepValue> {
|
|
351
|
+
assert.typeOf(input.value, 'number');
|
|
352
|
+
const value = input.value as number;
|
|
353
|
+
if (step.equal) {
|
|
354
|
+
assert.isAtMost(value, step.value as number);
|
|
355
|
+
} else {
|
|
356
|
+
assert.isBelow(value, step.value as number);
|
|
357
|
+
}
|
|
358
|
+
return input;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
protected async assertIncludes(input: IStepValue, step: IIncludesAssertion): Promise<IStepValue> {
|
|
362
|
+
if (this.isPrimitive(input.value)) {
|
|
363
|
+
assert.include(String(input.value), String(step.value));
|
|
364
|
+
} else {
|
|
365
|
+
assert.include(JSON.stringify(input.value), String(step.value));
|
|
366
|
+
}
|
|
367
|
+
return input;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
protected async assertNotIncludes(input: IStepValue, step: INotIncludesAssertion): Promise<IStepValue> {
|
|
371
|
+
if (this.isPrimitive(input.value)) {
|
|
372
|
+
assert.notInclude(String(input.value), String(step.value));
|
|
373
|
+
} else {
|
|
374
|
+
assert.notInclude(JSON.stringify(input.value), String(step.value));
|
|
375
|
+
}
|
|
376
|
+
return input;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
protected async assertOk(input: IStepValue): Promise<IStepValue> {
|
|
380
|
+
assert.ok(input.value);
|
|
381
|
+
return input;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
protected async assertNotOk(input: IStepValue): Promise<IStepValue> {
|
|
385
|
+
assert.notOk(input.value);
|
|
386
|
+
return input;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
protected async toBe(input: IStepValue, step: IToBeAssertion): Promise<IStepValue> {
|
|
390
|
+
assert.typeOf(input.value, step.value as string);
|
|
391
|
+
return input;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
protected async notToBe(input: IStepValue, step: INotToBeAssertion): Promise<IStepValue> {
|
|
395
|
+
if (Array.isArray(input.value) && step.value === ToBeTypes.object) {
|
|
396
|
+
assert(false, 'expected [Array] to be an object');
|
|
397
|
+
}
|
|
398
|
+
assert.notTypeOf(input.value, step.value as string);
|
|
399
|
+
return input;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
protected async isEmpty(input: IStepValue): Promise<IStepValue> {
|
|
403
|
+
assert.isEmpty(input.value);
|
|
404
|
+
return input;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
protected async isNotEmpty(input: IStepValue): Promise<IStepValue> {
|
|
408
|
+
assert.isNotEmpty(input.value);
|
|
409
|
+
return input;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
protected async lengthOf(input: IStepValue, step: ILengthOfAssertion): Promise<IStepValue> {
|
|
413
|
+
assert.lengthOf(input.value as unknown[], step.value as number);
|
|
414
|
+
return input;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
protected isPrimitive(value: unknown): boolean {
|
|
418
|
+
return (typeof value !== 'object' && typeof value !== 'function') || value === null;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* A step that reads data from the request, response, or variables.
|
|
423
|
+
*
|
|
424
|
+
* @param step The step configuration.
|
|
425
|
+
* @param request The HttpRequest or the SentRequest (for responses)
|
|
426
|
+
* @param response When available, the response data
|
|
427
|
+
* @returns The read value or undefined.
|
|
428
|
+
*/
|
|
429
|
+
async runReadDataStep(input: IStepValue, step: IReadDataStep, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<IStepValue> {
|
|
430
|
+
const instance = new ReadDataStep(step);
|
|
431
|
+
|
|
432
|
+
if (instance.enabled === false || !instance.checkValidity()) {
|
|
433
|
+
return input;
|
|
434
|
+
}
|
|
435
|
+
const { source, data, path } = step;
|
|
436
|
+
if (source === FlowSourceEnum.request) {
|
|
437
|
+
const extractor = new RequestDataExtractor(request);
|
|
438
|
+
const value = await extractor.extract(source, data, path);
|
|
439
|
+
return { ...input, value };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (source === FlowSourceEnum.response) {
|
|
443
|
+
const extractor = new RequestDataExtractor(request, response);
|
|
444
|
+
const value = await extractor.extract(source, data, path);
|
|
445
|
+
return { ...input, value };
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (source === FlowSourceEnum.variable && path && this.variables) {
|
|
449
|
+
const value = this.variables[path];
|
|
450
|
+
return { ...input, value };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return { ...input, value: undefined };
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* A step that returns a pre-configured value.
|
|
458
|
+
*
|
|
459
|
+
* @param step The step configuration.
|
|
460
|
+
* @returns The read value with applied data type.
|
|
461
|
+
*/
|
|
462
|
+
runSetDataStep(input: IStepValue, step: ISetDataStep): IStepValue {
|
|
463
|
+
const instance = new SetDataStep(step);
|
|
464
|
+
if (instance.enabled === false || !instance.checkValidity()) {
|
|
465
|
+
return input;
|
|
466
|
+
}
|
|
467
|
+
const { value, dataType } = step;
|
|
468
|
+
if (value === null || value === undefined) {
|
|
469
|
+
return { ...input, value: undefined };
|
|
470
|
+
}
|
|
471
|
+
const result = ApiSchemaValues.parseScalar(value, dataType);
|
|
472
|
+
return {
|
|
473
|
+
...input,
|
|
474
|
+
value: result,
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* A step that sets a variable in the current environment.
|
|
480
|
+
* Note, this passes the step value through.
|
|
481
|
+
*
|
|
482
|
+
* @param step The step configuration.
|
|
483
|
+
* @param value The value to set. A value that is `null` or `undefined` deletes the variable.
|
|
484
|
+
*/
|
|
485
|
+
runSetVariableStep(input: IStepValue, step: ISetVariableStep): IStepValue {
|
|
486
|
+
const instance = new SetVariableStep(step);
|
|
487
|
+
if (instance.enabled === false || !instance.checkValidity() || !this.variables) {
|
|
488
|
+
return input;
|
|
489
|
+
}
|
|
490
|
+
if (input.value === null || input.value === undefined) {
|
|
491
|
+
return input;
|
|
492
|
+
}
|
|
493
|
+
const { name } = step;
|
|
494
|
+
this.variables[name] = String(input.value);
|
|
495
|
+
return input;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* A step that sets a cookie.
|
|
500
|
+
* Note, this passes the step value through.
|
|
501
|
+
*
|
|
502
|
+
* @param step The step configuration.
|
|
503
|
+
* @param value The value to sent on the cookie.
|
|
504
|
+
* @param request The request object.
|
|
505
|
+
*/
|
|
506
|
+
async runSetCookieStep(input: IStepValue, step: ISetCookieStep, request: IHttpRequest | ISentRequest): Promise<IStepValue> {
|
|
507
|
+
const instance = new SetCookieStep(step);
|
|
508
|
+
const { cookies } = this;
|
|
509
|
+
if (instance.enabled === false || !instance.checkValidity() || !cookies) {
|
|
510
|
+
return input;
|
|
511
|
+
}
|
|
512
|
+
if (input.value === null || input.value === undefined) {
|
|
513
|
+
return input;
|
|
514
|
+
}
|
|
515
|
+
const { name, expires, hostOnly, httpOnly, sameSite, secure, session } = step;
|
|
516
|
+
const typedValue = String(input.value);
|
|
517
|
+
let url: string;
|
|
518
|
+
if (step.url) {
|
|
519
|
+
url = step.url;
|
|
520
|
+
} else {
|
|
521
|
+
url = request.url;
|
|
522
|
+
}
|
|
523
|
+
const cookie = new HttpCookie({
|
|
524
|
+
name: name,
|
|
525
|
+
value: typedValue,
|
|
526
|
+
sameSite: 'unspecified',
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
if (sameSite) {
|
|
530
|
+
const typed = sameSite as SameSiteValue;
|
|
531
|
+
switch (typed.toLowerCase()) {
|
|
532
|
+
case 'lax': cookie.sameSite = 'lax'; break;
|
|
533
|
+
case 'strict': cookie.sameSite = 'strict'; break;
|
|
534
|
+
case 'none': cookie.sameSite = 'no_restriction'; break;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (expires) {
|
|
538
|
+
cookie.expirationDate = expires;
|
|
539
|
+
}
|
|
540
|
+
if (typeof hostOnly === 'boolean') {
|
|
541
|
+
cookie.hostOnly = hostOnly;
|
|
542
|
+
}
|
|
543
|
+
if (typeof httpOnly === 'boolean') {
|
|
544
|
+
cookie.httpOnly = httpOnly;
|
|
545
|
+
}
|
|
546
|
+
if (typeof secure === 'boolean') {
|
|
547
|
+
cookie.secure = secure;
|
|
548
|
+
}
|
|
549
|
+
if (typeof session === 'boolean') {
|
|
550
|
+
cookie.session = session;
|
|
551
|
+
}
|
|
552
|
+
await cookies.setCookies(url, [cookie]);
|
|
553
|
+
return input;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* A step to delete cookies from the cookie jar.
|
|
558
|
+
*
|
|
559
|
+
* Note, this passes the step value through.
|
|
560
|
+
*/
|
|
561
|
+
async runDeleteCookieStep(input: IStepValue, step: IDeleteCookieStep, request: IHttpRequest | ISentRequest): Promise<IStepValue> {
|
|
562
|
+
const instance = new DeleteCookieStep(step);
|
|
563
|
+
const { cookies } = this;
|
|
564
|
+
if (instance.enabled === false || !instance.checkValidity() || !cookies) {
|
|
565
|
+
return input;
|
|
566
|
+
}
|
|
567
|
+
let url: string;
|
|
568
|
+
if (step.url) {
|
|
569
|
+
url = step.url;
|
|
570
|
+
} else {
|
|
571
|
+
url = request.url;
|
|
572
|
+
}
|
|
573
|
+
await cookies.deleteCookies(url, step.name);
|
|
574
|
+
return input;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
@@ -4,8 +4,8 @@ import { IRequestConfig } from '../../models/RequestConfig.js';
|
|
|
4
4
|
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
5
5
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
6
6
|
import { VariablesProcessor } from '../variables/VariablesProcessor.js';
|
|
7
|
-
import { IHttpFlow } from '../../models/http-
|
|
8
|
-
import { AssertionResult, IHttpAssertion } from '../../models/http-
|
|
7
|
+
import { IHttpFlow } from '../../models/http-flows/HttpFlows.js';
|
|
8
|
+
import { AssertionResult, IHttpAssertion } from '../../models/http-flows/HttpAssertion.js';
|
|
9
9
|
import { HttpEngineOptions } from '../http-engine/HttpEngine.js';
|
|
10
10
|
import { CoreEngine } from '../http-engine/CoreEngine.js';
|
|
11
11
|
import { Logger } from '../../lib/logging/Logger.js';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads value of the URL query parameters.
|
|
3
|
-
*
|
|
4
|
-
* The `?` at the beginning of the query string is removed.
|
|
5
|
-
*
|
|
6
|
-
* @param url The URL object instance
|
|
7
|
-
* @param param Param name to return. If not set then it returns whole query string value.
|
|
8
|
-
* @return Full query string value if `param` is not set or parameter
|
|
9
|
-
* value. This function does not returns `null` values.
|
|
10
|
-
*/
|
|
11
|
-
export declare function readUrlQueryValue(url: URL, param?: string): string | null;
|
|
12
|
-
/**
|
|
13
|
-
* Reads value of the URL hash.
|
|
14
|
-
*
|
|
15
|
-
* The `#` at the beginning of the hash string is removed.
|
|
16
|
-
*
|
|
17
|
-
* If the `param` argument is set then it treats hahs value as a query
|
|
18
|
-
* parameters string and parses it to get the value.
|
|
19
|
-
*
|
|
20
|
-
* @param url The URL object instance
|
|
21
|
-
* @param param Param name to return. If not set then it returns whole hash string value.
|
|
22
|
-
* @return Hash parameter or whole hash value.
|
|
23
|
-
*/
|
|
24
|
-
export declare function readUrlHashValue(url: URL, param?: string): string | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Returns the value for path for given source object
|
|
27
|
-
*
|
|
28
|
-
* @param url An url to parse.
|
|
29
|
-
* @param path Path to the data
|
|
30
|
-
* @return Value for the path.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getDataUrl(url: string, path: string[]): string | number | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Returns a value for the headers.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} source HTTP headers string
|
|
37
|
-
* @param {string[]} path Path to the object
|
|
38
|
-
* @return {string|undefined} Value for the path.
|
|
39
|
-
*/
|
|
40
|
-
export declare function getDataHeaders(source: string, path: string[]): string | undefined;
|