@api-client/core 0.9.4 → 0.9.6

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.
Files changed (256) hide show
  1. package/build/browser.d.ts +14 -3
  2. package/build/browser.js +16 -2
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +15 -4
  5. package/build/index.js +17 -3
  6. package/build/index.js.map +1 -1
  7. package/build/src/data/{JmesparthReader.d.ts → JmespathReader.d.ts} +1 -1
  8. package/build/src/data/{JmesparthReader.js → JmespathReader.js} +2 -2
  9. package/build/src/data/JmespathReader.js.map +1 -0
  10. package/build/src/data/RequestDataExtractor.d.ts +5 -5
  11. package/build/src/data/RequestDataExtractor.js.map +1 -1
  12. package/build/src/data/XmlReader.js +14 -1
  13. package/build/src/data/XmlReader.js.map +1 -1
  14. package/build/src/events/BaseEvents.d.ts +25 -0
  15. package/build/src/events/Events.d.ts +1 -1
  16. package/build/src/events/transport/TransportEvents.d.ts +1 -1
  17. package/build/src/events/transport/TransportEvents.js.map +1 -1
  18. package/build/src/models/ClientCertificate.d.ts +9 -0
  19. package/build/src/models/ClientCertificate.js.map +1 -1
  20. package/build/src/models/Environment.d.ts +3 -2
  21. package/build/src/models/Environment.js +11 -6
  22. package/build/src/models/Environment.js.map +1 -1
  23. package/build/src/models/ErrorResponse.js.map +1 -1
  24. package/build/src/models/HttpRequest.d.ts +2 -7
  25. package/build/src/models/HttpRequest.js +1 -6
  26. package/build/src/models/HttpRequest.js.map +1 -1
  27. package/build/src/models/HttpResponse.d.ts +2 -7
  28. package/build/src/models/HttpResponse.js +1 -3
  29. package/build/src/models/HttpResponse.js.map +1 -1
  30. package/build/src/models/ProjectExecution.d.ts +115 -0
  31. package/build/src/models/ProjectExecution.js +148 -0
  32. package/build/src/models/ProjectExecution.js.map +1 -0
  33. package/build/src/models/ProjectRequest.d.ts +19 -0
  34. package/build/src/models/ProjectRequest.js +50 -0
  35. package/build/src/models/ProjectRequest.js.map +1 -1
  36. package/build/src/models/Request.d.ts +12 -3
  37. package/build/src/models/Request.js +14 -1
  38. package/build/src/models/Request.js.map +1 -1
  39. package/build/src/models/RequestAuthorization.js.map +1 -1
  40. package/build/src/models/RequestLog.d.ts +11 -0
  41. package/build/src/models/RequestLog.js +15 -1
  42. package/build/src/models/RequestLog.js.map +1 -1
  43. package/build/src/models/SerializablePayload.d.ts +6 -1
  44. package/build/src/models/SerializablePayload.js +10 -6
  45. package/build/src/models/SerializablePayload.js.map +1 -1
  46. package/build/src/models/http-actions/AssertionError.d.ts +36 -0
  47. package/build/src/models/http-actions/AssertionError.js +35 -0
  48. package/build/src/models/http-actions/AssertionError.js.map +1 -0
  49. package/build/src/models/http-actions/HttpAssertion.d.ts +84 -0
  50. package/build/src/models/http-actions/HttpAssertion.js +52 -0
  51. package/build/src/models/http-actions/HttpAssertion.js.map +1 -0
  52. package/build/src/models/http-actions/HttpFlows.d.ts +109 -0
  53. package/build/src/models/http-actions/HttpFlows.js +31 -0
  54. package/build/src/models/http-actions/HttpFlows.js.map +1 -0
  55. package/build/src/models/http-actions/HttpStep.d.ts +29 -0
  56. package/build/src/models/http-actions/HttpStep.js +30 -0
  57. package/build/src/models/http-actions/HttpStep.js.map +1 -0
  58. package/build/src/models/http-actions/LegacyTranslator.d.ts +8 -7
  59. package/build/src/models/http-actions/LegacyTranslator.js +18 -13
  60. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -1
  61. package/build/src/models/http-actions/steps/assertion/EqualAssertion.d.ts +76 -0
  62. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js +79 -0
  63. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +1 -0
  64. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.d.ts +36 -0
  65. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js +59 -0
  66. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +1 -0
  67. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.d.ts +28 -0
  68. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js +45 -0
  69. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +1 -0
  70. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.d.ts +18 -0
  71. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js +29 -0
  72. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +1 -0
  73. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.d.ts +18 -0
  74. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js +29 -0
  75. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +1 -0
  76. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.d.ts +28 -0
  77. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js +45 -0
  78. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +1 -0
  79. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.d.ts +36 -0
  80. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js +59 -0
  81. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +1 -0
  82. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.d.ts +28 -0
  83. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js +45 -0
  84. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +1 -0
  85. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.d.ts +36 -0
  86. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js +59 -0
  87. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +1 -0
  88. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.d.ts +76 -0
  89. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js +79 -0
  90. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +1 -0
  91. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.d.ts +28 -0
  92. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js +45 -0
  93. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +1 -0
  94. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.d.ts +18 -0
  95. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js +29 -0
  96. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +1 -0
  97. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.d.ts +29 -0
  98. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js +45 -0
  99. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +1 -0
  100. package/build/src/models/http-actions/steps/assertion/OkAssertion.d.ts +18 -0
  101. package/build/src/models/http-actions/steps/assertion/OkAssertion.js +29 -0
  102. package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +1 -0
  103. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.d.ts +35 -0
  104. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js +53 -0
  105. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +1 -0
  106. package/build/src/models/http-actions/steps/assertion/index.d.ts +15 -0
  107. package/build/src/models/http-actions/steps/assertion/index.js +16 -0
  108. package/build/src/models/http-actions/steps/assertion/index.js.map +1 -0
  109. package/build/src/models/http-actions/steps/data/DeleteCookieStep.d.ts +44 -0
  110. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js +67 -0
  111. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +1 -0
  112. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.d.ts +53 -0
  113. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js +60 -0
  114. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +1 -0
  115. package/build/src/models/http-actions/steps/data/ReadDataStep.d.ts +67 -0
  116. package/build/src/models/http-actions/steps/data/ReadDataStep.js +77 -0
  117. package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +1 -0
  118. package/build/src/models/http-actions/steps/data/ReadValueStep.d.ts +45 -0
  119. package/build/src/models/http-actions/steps/data/ReadValueStep.js +52 -0
  120. package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +1 -0
  121. package/build/src/models/http-actions/steps/data/SetCookieStep.d.ts +100 -0
  122. package/build/src/models/http-actions/steps/data/SetCookieStep.js +138 -0
  123. package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +1 -0
  124. package/build/src/models/http-actions/steps/data/SetDataStep.d.ts +77 -0
  125. package/build/src/models/http-actions/steps/data/SetDataStep.js +69 -0
  126. package/build/src/models/http-actions/steps/data/SetDataStep.js.map +1 -0
  127. package/build/src/models/http-actions/steps/data/SetVariableStep.d.ts +40 -0
  128. package/build/src/models/http-actions/steps/data/SetVariableStep.js +44 -0
  129. package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +1 -0
  130. package/build/src/models/http-actions/steps/data/index.d.ts +7 -0
  131. package/build/src/models/http-actions/steps/data/index.js +8 -0
  132. package/build/src/models/http-actions/steps/data/index.js.map +1 -0
  133. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.d.ts +18 -0
  134. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js +29 -0
  135. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +1 -0
  136. package/build/src/models/http-actions/steps/transformation/AsNumberStep.d.ts +18 -0
  137. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js +29 -0
  138. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +1 -0
  139. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.d.ts +18 -0
  140. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js +29 -0
  141. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +1 -0
  142. package/build/src/models/http-actions/steps/transformation/RoundStep.d.ts +43 -0
  143. package/build/src/models/http-actions/steps/transformation/RoundStep.js +52 -0
  144. package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +1 -0
  145. package/build/src/models/http-actions/steps/transformation/SubstringStep.d.ts +38 -0
  146. package/build/src/models/http-actions/steps/transformation/SubstringStep.js +65 -0
  147. package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +1 -0
  148. package/build/src/models/http-actions/steps/transformation/TrimStep.d.ts +20 -0
  149. package/build/src/models/http-actions/steps/transformation/TrimStep.js +30 -0
  150. package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +1 -0
  151. package/build/src/models/http-actions/steps/transformation/index.d.ts +6 -0
  152. package/build/src/models/http-actions/steps/transformation/index.js +7 -0
  153. package/build/src/models/http-actions/steps/transformation/index.js.map +1 -0
  154. package/build/src/proxy/HttpProjectProxy.d.ts +1 -1
  155. package/build/src/proxy/Proxy.d.ts +1 -1
  156. package/build/src/proxy/ProxyService.d.ts +1 -1
  157. package/build/src/proxy/RequestProxy.d.ts +7 -2
  158. package/build/src/proxy/RequestProxy.js +4 -1
  159. package/build/src/proxy/RequestProxy.js.map +1 -1
  160. package/build/src/runtime/http-runner/ConditionCheck.d.ts +10 -10
  161. package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -1
  162. package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +75 -0
  163. package/build/src/runtime/http-runner/HttpAssertionRunner.js +538 -0
  164. package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -0
  165. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +11 -6
  166. package/build/src/runtime/http-runner/HttpFlowRunner.js +24 -15
  167. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  168. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +14 -3
  169. package/build/src/runtime/http-runner/HttpRequestRunner.js +44 -0
  170. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  171. package/build/src/runtime/node/BaseRunner.d.ts +1 -1
  172. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -2
  173. package/build/src/runtime/node/ProjectParallelRunner.js +2 -2
  174. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  175. package/build/src/runtime/node/ProjectRequestRunner.js +6 -2
  176. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  177. package/build/src/runtime/node/ProjectRunner.d.ts +1 -1
  178. package/build/src/runtime/node/ProjectSerialRunner.d.ts +1 -1
  179. package/build/src/runtime/reporters/Reporter.d.ts +1 -33
  180. package/build/src/runtime/reporters/Reporter.js.map +1 -1
  181. package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +2 -0
  182. package/build/src/runtime/store/interfaces/ProjectRuns.d.ts +56 -0
  183. package/build/src/runtime/store/interfaces/ProjectRuns.js +2 -0
  184. package/build/src/runtime/store/interfaces/ProjectRuns.js.map +1 -0
  185. package/package.json +3 -2
  186. package/src/data/{JmesparthReader.ts → JmespathReader.ts} +2 -2
  187. package/src/data/RequestDataExtractor.ts +5 -5
  188. package/src/data/XmlReader.ts +16 -2
  189. package/src/events/BaseEvents.ts +30 -0
  190. package/src/events/transport/TransportEvents.ts +1 -1
  191. package/src/models/ClientCertificate.ts +9 -0
  192. package/src/models/Environment.ts +11 -7
  193. package/src/models/ErrorResponse.ts +1 -1
  194. package/src/models/HttpRequest.ts +4 -14
  195. package/src/models/HttpResponse.ts +5 -11
  196. package/src/models/ProjectExecution.ts +227 -0
  197. package/src/models/ProjectRequest.ts +54 -0
  198. package/src/models/Request.ts +23 -4
  199. package/src/models/RequestAuthorization.ts +1 -1
  200. package/src/models/RequestLog.ts +21 -1
  201. package/src/models/SerializablePayload.ts +18 -1
  202. package/src/models/http-actions/AssertionError.ts +57 -0
  203. package/src/models/http-actions/HttpAssertion.ts +89 -0
  204. package/src/models/http-actions/HttpFlows.ts +115 -0
  205. package/src/models/http-actions/HttpStep.ts +50 -0
  206. package/src/models/http-actions/LegacyTranslator.ts +42 -30
  207. package/src/models/http-actions/steps/assertion/EqualAssertion.ts +130 -0
  208. package/src/models/http-actions/steps/assertion/GreaterThanAssertion.ts +87 -0
  209. package/src/models/http-actions/steps/assertion/IncludesAssertion.ts +68 -0
  210. package/src/models/http-actions/steps/assertion/IsEmptyAssertion.ts +41 -0
  211. package/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.ts +41 -0
  212. package/src/models/http-actions/steps/assertion/LengthOfAssertion.ts +68 -0
  213. package/src/models/http-actions/steps/assertion/LessThanAssertion.ts +87 -0
  214. package/src/models/http-actions/steps/assertion/MatchesAssertion.ts +68 -0
  215. package/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.ts +85 -0
  216. package/src/models/http-actions/steps/assertion/NotEqualAssertion.ts +130 -0
  217. package/src/models/http-actions/steps/assertion/NotIncludesAssertion.ts +68 -0
  218. package/src/models/http-actions/steps/assertion/NotOkAssertion.ts +41 -0
  219. package/src/models/http-actions/steps/assertion/NotToBeAssertion.ts +69 -0
  220. package/src/models/http-actions/steps/assertion/OkAssertion.ts +41 -0
  221. package/src/models/http-actions/steps/assertion/ToBeAssertion.ts +76 -0
  222. package/src/models/http-actions/steps/data/DeleteCookieStep.ts +102 -0
  223. package/src/models/http-actions/steps/data/ReadDataSourceStep.ts +103 -0
  224. package/src/models/http-actions/steps/data/ReadDataStep.ts +128 -0
  225. package/src/models/http-actions/steps/data/ReadValueStep.ts +88 -0
  226. package/src/models/http-actions/steps/data/SetCookieStep.ts +206 -0
  227. package/src/models/http-actions/steps/data/SetDataStep.ts +124 -0
  228. package/src/models/http-actions/steps/data/SetVariableStep.ts +82 -0
  229. package/src/models/http-actions/steps/transformation/AsLowerCaseStep.ts +41 -0
  230. package/src/models/http-actions/steps/transformation/AsNumberStep.ts +41 -0
  231. package/src/models/http-actions/steps/transformation/AsUpperCaseStep.ts +41 -0
  232. package/src/models/http-actions/steps/transformation/RoundStep.ts +86 -0
  233. package/src/models/http-actions/steps/transformation/SubstringStep.ts +93 -0
  234. package/src/models/http-actions/steps/transformation/TrimStep.ts +43 -0
  235. package/src/proxy/HttpProjectProxy.ts +1 -1
  236. package/src/proxy/Proxy.ts +1 -1
  237. package/src/proxy/ProxyService.ts +1 -1
  238. package/src/proxy/RequestProxy.ts +11 -3
  239. package/src/runtime/http-runner/ConditionCheck.ts +13 -14
  240. package/src/runtime/http-runner/HttpAssertionRunner.ts +540 -0
  241. package/src/runtime/http-runner/HttpFlowRunner.ts +33 -19
  242. package/src/runtime/http-runner/HttpRequestRunner.ts +53 -5
  243. package/src/runtime/node/BaseRunner.ts +1 -1
  244. package/src/runtime/node/ProjectParallelRunner.ts +5 -5
  245. package/src/runtime/node/ProjectRequestRunner.ts +6 -2
  246. package/src/runtime/node/ProjectRunner.ts +1 -1
  247. package/src/runtime/node/ProjectRunnerWorker.ts +1 -1
  248. package/src/runtime/node/ProjectSerialRunner.ts +1 -1
  249. package/src/runtime/reporters/Reporter.ts +1 -35
  250. package/src/runtime/store/interfaces/ApiClientStore.ts +3 -0
  251. package/src/runtime/store/interfaces/ProjectRuns.ts +64 -0
  252. package/build/src/data/JmesparthReader.js.map +0 -1
  253. package/build/src/models/http-actions/HttpActions.d.ts +0 -256
  254. package/build/src/models/http-actions/HttpActions.js +0 -46
  255. package/build/src/models/http-actions/HttpActions.js.map +0 -1
  256. package/src/models/http-actions/HttpActions.ts +0 -270
@@ -0,0 +1,540 @@
1
+ import { assert } from '@esm-bundle/chai';
2
+ import { HttpRequest } from "../../models/HttpRequest.js";
3
+ import { ISentRequest } from "../../models/SentRequest.js";
4
+ import { IResponse } from "../../models/Response.js";
5
+ import { ErrorResponse, IErrorResponse } from "../../models/ErrorResponse.js";
6
+ import { AssertionResult, IHttpAssertion } from "../../models/http-actions/HttpAssertion.js";
7
+ import { IHttpStep } from "../../models/http-actions/HttpStep.js";
8
+ import { FlowValue } from "./HttpFlowRunner.js";
9
+ import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from "../../models/http-actions/HttpFlows.js";
10
+ import { IReadDataSourceStep, ReadDataSourceStep, ReadDataSourceStepKind } from "../../models/http-actions/steps/data/ReadDataSourceStep.js";
11
+ import { IReadValueStep, ReadValueStep, ReadValueStepKind } from "../../models/http-actions/steps/data/ReadValueStep.js";
12
+ import * as DataUtils from '../../data/DataUtils.js';
13
+ import { HttpResponse } from "../../models/HttpResponse.js";
14
+ import { Headers } from '../../lib/headers/Headers.js';
15
+ import { DataReader } from "../../data/DataReader.js";
16
+ import { JmespathReader } from "../../data/JmespathReader.js";
17
+ import { XmlReader } from "../../data/XmlReader.js";
18
+ import { UrlEncodedReader } from "../../data/UrlEncodedReader.js";
19
+ import { AsLowerCaseStepKind } from "../../models/http-actions/steps/transformation/AsLowerCaseStep.js";
20
+ import { AsUpperCaseStepKind } from "../../models/http-actions/steps/transformation/AsUpperCaseStep.js";
21
+ import { AsNumberStepKind } from "../../models/http-actions/steps/transformation/AsNumberStep.js";
22
+ import { IRoundStep, RoundStepKind } from "../../models/http-actions/steps/transformation/RoundStep.js";
23
+ import { ISubstringStep, SubstringStepKind } from "../../models/http-actions/steps/transformation/SubstringStep.js";
24
+ import { TrimStepKind } from "../../models/http-actions/steps/transformation/TrimStep.js";
25
+ import { EqualAssertionKind, IEqualAssertion } from "../../models/http-actions/steps/assertion/EqualAssertion.js";
26
+ import { INotEqualAssertion, NotEqualAssertionKind } from "../../models/http-actions/steps/assertion/NotEqualAssertion.js";
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
+ }
46
+
47
+ /**
48
+ * A class that perform assertions that have been defined on an HTTP request.
49
+ */
50
+ export class HttpAssertionRunner {
51
+ report: AssertionResult[] = [];
52
+
53
+ /**
54
+ *
55
+ * @param request The request object sent to the server
56
+ * @param response The generated response
57
+ * @param assertions The list of assertions to perform.
58
+ */
59
+ async run(request: ISentRequest, response: IResponse | IErrorResponse, assertions: IHttpAssertion[]): Promise<AssertionResult[]> {
60
+ this.report = [];
61
+ if (!assertions || !assertions.length) {
62
+ return [...this.report];
63
+ }
64
+
65
+ for (const assertion of assertions) {
66
+ await this.runAssertion(request, response, assertion);
67
+ }
68
+ return [...this.report];
69
+ }
70
+
71
+ protected async runAssertion(request: ISentRequest, response: IResponse | IErrorResponse, assertion: IHttpAssertion): Promise<void> {
72
+ const { steps } = assertion;
73
+
74
+ // this keeps a value from the last step to be passed to the next step.
75
+ let lastResult: IStepValue = {
76
+ value: undefined,
77
+ };
78
+ let error: AssertionError | undefined;
79
+ for (const step of steps) {
80
+ try {
81
+ lastResult = await this.runStep(request, response, step, lastResult);
82
+ } catch (e) {
83
+ const typed = e as AssertionError;
84
+ if (typed.name === 'AssertionError') {
85
+ error = typed;
86
+ } else {
87
+ const err = e as Error;
88
+ error = new AssertionError({
89
+ message: err.message,
90
+ });
91
+ }
92
+ break;
93
+ }
94
+ }
95
+ const description = assertion.description || this.createDescription(steps);
96
+ if (error) {
97
+ this.report.push({
98
+ ok: false,
99
+ description,
100
+ error: error.toJSON(),
101
+ });
102
+ } else {
103
+ this.report.push({
104
+ ok: true,
105
+ description,
106
+ });
107
+ }
108
+ }
109
+
110
+ protected createDescription(steps: IHttpStep[]): string {
111
+ const parts: string[] = [];
112
+ for (const step of steps) {
113
+ switch (step.kind) {
114
+ case ReadDataSourceStepKind: parts.push(this.getDataSourceStepLabel(step as IReadDataSourceStep)); break;
115
+ case ReadValueStepKind: parts.push(this.getValueStepLabel(step as IReadValueStep)); break;
116
+ case AsLowerCaseStepKind: parts.push('To lower case'); break;
117
+ case AsUpperCaseStepKind: parts.push('To upper case'); break;
118
+ case AsNumberStepKind: parts.push('As number'); break;
119
+ case RoundStepKind: parts.push('Round'); break;
120
+ case TrimStepKind: parts.push('Trim'); break;
121
+ case SubstringStepKind: parts.push('Substring'); break;
122
+ case EqualAssertionKind: parts.push(`Equals to ${(step as IEqualAssertion).value}`); break;
123
+ case NotEqualAssertionKind: parts.push(`Not equals to ${(step as INotEqualAssertion).value}`); break;
124
+ case GreaterThanAssertionKind: parts.push(`Is greater than ${(step as IGreaterThanAssertion).value}`); break;
125
+ case LessThanAssertionKind: parts.push(`Is less than ${(step as ILessThanAssertion).value}`); break;
126
+ case IncludesAssertionKind: parts.push(`Includes ${(step as IIncludesAssertion).value}`); break;
127
+ case NotIncludesAssertionKind: parts.push(`Not includes ${(step as INotIncludesAssertion).value}`); break;
128
+ case OkAssertionKind: parts.push(`Is OK`); break;
129
+ case NotOkAssertionKind: parts.push(`Is not OK`); break;
130
+ default:
131
+ }
132
+ }
133
+ return parts.filter(i => !!i).join(' > ');
134
+ }
135
+
136
+ protected getDataSourceStepLabel(step: IReadDataSourceStep): string {
137
+ if (step.source === FlowSourceEnum.request) {
138
+ if (step.data === FlowRequestDataEnum.url) {
139
+ return 'Request URL';
140
+ }
141
+ if (step.data === FlowRequestDataEnum.headers) {
142
+ return 'Request headers';
143
+ }
144
+ if (step.data === FlowRequestDataEnum.method) {
145
+ return 'HTTP method';
146
+ }
147
+ if (step.data === FlowRequestDataEnum.body) {
148
+ return 'Request body';
149
+ }
150
+ }
151
+ if (step.source === FlowSourceEnum.response) {
152
+ if (step.data === FlowResponseDataEnum.url) {
153
+ return 'Response URL';
154
+ }
155
+ if (step.data === FlowResponseDataEnum.headers) {
156
+ return 'Response headers';
157
+ }
158
+ if (step.data === FlowResponseDataEnum.body) {
159
+ return 'Response body';
160
+ }
161
+ if (step.data === FlowResponseDataEnum.status) {
162
+ return 'Status code';
163
+ }
164
+ if (step.data === FlowResponseDataEnum.statusText) {
165
+ return 'Status message';
166
+ }
167
+ }
168
+ return 'Invalid step';
169
+ }
170
+
171
+ protected getValueStepLabel(step: IReadValueStep): string {
172
+ const { path } = step;
173
+ return path || '';
174
+ }
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
+ }
@@ -4,13 +4,22 @@ import { ISentRequest } from "../../models/SentRequest.js";
4
4
  import { IResponse } from "../../models/Response.js";
5
5
  import { IErrorResponse } from "../../models/ErrorResponse.js";
6
6
  import { HttpCookie } from "../../models/HttpCookie.js";
7
- import { ActionSourceEnum, DeleteCookieStepKind, IActionStep, IDeleteCookieStep, IHttpAction, IHttpActionFlow, IHttpCondition, IReadDataStep, ISetCookieStep, ISetDataStep, ISetVariableStep, ReadDataStepKind, SetCookieStepKind, SetDataStepKind, SetVariableStepKind } from '../../models/http-actions/HttpActions.js';
7
+ import {
8
+ FlowSourceEnum, IHttpAction,
9
+ IHttpFlow, IHttpCondition,
10
+ } from '../../models/http-actions/HttpFlows.js';
8
11
  import { RequestDataExtractor } from "../../data/RequestDataExtractor.js";
9
12
  import { checkCondition } from "./ConditionCheck.js";
10
13
  import { ApiSchemaValues } from "../../amf/ApiSchemaValues.js";
11
14
  import { SameSiteValue } from "../../cookies/CookieParser.js";
15
+ import { IHttpStep } from "../../models/http-actions/HttpStep.js";
16
+ import { IReadDataStep, ReadDataStep, ReadDataStepKind } from "../../models/http-actions/steps/data/ReadDataStep.js";
17
+ import { ISetDataStep, SetDataStep, SetDataStepKind } from "../../models/http-actions/steps/data/SetDataStep.js";
18
+ import { ISetVariableStep, SetVariableStep, SetVariableStepKind } from "../../models/http-actions/steps/data/SetVariableStep.js";
19
+ import { ISetCookieStep, SetCookieStep, SetCookieStepKind } from "../../models/http-actions/steps/data/SetCookieStep.js";
20
+ import { DeleteCookieStep, DeleteCookieStepKind, IDeleteCookieStep } from "../../models/http-actions/steps/data/DeleteCookieStep.js";
12
21
 
13
- type FlowValue = string | number | boolean | null | undefined;
22
+ export type FlowValue = string | number | boolean | null | undefined | unknown;
14
23
 
15
24
  export class HttpFlowRunner {
16
25
  /**
@@ -27,7 +36,7 @@ export class HttpFlowRunner {
27
36
  */
28
37
  cookies?: CookieJar;
29
38
 
30
- async request(request: IHttpRequest, flows?: IHttpActionFlow[]): Promise<void> {
39
+ async request(request: IHttpRequest, flows?: IHttpFlow[]): Promise<void> {
31
40
  if (!flows || !flows.length) {
32
41
  return;
33
42
  }
@@ -38,7 +47,7 @@ export class HttpFlowRunner {
38
47
  }
39
48
  }
40
49
 
41
- async response(request: IHttpRequest | ISentRequest, response: IResponse | IErrorResponse, flows?: IHttpActionFlow[]): Promise<void> {
50
+ async response(request: IHttpRequest | ISentRequest, response: IResponse | IErrorResponse, flows?: IHttpFlow[]): Promise<void> {
42
51
  if (!flows || !flows.length) {
43
52
  return;
44
53
  }
@@ -78,7 +87,7 @@ export class HttpFlowRunner {
78
87
  return checkCondition(readValue, operator, value);
79
88
  }
80
89
 
81
- async _runStep(step: IActionStep, input: FlowValue, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<FlowValue> {
90
+ async _runStep(step: IHttpStep, input: FlowValue, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<FlowValue> {
82
91
  switch (step.kind) {
83
92
  case ReadDataStepKind: return this._runReadDataStep(step as IReadDataStep, request, response);
84
93
  case SetDataStepKind: return this._runSetDataStep(step as ISetDataStep);
@@ -98,21 +107,23 @@ export class HttpFlowRunner {
98
107
  * @returns The read value or undefined.
99
108
  */
100
109
  async _runReadDataStep(step: IReadDataStep, request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<string | number | undefined> {
101
- const { source, data, enabled, path } = step;
102
- if (enabled === false) {
110
+ const instance = new ReadDataStep(step);
111
+
112
+ if (instance.enabled === false || !instance.checkValidity()) {
103
113
  return undefined;
104
114
  }
105
- if (source === ActionSourceEnum.request) {
115
+ const { source, data, path } = step;
116
+ if (source === FlowSourceEnum.request) {
106
117
  const extractor = new RequestDataExtractor(request);
107
118
  return extractor.extract(source, data, path);
108
119
  }
109
120
 
110
- if (source === ActionSourceEnum.response) {
121
+ if (source === FlowSourceEnum.response) {
111
122
  const extractor = new RequestDataExtractor(request, response);
112
123
  return extractor.extract(source, data, path);
113
124
  }
114
125
 
115
- if (source === ActionSourceEnum.variable && path && this.variables) {
126
+ if (source === FlowSourceEnum.variable && path && this.variables) {
116
127
  return this.variables[path];
117
128
  }
118
129
 
@@ -126,10 +137,11 @@ export class HttpFlowRunner {
126
137
  * @returns The read value with applied data type.
127
138
  */
128
139
  _runSetDataStep(step: ISetDataStep): FlowValue {
129
- const { value, dataType, enabled } = step;
130
- if (enabled === false) {
140
+ const instance = new SetDataStep(step);
141
+ if (instance.enabled === false || !instance.checkValidity()) {
131
142
  return undefined;
132
143
  }
144
+ const { value, dataType } = step;
133
145
  if (value === null || value === undefined) {
134
146
  return undefined;
135
147
  }
@@ -143,10 +155,11 @@ export class HttpFlowRunner {
143
155
  * @param value The value to set. A value that is `null` or `undefined` deletes the variable.
144
156
  */
145
157
  _runSetVariableStep(step: ISetVariableStep, value: FlowValue): FlowValue {
146
- const { name, enabled } = step;
147
- if (enabled === false || !name || !this.variables) {
158
+ const instance = new SetVariableStep(step);
159
+ if (instance.enabled === false || !instance.checkValidity() || !this.variables) {
148
160
  return undefined;
149
161
  }
162
+ const { name } = step;
150
163
  if (value === null || typeof value === undefined) {
151
164
  delete this.variables[name];
152
165
  } else {
@@ -163,14 +176,15 @@ export class HttpFlowRunner {
163
176
  * @param request The request object.
164
177
  */
165
178
  async _runSetCookieStep(step: ISetCookieStep, value: FlowValue, request: IHttpRequest | ISentRequest): Promise<FlowValue> {
166
- const { name, enabled, expires, hostOnly, httpOnly, sameSite, secure, session } = step;
179
+ const instance = new SetCookieStep(step);
167
180
  const { cookies } = this;
168
- if (enabled === false || !name || !cookies ) {
181
+ if (instance.enabled === false || !instance.checkValidity() || !cookies ) {
169
182
  return undefined;
170
183
  }
171
184
  if (value === null || typeof value === undefined) {
172
185
  return undefined;
173
186
  }
187
+ const { name, expires, hostOnly, httpOnly, sameSite, secure, session } = step;
174
188
  const typedValue = String(value);
175
189
  let url: string;
176
190
  if (step.url) {
@@ -215,9 +229,9 @@ export class HttpFlowRunner {
215
229
  * A step to delete cookies from the cookie jar.
216
230
  */
217
231
  async _runDeleteCookieStep(step: IDeleteCookieStep, request: IHttpRequest | ISentRequest): Promise<FlowValue> {
218
- const { name, enabled } = step;
232
+ const instance = new DeleteCookieStep(step);
219
233
  const { cookies } = this;
220
- if (enabled === false || !cookies ) {
234
+ if (instance.enabled === false || !instance.checkValidity() || !cookies ) {
221
235
  return undefined;
222
236
  }
223
237
  let url: string;
@@ -226,7 +240,7 @@ export class HttpFlowRunner {
226
240
  } else {
227
241
  url = request.url;
228
242
  }
229
- await cookies.deleteCookies(url, name);
243
+ await cookies.deleteCookies(url, step.name);
230
244
  return undefined;
231
245
  }
232
246
  }