Skip to content

Commit a01a6f9

Browse files
committed
validate endpoint on client --endpoint
1 parent d47763a commit a01a6f9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

templates/cli/lib/commands/generic.js.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const inquirer = require("inquirer");
22
const { Command } = require("commander");
3+
const Client = require("../client");
34
const { sdkForConsole } = require("../sdks");
45
const { globalConfig, localConfig } = require("../config");
56
const { actionRunner, success, parseBool, commandDescriptions, log, parse } = require("../parser");
@@ -68,6 +69,13 @@ const client = new Command("client")
6869
try {
6970
let url = new URL(endpoint);
7071
if (url.protocol === "http:" || url.protocol === "https:") {
72+
let apClient = new Client().setEndpoint(endpoint);
73+
let response = await apClient.call('GET', '/mock/tests/foo', {}, {'x': 'a', 'y': 1, 'z': ['a']});
74+
if(response.result && response.result === 'GET:/v1/mock/tests/foo:passed') {
75+
globalConfig.setEndpoint(endpoint);
76+
} else {
77+
throw new Error();
78+
}
7179
globalConfig.setEndpoint(endpoint);
7280
} else {
7381
throw new Error();

0 commit comments

Comments
 (0)