From a233ee3915173d78d175f1a2fcbff53223c35077 Mon Sep 17 00:00:00 2001 From: Mario Doiron <5252025+doiron@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:44:28 -0800 Subject: [PATCH] feat: add ASK_SKIP_DOMAIN_VALIDATION to allow skipping manifest api validation prior to skill enablement --- .../skill-metadata-controller/index.js | 4 ++++ .../skill-metadata-controller-test.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/controllers/skill-metadata-controller/index.js b/lib/controllers/skill-metadata-controller/index.js index d10c35b8..86f754be 100644 --- a/lib/controllers/skill-metadata-controller/index.js +++ b/lib/controllers/skill-metadata-controller/index.js @@ -111,6 +111,10 @@ module.exports = class SkillMetadataController { * Validates domain info */ validateDomain() { + if (process.env.ASK_SKIP_DOMAIN_VALIDATION) { + return; + } + const domainInfo = Manifest.getInstance().getApis(); if (!domainInfo || R.isEmpty(domainInfo)) { throw new CLiError('Skill information is not valid. Please make sure "apis" field in the skill.json is not empty.'); diff --git a/test/unit/controller/skill-metadata-controller-test.js b/test/unit/controller/skill-metadata-controller-test.js index df18b25a..d4cad4f8 100644 --- a/test/unit/controller/skill-metadata-controller-test.js +++ b/test/unit/controller/skill-metadata-controller-test.js @@ -61,6 +61,7 @@ describe("Controller test - skill metadata controller test", () => { }); afterEach(() => { + delete process.env.ASK_SKIP_DOMAIN_VALIDATION; ResourcesConfig.dispose(); Manifest.dispose(); sinon.restore(); @@ -263,6 +264,24 @@ describe("Controller test - skill metadata controller test", () => { expect(() => skillMetaController.validateDomain()).to.throw(CliWarn, expectedErrMessage); }); + it("| skips validation when ASK_SKILL_DOMAIN_VALIDATION is set", () => { + // setup + process.env.ASK_SKIP_DOMAIN_VALIDATION = 1; + Manifest.getInstance().setApis({ + custom: {}, + unknownApi: {}, + smartHome: {}, + }); + + const getApisSpy = sinon.spy(Manifest.prototype, "getApis"); + + // call + skillMetaController.validateDomain(); + + // verify + expect(getApisSpy.callCount).eq(0); + }); + it("| callback error when getSkillEnablement return error", (done) => { // setup sinon.stub(httpClient, "request").callsArgWith(3, "getSkillEnablementError"); // stub smapi request