diff --git a/lib/controllers/skill-metadata-controller/index.js b/lib/controllers/skill-metadata-controller/index.js index d10c35b8..e3d50d4c 100644 --- a/lib/controllers/skill-metadata-controller/index.js +++ b/lib/controllers/skill-metadata-controller/index.js @@ -111,6 +111,11 @@ module.exports = class SkillMetadataController { * Validates domain info */ validateDomain() { + if (process.env.ASK_FORCE_ENABLE) { + Messenger.getInstance().warn("The ASK_FORCE_ENABLE environment variable is set. Skipping domain validation.\n"); + 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..042a09db 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_FORCE_ENABLE; ResourcesConfig.dispose(); Manifest.dispose(); sinon.restore(); @@ -263,6 +264,28 @@ describe("Controller test - skill metadata controller test", () => { expect(() => skillMetaController.validateDomain()).to.throw(CliWarn, expectedErrMessage); }); + it("| skips validation when ASK_FORCE_ENABLE is set", () => { + // setup + process.env.ASK_FORCE_ENABLE = 1; + Manifest.getInstance().setApis({ + custom: {}, + unknownApi: {}, + smartHome: {}, + }); + const getApisSpy = sinon.spy(Manifest.prototype, "getApis"); + const warnStub = sinon.stub(); + sinon.stub(Messenger, "getInstance").returns({ + warn: warnStub, + }); + const expectedWarningMessage = "The ASK_FORCE_ENABLE environment variable is set. Skipping domain validation.\n" + // call + skillMetaController.validateDomain(); + // verify + expect(getApisSpy.callCount).eq(0); + expect(warnStub.callCount).equal(1); + expect(warnStub.args[0][0]).equal(expectedWarningMessage); + }); + it("| callback error when getSkillEnablement return error", (done) => { // setup sinon.stub(httpClient, "request").callsArgWith(3, "getSkillEnablementError"); // stub smapi request