Skip to content

Commit

Permalink
feat: add ASK_SKIP_DOMAIN_VALIDATION to allow skipping manifest api v…
Browse files Browse the repository at this point in the history
…alidation prior to skill enablement
  • Loading branch information
Mario Doiron committed Dec 11, 2023
1 parent d9a0cc6 commit a233ee3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/controllers/skill-metadata-controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
19 changes: 19 additions & 0 deletions test/unit/controller/skill-metadata-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a233ee3

Please sign in to comment.