Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ASK_SKIP_DOMAIN_VALIDATION to allow skipping manifest api v… #500

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 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,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.');
Expand Down
23 changes: 23 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_FORCE_ENABLE;
ResourcesConfig.dispose();
Manifest.dispose();
sinon.restore();
Expand Down Expand Up @@ -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
Expand Down
Loading