diff --git a/README.md b/README.md index 8bea5f7..1c79613 100644 --- a/README.md +++ b/README.md @@ -407,40 +407,3 @@ However, you can configure your own rules from the [ruleset available on the Red ## Running the Arazzo Specification For now, I recommend using the [Redocly CLI](https://redocly.com/redocly-cli) to [run your Arazzo Workflows](https://redocly.com/learn/arazzo/testing-arazzo-workflows). - -### Here be Dragons - -To run the generated Arazzo Specification, you can call the plugin from the CLI like: - -```bash -serverless arazzo run -``` - -Options: - -``` ---source -s The default Arazzo Specification source file. Default: arazzo.json ---input -i The file containign input variables to run the Workflow steps. Default: input.json -``` - -### Input file - -The input file is where you keep your variables that you wish to use within your workflow and should be a json file structured like: - -```json -{ - "worflowId1": { - "name": "Jared" - } -} -``` - -The file should contain objects for each workflow, by workflowId, with the variables matching up to the inputs that you defined in your workflow [inputs](#inputs) schema. - -This file is likely to be comitted to your repository, so you should not store secrets in the file, instead you might use something like [jq](https://jqlang.org/) that can take repository variables and insert them into your input file: - -```bash -jq --arg password "$secret_password" '.workflowId1.password = $password' input.json -``` - -Obviously, if you have a lot of secret variables that need adding as inputs, then you might need to write a script that can alter the `input.json` file for you within your CI/CD runner. diff --git a/package-lock.json b/package-lock.json index 69b1785..5590edc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "serverless-arazzo-workflows", - "version": "0.0.8", + "version": "0.0.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "serverless-arazzo-workflows", - "version": "0.0.8", + "version": "0.0.9", "license": "MIT", "dependencies": { "@redocly/cli": "^2.14.0", diff --git a/package.json b/package.json index 53daa70..b83a798 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-arazzo-workflows", - "version": "0.0.8", + "version": "0.0.9", "description": "Document your Serverless Framework API workflows with the OpenAPI Arazzo Workflow Spec", "main": "index.js", "scripts": { diff --git a/resources/rules.peggy b/resources/rules.peggy deleted file mode 100644 index be65f8a..0000000 --- a/resources/rules.peggy +++ /dev/null @@ -1,72 +0,0 @@ -expression - = ("$url"i / "$method"i / "$statusCode"i / "$request."i source / "$response."i source / "$inputs."i name / "$outputs."i name / "$steps."i name / "$workflows."i name / "$sourceDescriptions."i name / "$components."i name / "$components.parameters."i parameter_name) - -source - = (header_reference / query_reference / path_reference / body_reference) - -name - = (CHAR)* - -parameter_name - = name - -header_reference - = "header."i token - -query_reference - = "query."i name - -path_reference - = "path."i name - -body_reference - = "body"i ("#" json_pointer)? - -CHAR - = [\x01-\x7f] - -token - = tchar+ - -json_pointer - = ("/" reference_token)* - -tchar - = "!" - / "#" - / "$" - / "%" - / "&" - / "'" - / "*" - / "+" - / "-" - / "." - / "^" - / "_" - / "`" - / "|" - / "~" - / DIGIT - / ALPHA - -reference_token - = (unescaped / escaped)* - -DIGIT - = [\x30-\x39] - -ALPHA - = [\x41-\x5a] - / [\x61-\x7a] - -unescaped - = [\x00-\x2e] - / [\x30-\x7d] - / [\x7f-\ud7ff] - / [\ue000-\uffff] - / [\ud800-\udbff] [\udc00-\udfff] - -escaped - = "~" ("0" / "1") - diff --git a/src/Arazzo.js b/src/Arazzo.js deleted file mode 100644 index dbbd244..0000000 --- a/src/Arazzo.js +++ /dev/null @@ -1,503 +0,0 @@ -"use strict"; - -const { parse, test } = require("@swaggerexpert/arazzo-runtime-expression"); -const jp = require("jsonpath"); -const traverse = require("traverse"); - -const path = require("node:path"); - -const Document = require("./Document"); -const docFactory = require("./DocFactory"); - -class Arazzo extends Document { - constructor(url, name, options) { - super(url, name, options); - - this.type = "arazzo"; - this.outputs = {}; - this.loadedSourceDescriptions = {}; - // this.pathToArazzoSpecification = path.resolve(arazzoPath); - } - - setMainArazzo() { - this.filePath = path.resolve(this.url); - } - - async runWorkflows(inputFile) { - this.inputFile = inputFile; - await this.getSourceDescriptions(); - await this.getWorkflows(); - - await this.startWorkflows(); - } - - async startWorkflows(index = 0) { - const continueRunning = await this.runWorkflow(index); - if (continueRunning.noMoreWorkflows === false) { - await this.startWorkflows(index + 1); - } - } - - async runWorkflow(index) { - const workflow = await this.JSONPickerToIndex("workflows", index); - - if (workflow) { - this.logger.notice(`Running Workflow: ${workflow.workflowId}`); - this.inputs = await this.inputFile.getWorkflowInputs( - workflow.workflowId, - workflow.inputs, - ); - this.workflow = workflow; - await this.runSteps(); - return { noMoreWorkflows: false }; - } else { - this.logger.notice(`All workflows have run`); - return { noMoreWorkflows: true }; - } - } - - async runSteps(index = 0) { - const contineuRunning = await this.runStep(index); - - if (contineuRunning.noMoreSteps === false) { - await this.runSteps(index + 1); - } - } - - async runStep(index) { - const step = this.workflow.steps[index]; - if (step) { - this.step = step; - this.logger.notice(`Running Step: ${this.step.stepId}`); - - await this.loadOperationData(); - - if (this.openAPISteps) { - await this.runOpenAPIStep(); - } - - return { noMoreSteps: false }; - } else { - this.logger.notice(`All steps in ${this.workflow.workflowId} have run`); - return { noMoreSteps: true }; - } - } - - async runOpenAPIStep() { - this.operations = await this.sourceDescriptionFile.buildOperation( - this.inputs, - this.step, - ); - - this.mapInputs(); - - await this.runOperation(); - } - - async runOperation(retry = 0, retryAfter = 0) { - const sleep = function (ms) { - return new Promise((resolve) => setTimeout(resolve, ms)); - }; - - for (const operation of this.operations) { - let url = operation.url; - - if (operation.queryParams.size) { - url += `?${operation.queryParams}`; - } - - const options = { - method: operation.operation, - headers: operation.headers, - }; - - if (operation.data) { - options.body = data; - } - - this.logger.notice( - `Making a ${operation.operation.toUpperCase()} call to ${operation.url}`, - ); - - const response = await fetch(url, options); - - await this.dealWithResponse(response); - // if (response.ok === false) { - // this.logger.error(`Call to ${operation.operation.toUpperCase()} ${operation.url} failed`); - - // if (retry > 0) { - // let retryCount = retry--; - // this.logger.notice(`Making attempt number: ${retryCount}`); - // let retryAfterSeconds = retryAfter; - // if (response.headers.has('retry-after')) { - // retryAfterSeconds = response.headers['retry-after']; - // } - - // if (retryAfterSeconds > 0) { - // await sleep(retryAfterSeconds*1000); - // } - - // await this.runOperation(retryCount, retryAfterSeconds); - // } else { - // throw new Error(`Call to ${operation.operation.toUpperCase()} ${operation.url} failed with a ${response.status}`); - // } - // } - - // if (this.step.successCriteria) { - // const hasMatchedSuccessCriteria = await this.determineSuccessCriteria(response); - - // if (hasMatchedSuccessCriteria) { - // this.logger.success(`Making a ${operation.operation.toUpperCase()} call to ${operation.url} matched all the successCriteria`); - // } - // } - - // if (this.step.outputs) { - - // } - } - } - - async dealWithResponse(response) { - if (response.ok === false) { - await this.dealWithFailedResponse(response); - } else { - // const passed = await this.dealWithSuccessfulResponse(response); - - // if (!passed) { - // await this.dealWithFailedResponse(response); - // } - - await this.dealWithOutputs(response); - } - } - - async dealWithOutputs(response) { - const json = await response.json(); - if (this.step?.outputs) { - const outputs = {}; - for (const key in this.step.outputs) { - // console.log(key) - - const isARuntimeValue = this.matchesExpectedRunTimeExpression( - this.step.outputs[key], - "$response.", - ); - - if (isARuntimeValue) { - const parseResult = parse(this.step.outputs[key]); - const parts = []; - - parseResult.ast.translate(parts); - for (const result of parts) { - if (result.at(0) === "source") { - // if (result.at(1) === 'body') { - // outputs[key] = json; - // // console.log(JSON.stringify(json)) - // } - if (result.at(1).startsWith("body")) { - console.log(result.at(1)); - let path; - if (result.at(1) === "body") { - path = "$"; - } else { - const splitArr = result.at(1).split("body#/"); - path = `$..${splitArr[1]}`; - } - console.log(path); - const value1 = jp.query(json, path); - console.log(value1); - } - - if (result.at(1).startsWith("header")) { - const headerName = parts[3][1]; - outputs[key] = response.headers.get(headerName); - } - } - // console.log(result) - // if (result.at(1).at(0) === 'body' && !result?.at(3)) { - // outputs[key] = json; - // } - - // if (result[1].startsWith('header')) { - // outputs[key] = response.headers[result[3][1]]; - // } - } - } - } - - Object.assign(this.outputs, { [this.step.stepId]: outputs }); - } - - console.log(this.outputs); - } - - async dealWithFailedResponse(response) { - if (this.workflow.failureActions) { - } - - if (this.step.failureActions) { - } - } - - async dealWithSuccessfulResponse(response) { - let successCriteriaPassed = false; - - if (this.step.successCriteria) { - successCriteriaPassed = this.dealWithCriteria( - response, - this.step.successCriteria, - ); - } - - return successCriteriaPassed; - } - - safeEval(expression, context) { - try { - const func = new Function("data", `return ${expression}`); - return func(context); - } catch (e) { - console.error("Error evaluating expression:", expression, e); - return false; - } - } - - dealWithCriteria(response, criteriaArr) { - let hasPassed = false; - const passes = []; - const failures = []; - for (const successCriteria of criteriaArr) { - if ( - Object.hasOwn(successCriteria, "type") === false || - successCriteria?.type === "simple" - ) { - let condition = successCriteria.condition; - for (const key in response) { - const passed = this.safeEval(condition, response); - if (passed) passes.push(true); - } - } else { - if (successCriteria?.type === "regex") { - } else { - } - } - } - - if (passes === this.step.successCriteria.length) { - hasPassed = true; - } - - return hasPassed; - } - - async determineSuccessCriteria(response) { - let matchesAllSuccessCriteria = false; - const successCriteriaMatches = []; - for (const criterionObject of this.step.successCriteria) { - if (Object.entries(criterionObject).length === 1) { - if (test(criterionObject.condition)) { - const parseResult = parse(criterionObject.condition); - parseResult.ast.translate(parts); - - console.log(parseResult); - } else { - if (criterionObject.condition.startsWith("$statusCode")) { - if (response.status == 200) { - successCriteriaMatches.push(true); - } - } - } - } - } - - if (successCriteriaMatches.every((value) => value === true)) { - matchesAllSuccessCriteria = true; - } - - return matchesAllSuccessCriteria; - } - - mapInputs() { - this.mapParameters(); - this.mapRequestBody(); - } - - mapParameters() { - const headers = new Headers(); - const queryParams = new URLSearchParams(); - - for (const param of this.step?.parameters) { - const value = this.parseRunTimeExpression(param.value); - - switch (param.in) { - case "header": - headers.append(param.name, value); - break; - - case "path": - for (const operation of this.operations) { - operation.url = operation.url.replace(`{${param.name}}`, value); - } - break; - - case "query": - queryParams.append(param.name, value); - break; - } - } - - for (const operation of this.operations) { - operation.headers = headers; - operation.queryParams = queryParams; - } - } - - mapRequestBody() { - if (this.step?.requestBody) { - const payload = structuredClone(this.step.requestBody.payload); - traverse(payload).forEach((requestValue) => { - const value = this.parseRunTimeExpression(requestValue); - this.update(value); - }); - - for (const operation of this.operations) { - operation.data = payload; - } - } - } - - parseRunTimeExpression(expression) { - let value = expression; - if (test(value)) { - const parts = []; - const parseResult = parse(value); - parseResult.ast.translate(parts); - console.log(parts); - for (const part of parts) { - if (part[0] === "name") { - value = this.inputs[part[1]]; - } - } - } - - return value; - } - - async loadOperationData() { - this.sourceDescription = this.getOperationIdSourceDescription(); - - if (!this.loadedSourceDescriptions[this.sourceDescription.name]) { - this.logger.notice( - `Getting Source Description for: ${this.sourceDescription.name}`, - ); - this.sourceDescriptionFile = await docFactory.buildDocument( - this.sourceDescription.type, - this.sourceDescription.url, - this.sourceDescription.name, - { parser: this.parser, logger: this.logger }, - ); - Object.assign(this.loadedSourceDescriptions, { - [this.sourceDescription.name]: true, - }); - } - - if (this.isAnOperationId) { - // this.logger.notice(`Getting OperationId: ${this.step.operationId}`); - await this.sourceDescriptionFile.getOperationById(this.step.operationId); - } - } - - getOperationIdSourceDescription() { - const operationOrWorkflowPointer = this.getOperationType(); - - if (this.sourceDescriptions.length === 1) { - return this.sourceDescriptions[0]; - } else { - if ( - this.matchesExpectedRunTimeExpression( - operationOrWorkflowPointer, - "$sourceDescriptions.", - ) - ) { - const sourceDescription = this.sourceDescriptions.filter( - (sourceDescription) => { - if ( - sourceDescription.name === - operationOrWorkflowPointer.split(".")[1] - ) { - return sourceDescription; - } - }, - ); - if (sourceDescription.length === 1) { - return sourceDescription; - } - } - } - - throw new Error( - `No known matching source description for ${this.step.operationId}`, - ); - } - - getOperationType() { - let operationOrWorkflowPointer; - if (this.step.operationId) { - operationOrWorkflowPointer = this.step.operationId; - this.isAnOperationId = true; - this.openAPISteps = true; - } else if (this.step.workflowId) { - operationOrWorkflowPointer = this.step.workflowId; - this.isAWorkflowId = true; - } else { - operationOrWorkflowPointer = this.step.operationPath; - this.isAnOperationPath = true; - this.openAPISteps = true; - } - return operationOrWorkflowPointer; - } - - matchesExpectedRunTimeExpression(string, runtimeExpression) { - const result = this.parser.parse(string, { peg$library: true }); - - if (result.peg$success) { - if (result.peg$result[0] === runtimeExpression) { - return true; - } - } - - return false; - } - - async getSourceDescriptions() { - const pipeline = this.JSONPicker("sourceDescriptions", this.filePath); - - let sourceDescriptions = []; - for await (const { value } of pipeline) { - sourceDescriptions = value.flat(); - } - - if (sourceDescriptions.length === 0) { - throw new Error("Missing Source Descriptions"); - } - - this.sourceDescriptions = sourceDescriptions; - } - - async getWorkflows() { - const pipeline = this.JSONPicker("workflows", this.filePath); - - let workflows = []; - for await (const { value } of pipeline) { - workflows = value.flat(); - } - - if (workflows.length === 0) { - throw new Error("Missing Workflows"); - } - - this.workflows = workflows; - } -} - -module.exports = Arazzo; diff --git a/src/ArazzoPlugin.js b/src/ArazzoPlugin.js index cd01d02..c200da7 100644 --- a/src/ArazzoPlugin.js +++ b/src/ArazzoPlugin.js @@ -6,7 +6,6 @@ const yaml = require("js-yaml"); const fs = require("fs/promises"); const ArazzoGenerator = require("./ArazzoGenerator"); -const ArazzoRunner = require("./ArazzoRunner"); const Logger = require("./Logger"); const serverlessSchema = require("../resources/serverlessSchema.json"); @@ -92,15 +91,6 @@ class ArazzoPlugin { this.runArazzo = true; this.processCLIInput(); - const runner = new ArazzoRunner(`./${this.config.source}`, { - logger: this.logger, - inputFile: this.config.input, - }); - - await runner.runArazzoWorkflows().catch((err) => { - throw new this.serverless.classes.Error(err); - }); - this.logger.success("Arazzo Specification Successfully Run"); } diff --git a/src/ArazzoRunner.js b/src/ArazzoRunner.js deleted file mode 100644 index 64c8355..0000000 --- a/src/ArazzoRunner.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; - -const peggy = require("peggy"); -const { chain } = require("stream-chain"); -const Pick = require("stream-json/filters/Pick"); -const { streamValues } = require("stream-json/streamers/StreamValues"); - -const fs = require("node:fs"); -const fsp = require("node:fs/promises"); -const path = require("node:path"); - -const Arazzo = require("./Arazzo"); -const Input = require("./Input"); - -class ArazzoRunner { - constructor(pathToArazzoSpecification = "./arazzo.json", options) { - this.pathToArazzoSpecification = pathToArazzoSpecification; - - this.logger = options.logger; - - this.openAPISteps = false; - - this.inputFile = new Input(options.inputFile, "inputs"); - } - - async runArazzoWorkflows() { - await this.loadPeggyRules(); - - this.arazzoDocument = new Arazzo( - this.pathToArazzoSpecification, - "mainArazzo", - { - parser: this.parser, - logger: this.logger, - }, - ); - - this.arazzoDocument.setMainArazzo(); - - await this.arazzoDocument.runWorkflows(this.inputFile); - } - - async loadPeggyRules() { - const peggyPath = path.join(__dirname, "..", "resources", "rules.peggy"); - const peggyRuleSet = await fsp.readFile(peggyPath); - - this.parser = peggy.generate(peggyRuleSet.toString()); - } - - JSONPicker(key, file) { - const pipeline = chain([ - fs.createReadStream(file), - Pick.withParser({ filter: key }), - streamValues(), - ]); - return pipeline; - } -} - -module.exports = ArazzoRunner; diff --git a/src/DocFactory.js b/src/DocFactory.js deleted file mode 100644 index 2716cbf..0000000 --- a/src/DocFactory.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -const Arazzo = require("./Arazzo"); -const OpenAPI = require("./OpenAPI"); - -class DocumentFactory { - constructor() {} - - async buildDocument(type, path, name, options) { - let document; - if (type === "openapi") { - document = new OpenAPI(path, name, options); - } else { - document = new Arazzo(path, name, options); - } - - await document.loadDocument(); - - return document; - } -} - -module.exports = new DocumentFactory(); diff --git a/src/Document.js b/src/Document.js deleted file mode 100644 index 34eff82..0000000 --- a/src/Document.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; - -const { - bundleDocument, - bundleFromString, - createConfig, -} = require("@redocly/openapi-core"); -const { chain } = require("stream-chain"); -const Pick = require("stream-json/filters/Pick"); -const { streamArray } = require("stream-json/streamers/StreamArray"); -const { streamValues } = require("stream-json/streamers/StreamValues"); - -const fs = require("node:fs"); -const fsp = require("node:fs/promises"); -const path = require("node:path"); - -class Document { - constructor(url, name, { parser, logger }) { - this.url = url; - this.name = name; - this.parser = parser; - this.logger = logger; - } - - async loadDocument() { - const response = await fetch(this.url); - - if (!response.ok) { - throw new Error(`Error fetching document from ${this.url}`); - } - - let data = await response.json(); - - await this.writeDocument(data); - } - - async writeDocument(data) { - let document = data; - if (this.type === "openapi") { - const config = await createConfig({}); - const bundledData = await bundleFromString({ - source: JSON.stringify(data), - dereference: true, - config: config, - }); - document = bundledData.bundle.parsed; - } - - this.fileName = `${this.name}.json`; - await fsp.writeFile(this.fileName, JSON.stringify(document)); - this.filePath = path.resolve(this.fileName); - } - - async readStreamFromURL(key) { - try { - const response = await fetch(this.url); - - if (!response.ok) { - throw new Error(`HTTP error! Status: ${response.status}`); - } - - return chain([ - response.body, // ReadableStream from fetch - Pick.withParser({ filter: key }), - streamValues(), // Change to streamObject() if JSON is an object - ]); - } catch (err) { - console.error("Error reading stream:", err); - } - } - - matchesExpectedRunTimeExpression(string, runtimeExpression) { - const result = this.parser.parse(string, { peg$library: true }); - if (result.peg$success) { - if (result.peg$result[0] === runtimeExpression) { - return true; - } - } - - return false; - } - - JSONPickerToIndex(key, index, file = this.filePath) { - return new Promise((resolve, reject) => { - const pipeline = chain([ - fs.createReadStream(path.resolve(file)), - Pick.withParser({ filter: key }), - streamArray(), - ]); - - pipeline.on("data", ({ key, value }) => { - if (key === index) { - resolve(value); - pipeline.destroy(); - } - }); - - pipeline.on("error", (err) => { - reject(err); - }); - - pipeline.on("end", () => { - resolve(null); - }); - }); - } - - JSONPicker(key, file) { - let pipeline; - // if (this.httpPath) { - // pipeline = this.readStreamFromURL(key) - // } else { - pipeline = chain([ - fs.createReadStream(path.resolve(file)), - Pick.withParser({ filter: key }), - streamValues(), - ]); - // } - - return pipeline; - } -} - -module.exports = Document; diff --git a/src/Input.js b/src/Input.js deleted file mode 100644 index 7a42317..0000000 --- a/src/Input.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -const Ajv = require("ajv"); - -const path = require("node:path"); - -const Document = require("./Document"); - -class Input extends Document { - constructor(filePath, name) { - super(filePath, name, {}); - - this.type = "input"; - - this.filePath = path.resolve(filePath); - - this.ajv = new Ajv(); - } - - async getWorkflowInputs(workflowId, schema) { - const pipeline = this.JSONPicker(workflowId, this.filePath); - - for await (const { value } of pipeline) { - this.validateInputs(value, schema); - this.inputs = value; - } - - return this.inputs; - } - - validateInputs(value, schema) { - const validate = this.ajv.compile(schema); - - const valid = validate(value); - - if (!valid) { - throw new Error("Input values do not match Input schema", { - cause: validate.errors, - }); - } - } -} - -module.exports = Input; diff --git a/src/OpenAPI.js b/src/OpenAPI.js deleted file mode 100644 index 566e0fb..0000000 --- a/src/OpenAPI.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; - -const Document = require("./Document"); - -class OpenAPI extends Document { - constructor(url, name, options) { - super(url, name, options); - - this.type = "openapi"; - } - - async getOperationById(operationId) { - const pipeline = await this.JSONPicker("paths", this.filePath); - - for await (const { value } of pipeline) { - for (let key in value) { - for (let operation in value[key]) { - if (value[key][operation]?.operationId === operationId) { - this.path = key; - this.operation = operation; - this.operationDetails = value[key][operation]; - } - } - } - } - - if (this.path === undefined) { - throw new Error(`The OperationId: ${operationId} does not exist`); - } - } - - async buildOperation(inputs, step) { - await this.getServers(); - // this.mapInputs(inputs, step) - this.buildOperations(); - - // console.log(this.operations) - return this.operations; - } - - async getServers() { - const pipeline = await this.JSONPicker("servers", this.filePath); - - for await (const { value } of pipeline) { - this.servers = value; - } - } - - // mapInputs(inputs, step) { - // if (step.parameters) { - // this.mapParamsToInputs(inputs, step); - // } - - // if (step.requestBody) { - // this.mapRequestBodyToInputs(inputs, step); - // } - // } - - // mapParamsToInputs(inputs, step) { - // const headers = new Headers(); - // const queryParams = new URLSearchParams(); - - // for (const param of step.parameters) { - // if (this.matchesExpectedRunTimeExpression(param.value, '$inputs.')) { - // const inputName = param.value.split('.')[1]; - // const inputValue = inputs[inputName]; - - // if (param.in === 'header') { - // headers.append(param.name, inputValue); - // } else if (param.in === 'query') { - // queryParams.append(param.name, inputValue); - // } else if (param.in === 'path') { - // this.path = this.path.replace(`{${inputName}}`, inputValue) - // } - // } - // } - - // this.headers = headers; - // this.queryParams = queryParams; - // } - - // mapRequestBodyToInputs(inputs, step) { - // if (step.requestBody.contentType || Object.keys(this.operationDetails.requestBody.content) === 1) { - // for (const contentType in this.operationDetails.requestBody.content) { - // if (step.requestBody.contentType === contentType) { - // if (contentType === 'application/json') { - // const payload = structuredClonestep.requestBody.payload; - // traverse(payload).forEach(function(value) { - // if (this.matchesExpectedRunTimeExpression(value, '$inputs.')) { - // const inputName = param.value.split('.')[1]; - // const inputValue = inputs[inputName]; - - // this.update(inputValue); - // } - // }); - // this.payload = payload; - // } - // } - // } - // } else { - // throw new Error(`Too many contentTypes on ${this.operationDetails.operationId}, please add the targeted contentType to the Arazzo Documentation`); - // } - // } - - buildOperations() { - this.operations = []; - - for (const server of this.servers) { - this.operations.push({ - url: `${server.url}${this.path}`, - operation: this.operation, - // headers: this.headers, - // queryParams: this.queryParams, - // payload: this?.payload || null - }); - } - } -} - -module.exports = OpenAPI; diff --git a/test/unit/Arazzo.spec.js b/test/unit/Arazzo.spec.js deleted file mode 100644 index de0dae0..0000000 --- a/test/unit/Arazzo.spec.js +++ /dev/null @@ -1,770 +0,0 @@ -"use strict"; - -const { bundleFromString } = require("@redocly/openapi-core"); -const expect = require("chai").expect; -const peggy = require("peggy"); -const nock = require("nock"); -const sinon = require("sinon"); - -const path = require("node:path"); -const fs = require("node:fs"); -const fsp = require("node:fs/promises"); - -const openAPIMock = require("../mocks/petStoreOpenAPI.json"); - -const Input = require("../../src/Input.js"); -const Logger = require("../../src/Logger.js"); -const OpenAPI = require("../../src/OpenAPI.js"); - -const Arazzo = require("../../src/Arazzo"); - -describe(`Arazzo Document`, function () { - let parser; - before(async () => { - const peggyPath = path.join( - __dirname, - "..", - "..", - "resources", - "rules.peggy", - ); - const peggyRuleSet = await fsp.readFile(peggyPath); - - parser = peggy.generate(peggyRuleSet.toString()); - }); - - const logger = new Logger("3", { - notice: (str) => {}, - error: (str) => {}, - success: (str) => {}, - verbose: (str) => {}, - }); - - describe(`constructor`, function () { - it(`should set the type to arazzo`, function () { - const expected = new Arazzo("./arazzo.json", "arazzo", { - logger: logger, - parser, - }); - - expect(expected).to.be.instanceOf(Arazzo); - expect(expected.type).to.be.equal("arazzo"); - }); - }); - - describe(`setMainArazzo`, function () { - it(`should correctly set the filePath`, function () { - const arazzo = new Arazzo("./arazzo.json", "arazzo", { - logger: logger, - parser, - }); - arazzo.setMainArazzo(); - - expect(arazzo.filePath).to.be.equal( - `${path.resolve(__dirname, "..", "..")}/arazzo.json`, - ); - }); - }); - - xdescribe(`runWorkflows`, function () { - describe(`OpenAPI SourceDescriptions`, function () { - xdescribe(`singular step`, function () { - it(`return successfully when there are no more steps to run`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get( - "/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json", - ) - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": - "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - nock("http://petstore.swagger.io:80", { encodedQueryParams: true }) - .get("/v2/pet/findByStatus") - .query({ status: "pending" }) - .reply( - 200, - [ - { - id: 9515, - category: { id: 7792, name: "string" }, - name: "doggie", - photoUrls: ["string", "string"], - tags: [ - { id: 7284, name: "string" }, - { id: 9936, name: "string" }, - ], - status: "pending", - }, - { - id: 1109, - name: "Test9_02012026", - photoUrls: [], - tags: [], - status: "pending", - }, - { - id: 1003, - name: "Lucy", - photoUrls: ["url1"], - tags: [], - status: "pending", - }, - { - id: 5619, - category: { id: 5381, name: "string" }, - name: "doggie", - photoUrls: ["string", "string"], - tags: [ - { id: 9192, name: "string" }, - { id: 8297, name: "string" }, - ], - status: "pending", - }, - { - id: 100002, - name: "Simple Cat", - photoUrls: ["https://example.com/cat.jpg"], - tags: [], - status: "pending", - }, - { - id: 922337203685477600, - name: "chedder-89811222", - photoUrls: ["./dog.png"], - tags: [], - status: "pending", - }, - { - id: 1088293, - category: { id: 1, name: "Dogs" }, - name: "UpdatedWorkflowDog-1088293", - photoUrls: ["https://example.com/photo1.jpg"], - tags: [{ id: 1, name: "test-tag" }], - status: "pending", - }, - { - id: 745215, - category: { id: 1, name: "Dogs" }, - name: "UpdatedWorkflowDog-745215", - photoUrls: ["https://example.com/photo1.jpg"], - tags: [{ id: 1, name: "test-tag" }], - status: "pending", - }, - ], - { - "access-control-allow-headers": - "Content-Type, api_key, Authorization", - "access-control-allow-methods": "GET, POST, DELETE, PUT", - "access-control-allow-origin": "*", - connection: "keep-alive", - "content-type": "application/json", - date: "Fri, 02 Jan 2026 13:05:43 GMT", - server: "Jetty(9.2.9.v20150224)", - "transfer-encoding": "chunked", - }, - ); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - const expected = await arazzo.runWorkflows(inputFile); - console.log(expected); - } catch (err) { - expect(err).to.not.be.instanceOf(Error); - } - }); - }); - - xdescribe(`multiple Steps in one workflow`, function () { - it(`returns successfully when there are no more steps to run`, async function () { - nock.recorder.rec(); - - // nock('https://raw.githubusercontent.com:443', {"encodedQueryParams":true}) - // .get('/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json') - // .reply(200, ["1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000"], { - // 'accept-ranges': 'bytes', - // 'access-control-allow-origin': '*', - // 'cache-control': 'max-age=300', - // connection: 'keep-alive', - // 'content-encoding': 'gzip', - // 'content-length': '3189', - // 'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'; sandbox", - // 'content-type': 'text/plain; charset=utf-8', - // 'cross-origin-resource-policy': 'cross-origin', - // date: 'Fri, 02 Jan 2026 12:03:42 GMT', - // etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - // expires: 'Fri, 02 Jan 2026 12:08:42 GMT', - // 'source-age': '0', - // 'strict-transport-security': 'max-age=31536000', - // vary: 'Authorization,Accept-Encoding', - // via: '1.1 varnish', - // 'x-cache': 'HIT', - // 'x-cache-hits': '1', - // 'x-content-type-options': 'nosniff', - // 'x-fastly-request-id': 'e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be', - // 'x-frame-options': 'deny', - // 'x-github-request-id': '9733:2549FA:1BB33B8:30A9114:6957ADA3', - // 'x-served-by': 'cache-lhr-egll1980089-LHR', - // 'x-timer': 'S1767355422.386688,VS0,VE1', - // 'x-xss-protection': '1; mode=block' - // }); - - // nock('http://petstore.swagger.io:80', {"encodedQueryParams":true}) - // .get('/v2/pet/findByStatus') - // .query({"status":"pending"}) - // .reply(200, [{"id":9515,"category":{"id":7792,"name":"string"},"name":"doggie","photoUrls":["string","string"],"tags":[{"id":7284,"name":"string"},{"id":9936,"name":"string"}],"status":"pending"},{"id":1109,"name":"Test9_02012026","photoUrls":[],"tags":[],"status":"pending"},{"id":1003,"name":"Lucy","photoUrls":["url1"],"tags":[],"status":"pending"},{"id":5619,"category":{"id":5381,"name":"string"},"name":"doggie","photoUrls":["string","string"],"tags":[{"id":9192,"name":"string"},{"id":8297,"name":"string"}],"status":"pending"},{"id":100002,"name":"Simple Cat","photoUrls":["https://example.com/cat.jpg"],"tags":[],"status":"pending"},{"id":922337203685477600,"name":"chedder-89811222","photoUrls":["./dog.png"],"tags":[],"status":"pending"},{"id":1088293,"category":{"id":1,"name":"Dogs"},"name":"UpdatedWorkflowDog-1088293","photoUrls":["https://example.com/photo1.jpg"],"tags":[{"id":1,"name":"test-tag"}],"status":"pending"},{"id":745215,"category":{"id":1,"name":"Dogs"},"name":"UpdatedWorkflowDog-745215","photoUrls":["https://example.com/photo1.jpg"],"tags":[{"id":1,"name":"test-tag"}],"status":"pending"}], { - // 'access-control-allow-headers': 'Content-Type, api_key, Authorization', - // 'access-control-allow-methods': 'GET, POST, DELETE, PUT', - // 'access-control-allow-origin': '*', - // connection: 'keep-alive', - // 'content-type': 'application/json', - // date: 'Fri, 02 Jan 2026 13:05:43 GMT', - // server: 'Jetty(9.2.9.v20150224)', - // 'transfer-encoding': 'chunked' - // }); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMockWithTwoSteps.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - const expected = await arazzo.runWorkflows(inputFile); - console.log(expected); - } catch (err) { - expect(err).to.not.be.instanceOf(Error); - } - }); - }); - - xit(`should throw an error when a step fails onFailure at step level is included and is set to retry and all retries are exhausted`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - nock("http://petstore.swagger.io:80", { encodedQueryParams: true }) - .get("/v2/pet/findByStatus") - .query({ status: "pending" }) - .times(3) - .reply(404); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMockWithRetryOnFailure.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - const spy = sinon.spy(arazzo, "runOperation"); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(spy.callCount).to.be.equal(3); - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `Call to GET http://petstore.swagger.io/v2/pet/findByStatus failed with a 404`, - ); - } - - spy.restore(); - }); - - xit(`should throw an error when a step fails and onFailure is omitted`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - nock("http://petstore.swagger.io:80", { encodedQueryParams: true }) - .get("/v2/pet/findByStatus") - .query({ status: "pending" }) - .reply(404); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `Call to GET http://petstore.swagger.io/v2/pet/findByStatus failed with a 404`, - ); - } - }); - - it(`should throw an error when the operationId does not exist in the OpenAPI document`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - const missingOperationIdOpenAPIFile = structuredClone(openAPIMock); - delete missingOperationIdOpenAPIFile.paths["/pet/findByStatus"]; - - const stub = sinon.stub(OpenAPI.prototype, "writeDocument").resolves(); - OpenAPI.prototype.fileName = - "Arazzo-Workflow-for-Petstore-openAPI.json"; - OpenAPI.prototype.filePath = path.resolve( - __dirname, - "../..", - "Arazzo-Workflow-for-Petstore-openAPI.json", - ); - await fsp.writeFile( - "./Arazzo-Workflow-for-Petstore-openAPI.json", - JSON.stringify(missingOperationIdOpenAPIFile), - ); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `The OperationId: findPetsByStatus does not exist`, - ); - } - - stub.restore(); - }); - - xit(`should throw an error if redocly can not bundle the document`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - const stub = sinon - .stub(bundleFromString) - .rejects( - new Error("sinon threw an error when bundling the document"), - ); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `sinon threw an error when bundling the document`, - ); - } - - stub.restore(); - }); - }); - - it(`should throw an error when writing a downloaded sourceDescription file fails`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply( - 200, - [ - "1f8b0800000000000013ed5ddd73dbb8117ff75fb1c3eb436fc696ec5cda074faf53274e3a9a4b134f1cb7d7c964ee607245e142020c004a5633fedf3b00488ae0b7be1c39c93df8241104f60bbf5d2c16c8e723008f27c84842bd73f07e1a9d8d4ebd63fd2b6553ee9dc3e72300002f40e90b9a28ca996ef76e46255009042489930841a298a3802b545271917f1f01fc97a7e0130653ca02e0a982583f26b7fae3f58284210a200adecf944acec763697f1a51fee1cfb59f7e042e8033784f853f9a0a44c6031c3154c7f043d6aae1ad3115fef8c711c04b2e4069c22dcdc7b0cc684b25829a219084c2475cc2ef32419f92e8e4232e7f07c541a154b645aa665cd0ff112d0898d248a190232330006f8e4266023a1b9d668204f0145511ea5f73867331150d50c4f2cdf41ac59cfaa6659d0bd3669cbfe173a688af0a05017818131ae97749421592f81fab973dd3e63e7b37a23e3289e5771989cdb01709f167084f0ada01bc5444258a168bc5889856232ec271d6971cbf9a3c7ff1fafac5c993d1e968a6e2281bf2281bd6b30621bd73786f9e7c6eee3ec924332a713e7fb2eaec83e90cef140a46a24beecb561b7dd96e71b914ddb15d7959b215091b68cec595a05ac9a932fc8b398aa59a511666632f796a35bf7aa5918f5e5e8af77b38c8655668be467fd908eb835ef83e4aa9edbf98d65c045a899d9da6b21070bdcf37090a3379642615b7f56602c9bad2f275391a2ea0c2b412a266259bd206599e280997ca252cb710630c1f4a23cb348e89581a4906011060b8800495019419d649adb0587ec473b14d0233c383e0aa647a866c416254d90c2b932150265c4f51876c00efe9e95f2a3fd56998b0398968009425a9f24a4def8bcff76596d14f0555cb62c6d8ff2a63e473fc378da646740b41159e27666e688a4960bf7c681cd1e5ee538a523de3c1b2cadf9f044e350f3f8c7d1e279c215372bc6a4f518eb5108faa03140c799ae7b5757d9304442110067847a5d2f33f7175355ccfa9e96b17aa3e1daceac925c83449228a81a3f063b7c3a7bd1d5ea102c6154c79ca3abbea37c37f6bcaaccfc53b1fedefdf88353aae5bc3d1588752cf96d78aa8b4ac692fc40dcc5503a934000fb74b90b6d37663fd571a296a023ed312e6244a519a28ea1621117c4e030c6041d50c7c1ec704246a835518805482b25076d8bbe64c935270d76af6edfa5cf9b64a0fe629355c7c4a512cab8f2a9c5e3b0caa1951c010038ddeb7083e6792062830802917592458ed51ab970ad4ac299162e529de25110fb0f9a1f4671893dac4d04a5d26863f2204a9f2a019541857e77fe54dab87daab9a2496c6c660c89cd088dc46a86740822c302f80277914942da924bc29492365082bdead34bb3f6afbd6369b5ae0ecc9003893a9895ea66904859155f5a3836864aa49ca4423a06fde1adfc551b3405b9504fd8a826e65412b66d8412b68d12cd6e65fee6b365366f60f69e4f7f570db6e74153734dc4596b1ef60dc509fbf78679dc12ebd8579a3d3571857a19bade521467023cd6b67c7faef13f3f72703b47a254e59381ae444de55e85bd78554f883f51c881e5d7b0beb1be0b6d6feb0ddc377f03e4838fb0ede7539ac05de8a840786dc0e8226027d8d85d9bc6f47f5cf09aa4970bf1348376989db254c2e3be0fc2daa543093f3a52c8cb0baacadc07088ea0ad5b3e524d806820d93cd18ac33353d103cb9043ecd732ec2d0bf1e08f7e32c650ac35ae80fe04db98889ca9afcf5a9d76eca5f237eae8f070f83743ba06b0f98f4d03997d56a6db01de5f6b82bd42409fded239a463d01ed2a1db751eed5e6e3346c691ca06c957bb531a89ea7101045b64cd1fd87aad94b2ee28340bb3c5b21b37485a5b2d6f5a303bfaf3d67dd06ca2e249f2c168b132de2935444c87c1e1815d6d4d40185850af9ed1fe8aba6645022b4a92b5ad342d12233db9690b0a2163b0f03d02f693bd5d3d08d201ae96b5e8d409383b03c57d3a2c3a8ca96f43ba16b1b177254fdb482bf002354b83e005e9af73200dc0ce4ecd09dfb10fde096237e23bccd90049d09d42989e4fa00d5a4a55697bd1750d61e999aac71a6bfc70fc10715d77c494c3f2affd2b4381ba749c449308949e8945b6c16c9d8cea4de5aa4a6c70d0316ddcb4b1ae141442a3c8b4d1efdbc78e075d95e164017097ddb10e7d76553ffdee2c51e75a0c57d85ea442a8124de34be6adf6c5b19e22d657a8a6f1325b810642438a66c8e4c715166be234764eb515ab0274ffed83594ed97e2b03de355e22826899ef859b0a5e356b340f99412a6a889343bf3499382a1edca211ec954ed0dd1c15402513d0889aefac2f501e098357320f2a7277b0c72f79836689a11a67c6da023ee9c0e5711f14d8d8fe9d1ec4c6d115e27bab737c20d801f8161ef233768c5d06f5d0f9f1d1c4ad9b0c5c65a71746de8e629b4adbf6b115ba79f5b5f6443055491859d6966aad89a9b2415fe8ce8bd88c6357b35821ce633cd28e3cfe67f8377573aa1c2eeaf585ab302dadead165da96e359f4f75506209196cc3e452dadca5d9c782bfff0c674058007ffb19ce4e47f046cd50e4854b0b1a45102243bbc35e94cff5b85aa3b96d376f3229ee23a13945e5cfbe6042b3d620a68cc6a67aeaacfe8cdce5cf4e1fe972e33bd43fb6ad20c3436fd2e4a8d27d7796b113e86c9e715f50977049159d63f1c4e0db085e6348ccef5c33cb4e9cc715f8838bab09a0105c74a19f95404f38f650e0a73d9b15640d022d9d870981bb42b9473073dc28c21c6719b6c0304d5be6d27381da5e9dc3312da7f074611d67d1d2980467680af36608110f43d4bb60a697ae8239df0c7623b75e7e6cb0adbcf24b8f2fba3512db4d706bf51d185541c37a7fdd6056f733b67ad5fbd217a6ae6b57662921a2526974d26d337c0ee91c99dd73856a19d91a4be1952dca82f089d9c87da4a639e0dc87e6d66a684db5bea28e161f8d5635dddf95ea2835e2212da353c76ab34b95af78282d8850961f335c4a85f1667a3354753b86fe404893633e374642832aa967d615dada01bdf6b7e2da71e4b393cd6222e5828b96b06f28b3792f2b5eb51ff72324ba02feae9a0bde3fe7eb456dbb5a9bdaa280a67cb6f7ebc95ba2f0e4158d69d3dab53e9e4fa2486f5f0898e973c2248af802833c58aa045afda273c4d7954eef4fa6f7af777f3d7971975081f2e462aa9cf8b29d5f73089532b879f71c163364a0f847d4c7274d479bf3daba9fe5b0aa473f51345e7f1bf141d3137dc53c0f5b7d3f988a8131e63a8ba71ca4c705f434aea586fa32ee9c9cdec699e983fd7e2a04325559d28044295dd458cfb5f1541de6a2a743b69f73450d4c4d77c9f79f68af5fd02058b8d7cda419a211e5b3e5eb4a17bb0d1606a44db4fb3461425bcad81e2ed3e39c3927cae01b71aa5f30e1dbb4603e887cef40c2f688bb3b4a5dddc84d72beedf75c74c1475e3afb30492a5b25b6dfb5c8007871a165bfd5f53b069075cdf2214df21b49f395a7cc6669be61fb345dd336dba67998596ba9fce2b3b63d28d8d326ca179eba5fcaa31ce57fede569abc9540c93c9ceb989e04da52aababf4adfd548a47eb67607a56e85db5c0aea46cb9f3debacf0a20ab80b7e6086e72c11d41ce6872492a80010d26db3a40e392be3248f3d99b9e211a77df6af7ff98a6c5fd34b60c48d70393445f29613f0718d1b9be93c7ad0d7668d43659434e87ca5bce2324b5b879b5ce3347517afd583d802ef0ac525e5007f7e74461e816ee1ee0a4683cfed501816bcba9104387a86ee4a16347e1bdd61195d3c3940aa95e6fd54544b6ed21bf5e74c3d78bc4f8e63dcc38db827ead86da9d69953e06a26c3780198f998db48df5bb7167ddf2df91f0b00d7feff8a025d021a0ab5a56ac5540a578efbdedfed8189ce23722924e28bd5759d6c25012bc61d1b2ba1ca839b5267f01bd2b9b3abe6ea4c2aa93be33d72b9b98818721ed081856126e1da3e94a9a069b28535b745b2f515a089224f5e5558db28e0b6f36db2eccd7663be45291fa36cc4e18ecb41967ce75b3bc93705057ff66e785ca7737b44686dd37176e83363d97c596cfce6d0dcbbebdf96b4f8b81ac9f0d1d698c52bae759fb3ba8cbeda8d4b1e7944e94978635086f4e01f527803ad6eceb5d09d36eee7dd9f3fd90d068c50da7a7adf5d5132024086c1eb3f14aeae67c941b7d578bcbf6a3a5cdefb5db65726f88b45f95caa8ea49be36913af3213f0b77ada9746744f57c6c13d0e847e528d59b467c510f5762ad8d86f209cff9570e6e7aefe737e38d034a225e4373e9f3a4f14462f958ef3978310fe874a9cf7a189c3777e513dfe729ab1f7c2c9d013eb75f6c7bf3cb10ddd5cc7875aab0419c24a1bf38d75674dc68e1de66e1ea56a7c58eee8ffe0fa561a61773630000", - ], - { - "accept-ranges": "bytes", - "access-control-allow-origin": "*", - "cache-control": "max-age=300", - connection: "keep-alive", - "content-encoding": "gzip", - "content-length": "3189", - "content-security-policy": - "default-src 'none'; style-src 'unsafe-inline'; sandbox", - "content-type": "text/plain; charset=utf-8", - "cross-origin-resource-policy": "cross-origin", - date: "Fri, 02 Jan 2026 12:03:42 GMT", - etag: 'W/"6f618be854ed64cd6a2cb850eefecf34866e637d9e73287a9d9d64a8ca3d54b3"', - expires: "Fri, 02 Jan 2026 12:08:42 GMT", - "source-age": "0", - "strict-transport-security": "max-age=31536000", - vary: "Authorization,Accept-Encoding", - via: "1.1 varnish", - "x-cache": "HIT", - "x-cache-hits": "1", - "x-content-type-options": "nosniff", - "x-fastly-request-id": "e357bbd9481ed9b72541f1d5e4d6c921c6dbf9be", - "x-frame-options": "deny", - "x-github-request-id": "9733:2549FA:1BB33B8:30A9114:6957ADA3", - "x-served-by": "cache-lhr-egll1980089-LHR", - "x-timer": "S1767355422.386688,VS0,VE1", - "x-xss-protection": "1; mode=block", - }, - ); - - const stub = sinon - .stub(fsp, "writeFile") - .rejects( - new Error( - "sinon threw an error when writing a sourceDescription file", - ), - ); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `sinon threw an error when writing a sourceDescription file`, - ); - } - - stub.restore(); - }); - - it(`should throw an error when there is more than one sourceDescription and it is incorrectly referenced`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get( - "/readmeio/oas-examples/refs/heads/main/3.1/json/petstore-simple.json", - ) - .reply(404); - - const inputFile = new Input("./test/mocks/validInputById.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/arazzoMockIncorrectlyReferencedSourceDescription.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `No known matching source description for $sourceDescriptions.Arazzo-Workflow-for-simple-petstore-openAP.getById`, - ); - } - }); - - it(`should throw an error when loading a sourceDescription from a URL fails`, async function () { - nock("https://raw.githubusercontent.com:443", { - encodedQueryParams: true, - }) - .get("/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json") - .reply(404); - - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/workingArazzoMock.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `Error fetching document from https://raw.githubusercontent.com/readmeio/oas-examples/refs/heads/main/3.1/json/petstore.json`, - ); - } - }); - - it(`should throw an error when a workflow does not have steps`, async function () { - const inputFile = new Input("./test/mocks/validInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/arazzoMockMissingSteps.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - `Cannot read properties of undefined (reading '0')`, - ); - } - }); - - it(`should throw an error when an invalid input file is attached and does not conform to the workflow schema`, async function () { - const inputFile = new Input("./test/mocks/invalidInput.json", "inputs"); - - const arazzo = new Arazzo( - "./test/mocks/arazzoMockWithInvalidInputs.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(inputFile); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal( - "Input values do not match Input schema", - ); - } - }); - - it(`should throw an error when workflows are omitted`, async function () { - const arazzo = new Arazzo( - "./test/mocks/arazzoMockMissingWorkflows.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal("Missing Workflows"); - } - }); - - it(`should throw an error when sourceDescriptions are omitted`, async function () { - const arazzo = new Arazzo( - "./test/mocks/arazzoMockMissingSourceDescriptions.json", - "arazzo", - { logger: logger, parser }, - ); - arazzo.setMainArazzo(); - - try { - await arazzo.runWorkflows(); - throw new Error("Expected promise to reject but it resolved"); - } catch (err) { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.be.equal("Missing Source Descriptions"); - } - }); - }); -}); diff --git a/test/unit/ArrazoRunner.spec.js b/test/unit/ArrazoRunner.spec.js deleted file mode 100644 index c60e01f..0000000 --- a/test/unit/ArrazoRunner.spec.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; - -const expect = require("chai").expect; -const sinon = require("sinon"); - -const fsp = require("node:fs/promises"); - -const Arazzo = require("../../src/Arazzo.js"); -const Logger = require("../../src/Logger.js"); -const ArazzoRunner = require("../../src/ArazzoRunner.js"); - -describe(`Arazzo Runner`, function () { - const logger = new Logger("3", { - notice: (str) => {}, - error: (str) => {}, - success: (str) => {}, - verbose: (str) => {}, - }); - - describe(`constructor`, function () { - it(`correctly sets the path of the Arazzo Specification File when not passed in `, function () { - const expected = new ArazzoRunner(undefined, { - logger, - inputFile: "./input.json", - }); - - expect(expected.pathToArazzoSpecification).to.be.equal("./arazzo.json"); - }); - - it(`correctly sets the path of the Arazzo Specification File when passed in `, function () { - const expected = new ArazzoRunner("./my-arazzo.json", { - logger, - inputFile: "./input.json", - }); - - expect(expected.pathToArazzoSpecification).to.be.equal( - "./my-arazzo.json", - ); - }); - }); - - describe(`runArazzoWorkflows`, function () { - it(`should run an Arazzo Workflow as expected`, async function () { - const arazzoStub = sinon - .stub(Arazzo.prototype, "runWorkflows") - .resolves(); - - const runner = new ArazzoRunner(undefined, { - logger, - inputFile: "./input.json", - }); - - try { - await runner.runArazzoWorkflows(); - } catch (err) { - throw new Error("Err not expected"); - } - - arazzoStub.restore(); - }); - - it(`throws an error reading the peggy rules fails`, async function () { - const readFileStub = sinon - .stub(fsp, "readFile") - .rejects(new Error("Error thrown from sinon")); - - const runner = new ArazzoRunner(undefined, { - logger, - inputFile: "./input.json", - }); - - try { - await runner.runArazzoWorkflows(); - } catch (err) { - expect(err).to.be.instanceOf(Error); - } - - readFileStub.restore(); - }); - }); -}); diff --git a/test/unit/arazzoPlugin.spec.js b/test/unit/arazzoPlugin.spec.js index 1b4869d..8f2cfa0 100644 --- a/test/unit/arazzoPlugin.spec.js +++ b/test/unit/arazzoPlugin.spec.js @@ -4,7 +4,6 @@ const expect = require("chai").expect; const sinon = require("sinon"); const ArazzoPlugin = require("../../src/ArazzoPlugin.js"); -const ArazzoRunner = require("../../src/ArazzoRunner.js"); const arazzoMock = require("../mocks/arazzoMock.json"); @@ -107,20 +106,14 @@ describe(`Arazzo Plugin`, function () { describe(`Arazzo Runner`, function () { it(`should run an Arazzo Specification`, async function () { - const stub = sinon - .stub(ArazzoRunner.prototype, "runArazzoWorkflows") - .resolves(); - const arazzoPlugin = new ArazzoPlugin(sls, {}, logOutput); await arazzoPlugin.run().catch((err) => { console.error(err); }); - - stub.restore(); }); - it(`should throw an error if the ArazzoRunner rejects`, async function () { + xit(`should throw an error if the ArazzoRunner rejects`, async function () { const stub = sinon .stub(ArazzoRunner.prototype, "runArazzoWorkflows") .rejects(new Error("Thrown from sinon"));