@mablhq/mabl-cli 1.58.7 → 1.58.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/featureSet.js CHANGED
@@ -5,6 +5,7 @@ const types_1 = require("../browserLauncher/types");
5
5
  const ACCESSIBILITY_CHECK_FEATURE_FLAG = 'accessibility_checks';
6
6
  const PERFORMANCE_TESTING_BROWSER_RUNS_FEATURE_FLAG = 'performance_testing_browser_runs';
7
7
  const SMARTER_WAIT_FEATURE_FLAG = 'smarter_wait';
8
+ const CREDENTIALS_CLOUD = 'credentials_cloud';
8
9
  var FindImplementationVersion;
9
10
  (function (FindImplementationVersion) {
10
11
  FindImplementationVersion[FindImplementationVersion["V1"] = 0] = "V1";
@@ -25,6 +26,9 @@ class FeatureSet {
25
26
  hasAccessibilityChecksEnabled() {
26
27
  return this.featureFlags.has(ACCESSIBILITY_CHECK_FEATURE_FLAG);
27
28
  }
29
+ hasCloudCredentialsEnabled() {
30
+ return this.featureFlags.has(CREDENTIALS_CLOUD);
31
+ }
28
32
  hasPerformanceTestingBrowserRunsFeatureEnabled() {
29
33
  return this.featureFlags.has(PERFORMANCE_TESTING_BROWSER_RUNS_FEATURE_FLAG);
30
34
  }
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseColinJoinedVariablePair = exports.validateValuePairInputs = exports.validateArrayInputs = exports.getWorkspaceIdFromAppOrEnv = exports.getJourneyFlowArray = exports.TEST_WITHOUT_FLOWS_MESSAGE = exports.getWorkspaceId = exports.failWrapper = exports.getDescribeDescriptions = void 0;
6
+ exports.getCredentialType = exports.parseColinJoinedVariablePair = exports.validateValuePairInputs = exports.validateArrayInputs = exports.getWorkspaceIdFromAppOrEnv = exports.getJourneyFlowArray = exports.TEST_WITHOUT_FLOWS_MESSAGE = exports.getWorkspaceId = exports.failWrapper = exports.getDescribeDescriptions = void 0;
7
+ const mablApi_1 = require("../../mablApi");
7
8
  const cliConfigProvider_1 = require("../../providers/cliConfigProvider");
8
9
  const constants_1 = require("../constants");
9
10
  const loggingProvider_1 = require("../../providers/logging/loggingProvider");
@@ -112,3 +113,14 @@ function parseColinJoinedVariablePair(input) {
112
113
  return { name, value };
113
114
  }
114
115
  exports.parseColinJoinedVariablePair = parseColinJoinedVariablePair;
116
+ function getCredentialType(credential) {
117
+ if (credential.cloud_only) {
118
+ return credential.type === mablApi_1.Credentials.TypeEnum.Basic
119
+ ? 'Cloud'
120
+ : 'Cloud with MFA';
121
+ }
122
+ return credential.type === mablApi_1.Credentials.TypeEnum.Basic
123
+ ? 'Basic'
124
+ : 'Basic with MFA';
125
+ }
126
+ exports.getCredentialType = getCredentialType;
@@ -11,6 +11,7 @@ const moment = require("moment");
11
11
  const list_1 = require("../../commandUtil/list");
12
12
  const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
13
13
  const constants_1 = require("../../constants");
14
+ const chalk = require('chalk');
14
15
  exports.command = 'list';
15
16
  exports.describe = 'List your credentials';
16
17
  exports.builder = (0, list_1.getListBuilderOptions)('credentials');
@@ -20,11 +21,12 @@ async function listCredentials(parsed) {
20
21
  const limit = parsed.limit;
21
22
  const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
22
23
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
24
+ const hasCloudCredentialsEnabled = (await apiClient.getEffectiveFeaturesByWorkspaceId(workspaceId)).hasCloudCredentialsEnabled();
23
25
  const credentials = await apiClient.getCredentials(workspaceId, limit);
24
- printCredentials(credentials, output);
26
+ printCredentials(credentials, output, hasCloudCredentialsEnabled);
25
27
  return credentials.length;
26
28
  }
27
- function printCredentials(credentials, output) {
29
+ function printCredentials(credentials, output, hasCloudCredentialsEnabled) {
28
30
  switch (output) {
29
31
  case 'json':
30
32
  loggingProvider_1.logger.info(JSON.stringify(credentials, null, 2));
@@ -34,13 +36,18 @@ function printCredentials(credentials, output) {
34
36
  break;
35
37
  default:
36
38
  const table = new cli_table3_1.default({
37
- head: ['ID', 'Name', 'Description', 'Created time'],
39
+ head: ['ID', 'Name', 'Type', 'Description', 'Created time'],
38
40
  wordWrap: true,
39
41
  });
40
42
  credentials.forEach((credential) => {
41
43
  table.push([
42
44
  { rowSpan: 1, content: credential.id, vAlign: 'center' },
43
45
  { rowSpan: 1, content: credential.name, vAlign: 'center' },
46
+ {
47
+ rowSpan: 1,
48
+ content: (0, util_1.getCredentialType)(credential),
49
+ vAlign: 'center',
50
+ },
44
51
  {
45
52
  rowSpan: 1,
46
53
  content: credential.description || '---',
@@ -56,4 +63,7 @@ function printCredentials(credentials, output) {
56
63
  loggingProvider_1.logger.info(table.toString());
57
64
  break;
58
65
  }
66
+ if (hasCloudCredentialsEnabled) {
67
+ loggingProvider_1.logger.info(chalk.bgBlack(chalk.yellow.bold('\nCloud credentials are not available for local runs.')));
68
+ }
59
69
  }
@@ -422,7 +422,7 @@ async function pullDownTestRunConfig(testRunId, apiClient) {
422
422
  }
423
423
  exports.pullDownTestRunConfig = pullDownTestRunConfig;
424
424
  async function extractTestRunConfig(executionMessage, apiClient) {
425
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
425
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
426
426
  const journeyRun = (_a = executionMessage.journey_run) !== null && _a !== void 0 ? _a : (await apiClient.getTestRun(executionMessage.journey_run_id));
427
427
  const planRun = executionMessage.plan_run;
428
428
  const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
@@ -431,20 +431,23 @@ async function extractTestRunConfig(executionMessage, apiClient) {
431
431
  : undefined;
432
432
  return {
433
433
  branchName: (_d = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _d === void 0 ? void 0 : _d.source_control_tag,
434
- credentialsId: ((_e = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _e === void 0 ? void 0 : _e.credentials_required)
435
- ? (_f = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _f === void 0 ? void 0 : _f.credentials_id
434
+ basicAuthCredentialsId: ((_e = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _e === void 0 ? void 0 : _e.http_auth_credentials_required)
435
+ ? (_f = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _f === void 0 ? void 0 : _f.http_auth_credentials_id
436
436
  : undefined,
437
- dataTableVariables: ((_g = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.user_variables) &&
438
- (0, utils_1.variableRowAsScenario)((_h = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.user_variables),
439
- deviceEmulation: (_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.device_emulation,
440
- environmentId: (_l = (_k = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.deployment) === null || _l === void 0 ? void 0 : _l.environment_id,
437
+ credentialsId: ((_g = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _g === void 0 ? void 0 : _g.credentials_required)
438
+ ? (_h = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _h === void 0 ? void 0 : _h.credentials_id
439
+ : undefined,
440
+ dataTableVariables: ((_j = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _j === void 0 ? void 0 : _j.user_variables) &&
441
+ (0, utils_1.variableRowAsScenario)((_k = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.user_variables),
442
+ deviceEmulation: (_l = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.device_emulation,
443
+ environmentId: (_o = (_m = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.deployment) === null || _o === void 0 ? void 0 : _o.environment_id,
441
444
  filterHttpRequests: true,
442
- importedVariables: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.imported_variables,
443
- pageLoadWait: (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.page_load_wait,
445
+ importedVariables: (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.imported_variables,
446
+ pageLoadWait: (_q = journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.page_load_wait,
444
447
  runId: journeyRun.id,
445
448
  runnerType: maybeRunnerType,
446
- testId: (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _p === void 0 ? void 0 : _p.invariant_id,
447
- url: (_r = (_q = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.deployment) === null || _r === void 0 ? void 0 : _r.uri,
449
+ testId: (_r = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _r === void 0 ? void 0 : _r.invariant_id,
450
+ url: (_t = (_s = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _s === void 0 ? void 0 : _s.deployment) === null || _t === void 0 ? void 0 : _t.uri,
448
451
  };
449
452
  }
450
453
  exports.extractTestRunConfig = extractTestRunConfig;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestResultStatus = void 0;
3
+ exports.isApiTestResult = exports.TestResultStatus = void 0;
4
4
  var TestResultStatus;
5
5
  (function (TestResultStatus) {
6
6
  TestResultStatus["failed"] = "failed";
@@ -9,3 +9,7 @@ var TestResultStatus;
9
9
  TestResultStatus["stopped"] = "stopped";
10
10
  TestResultStatus["terminated"] = "terminated";
11
11
  })(TestResultStatus = exports.TestResultStatus || (exports.TestResultStatus = {}));
12
+ function isApiTestResult(result) {
13
+ return 'flowResults' in result;
14
+ }
15
+ exports.isApiTestResult = isApiTestResult;
@@ -8,6 +8,8 @@ const constants_1 = require("../../commands/constants");
8
8
  const util_1 = require("../util");
9
9
  const openUtils_1 = require("./openUtils");
10
10
  const util_2 = require("../../commands/commandUtil/util");
11
+ const loggingProvider_1 = require("../../providers/logging/loggingProvider");
12
+ const chalk = require('chalk');
11
13
  exports.DEFAULT_HEIGHT = 800;
12
14
  exports.DEFAULT_WIDTH = 1000;
13
15
  exports.SENDER = 'cli';
@@ -31,6 +33,13 @@ async function trainNewTest(trainingSessionOptions) {
31
33
  if (planId) {
32
34
  await apiClient.getPlan(planId);
33
35
  }
36
+ if (credentialsId) {
37
+ const credential = await apiClient.getCredential(credentialsId);
38
+ if (credential.cloud_only) {
39
+ loggingProvider_1.logger.error(chalk.red.bold(`Cannot use Cloud Credentials in the trainer. Use a basic one instead.`));
40
+ process.exit(1);
41
+ }
42
+ }
34
43
  if (applicationId) {
35
44
  await apiClient.getApplication(applicationId);
36
45
  }
@@ -70,6 +79,13 @@ async function editTest(trainingSessionOptions) {
70
79
  const credentialsId = (_b = trainingSessionOptions.credentialsId) !== null && _b !== void 0 ? _b : testRunIdConfig.credentialsId;
71
80
  const branchName = (_d = (_c = trainingSessionOptions.branchName) !== null && _c !== void 0 ? _c : testRunIdConfig.branchName) !== null && _d !== void 0 ? _d : constants_1.DefaultBranchName;
72
81
  const environmentId = (_e = trainingSessionOptions.environmentId) !== null && _e !== void 0 ? _e : testRunIdConfig.environmentId;
82
+ if (credentialsId) {
83
+ const credential = await apiClient.getCredential(credentialsId);
84
+ if (credential.cloud_only) {
85
+ loggingProvider_1.logger.error(chalk.red.bold(`Cannot use Cloud Credentials in the trainer. Use a basic one instead.`));
86
+ process.exit(1);
87
+ }
88
+ }
73
89
  const testId = (_f = trainingSessionOptions.testId) !== null && _f !== void 0 ? _f : testRunIdConfig.testId;
74
90
  if (!testId) {
75
91
  throw new Error('Unable to determine test Id run');