@webex/webex-core 3.10.0-next.13 → 3.10.0-next.14

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.
@@ -286,7 +286,7 @@ var Batcher = _webexPlugin.default.extend({
286
286
  fingerprintResponse: function fingerprintResponse(item) {
287
287
  throw new Error('fingerprintResponse() must be implemented');
288
288
  },
289
- version: "3.10.0-next.13"
289
+ version: "3.10.0-next.14"
290
290
  });
291
291
  var _default2 = exports.default = Batcher;
292
292
  //# sourceMappingURL=batcher.js.map
@@ -556,7 +556,7 @@ var Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
556
556
  this.refresh();
557
557
  }
558
558
  },
559
- version: "3.10.0-next.13"
559
+ version: "3.10.0-next.14"
560
560
  }, (0, _applyDecoratedDescriptor2.default)(_obj, "getUserToken", [_dec, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "getUserToken"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initialize", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "initialize"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "invalidate", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "invalidate"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), _obj));
561
561
  var _default = exports.default = Credentials;
562
562
  //# sourceMappingURL=credentials.js.map
@@ -532,7 +532,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
532
532
  return res.body;
533
533
  });
534
534
  },
535
- version: "3.10.0-next.13"
535
+ version: "3.10.0-next.14"
536
536
  }, (0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj), _obj));
537
537
  var _default = exports.default = Token;
538
538
  //# sourceMappingURL=token.js.map
@@ -66,6 +66,16 @@ var ServiceUrl = _ampersandState.default.extend({
66
66
  }) : this.hosts.filter(function (host) {
67
67
  return host.homeCluster;
68
68
  });
69
+
70
+ // Filter out hosts with non-positive priorities (including -1)
71
+ filteredHosts = filteredHosts.filter(function (host) {
72
+ return host.priority > 0;
73
+ });
74
+
75
+ // If no valid hosts remain after filtering, return the default URL
76
+ if (filteredHosts.length === 0) {
77
+ return this.defaultUrl;
78
+ }
69
79
  var aliveHosts = filteredHosts.filter(function (host) {
70
80
  return !host.failed;
71
81
  });
@@ -76,7 +86,7 @@ var ServiceUrl = _ampersandState.default.extend({
76
86
  }) : aliveHosts;
77
87
  return this._generateHostUrl(filteredHosts.reduce(function (previous, current) {
78
88
  return previous.priority > current.priority || !previous.homeCluster ? current : previous;
79
- }, {}).host);
89
+ }, filteredHosts[0]).host);
80
90
  },
81
91
  /**
82
92
  * Attempt to mark a host from this `ServiceUrl` as failed and return true
@@ -1 +1 @@
1
- {"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","concat","port","format","_getHostUrls","_this","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","_Url$parse","hostname","foundHost","find","hostObj","get","priorityHost","_default","exports","default"],"sources":["service-url.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceUrl = AmpState.extend({\n namespace: 'ServiceUrl',\n\n props: {\n defaultUrl: ['string', true, undefined],\n hosts: ['array', false, () => []],\n name: ['string', true, undefined],\n },\n\n /**\n * Generate a host url based on the host\n * uri provided.\n * @param {string} hostUri\n * @returns {string}\n */\n _generateHostUrl(hostUri) {\n const url = Url.parse(this.defaultUrl);\n\n // setting url.hostname will not apply during Url.format(), set host via\n // a string literal instead.\n url.host = `${hostUri}${url.port ? `:${url.port}` : ''}`;\n\n return Url.format(url);\n },\n\n /**\n * Generate a list of urls based on this\n * `ServiceUrl`'s known hosts.\n * @returns {string[]}\n */\n _getHostUrls() {\n return this.hosts.map((host) => ({\n url: this._generateHostUrl(host.host),\n priority: host.priority,\n }));\n },\n\n /**\n * Get the current host url with the highest priority. If a clusterId is not\n * provided, this will only return a URL with a filtered host that has the\n * `homeCluster` value set to `true`.\n *\n * @param {string} [clusterId] - The clusterId to filter for a priority host.\n * @returns {string} - The priority host url.\n */\n _getPriorityHostUrl(clusterId) {\n if (this.hosts.length === 0) {\n return this.defaultUrl;\n }\n\n let filteredHosts = clusterId\n ? this.hosts.filter((host) => host.id === clusterId)\n : this.hosts.filter((host) => host.homeCluster);\n\n const aliveHosts = filteredHosts.filter((host) => !host.failed);\n\n filteredHosts =\n aliveHosts.length === 0\n ? filteredHosts.map((host) => {\n /* eslint-disable-next-line no-param-reassign */\n host.failed = false;\n\n return host;\n })\n : aliveHosts;\n\n return this._generateHostUrl(\n filteredHosts.reduce(\n (previous, current) =>\n previous.priority > current.priority || !previous.homeCluster ? current : previous,\n {}\n ).host\n );\n },\n\n /**\n * Attempt to mark a host from this `ServiceUrl` as failed and return true\n * if the provided url has a host that could be successfully marked as failed.\n *\n * @param {string} url\n * @returns {boolean}\n */\n failHost(url) {\n if (url === this.defaultUrl) {\n return true;\n }\n\n const {hostname} = Url.parse(url);\n const foundHost = this.hosts.find((hostObj) => hostObj.host === hostname);\n\n if (foundHost) {\n foundHost.failed = true;\n }\n\n return foundHost !== undefined;\n },\n\n /**\n * Get the current `defaultUrl` or generate a url using the host with the\n * highest priority via host rendering.\n *\n * @param {boolean} [priorityHost] - Retrieve the priority host.\n * @param {string} [clusterId] - Cluster to match a host against.\n * @returns {string} - The full service url.\n */\n get(priorityHost, clusterId) {\n if (!priorityHost) {\n return this.defaultUrl;\n }\n\n return this._getPriorityHostUrl(clusterId);\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceUrl;\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA,IAAME,UAAU,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACjCC,SAAS,EAAE,YAAY;EAEvBC,KAAK,EAAE;IACLC,UAAU,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAEC,SAAS,CAAC;IACvCC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE;MAAA,OAAM,EAAE;IAAA,EAAC;IACjCC,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAEF,SAAS;EAClC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEG,gBAAgB,WAAhBA,gBAAgBA,CAACC,OAAO,EAAE;IACxB,IAAMC,GAAG,GAAGC,YAAG,CAACC,KAAK,CAAC,IAAI,CAACR,UAAU,CAAC;;IAEtC;IACA;IACAM,GAAG,CAACG,IAAI,MAAAC,MAAA,CAAML,OAAO,EAAAK,MAAA,CAAGJ,GAAG,CAACK,IAAI,OAAAD,MAAA,CAAOJ,GAAG,CAACK,IAAI,IAAK,EAAE,CAAE;IAExD,OAAOJ,YAAG,CAACK,MAAM,CAACN,GAAG,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEO,YAAY,WAAZA,YAAYA,CAAA,EAAG;IAAA,IAAAC,KAAA;IACb,OAAO,IAAI,CAACZ,KAAK,CAACa,GAAG,CAAC,UAACN,IAAI;MAAA,OAAM;QAC/BH,GAAG,EAAEQ,KAAI,CAACV,gBAAgB,CAACK,IAAI,CAACA,IAAI,CAAC;QACrCO,QAAQ,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AAI;IACb;IAEA,IAAA8B,UAAA,GAAmBvB,YAAG,CAACC,KAAK,CAACF,GAAG,CAAC;MAA1ByB,QAAQ,GAAAD,UAAA,CAARC,QAAQ;IACf,IAAMC,SAAS,GAAG,IAAI,CAAC9B,KAAK,CAAC+B,IAAI,CAAC,UAACC,OAAO;MAAA,OAAKA,OAAO,CAACzB,IAAI,KAAKsB,QAAQ;IAAA,EAAC;IAEzE,IAAIC,SAAS,EAAE;MACbA,SAAS,CAACP,MAAM,GAAG,IAAI;IACzB;IAEA,OAAOO,SAAS,KAAK/B,SAAS;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEkC,GAAG,WAAHA,GAAGA,CAACC,YAAY,EAAElB,SAAS,EAAE;IAC3B,IAAI,CAACkB,YAAY,EAAE;MACjB,OAAO,IAAI,CAACpC,UAAU;IACxB;IAEA,OAAO,IAAI,CAACiB,mBAAmB,CAACC,SAAS,CAAC;EAC5C;AACF,CAAC,CAAC;AACF;AAAA,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEe5C,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","concat","port","format","_getHostUrls","_this","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","_Url$parse","hostname","foundHost","find","hostObj","get","priorityHost","_default","exports","default"],"sources":["service-url.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceUrl = AmpState.extend({\n namespace: 'ServiceUrl',\n\n props: {\n defaultUrl: ['string', true, undefined],\n hosts: ['array', false, () => []],\n name: ['string', true, undefined],\n },\n\n /**\n * Generate a host url based on the host\n * uri provided.\n * @param {string} hostUri\n * @returns {string}\n */\n _generateHostUrl(hostUri) {\n const url = Url.parse(this.defaultUrl);\n\n // setting url.hostname will not apply during Url.format(), set host via\n // a string literal instead.\n url.host = `${hostUri}${url.port ? `:${url.port}` : ''}`;\n\n return Url.format(url);\n },\n\n /**\n * Generate a list of urls based on this\n * `ServiceUrl`'s known hosts.\n * @returns {string[]}\n */\n _getHostUrls() {\n return this.hosts.map((host) => ({\n url: this._generateHostUrl(host.host),\n priority: host.priority,\n }));\n },\n\n /**\n * Get the current host url with the highest priority. If a clusterId is not\n * provided, this will only return a URL with a filtered host that has the\n * `homeCluster` value set to `true`.\n *\n * @param {string} [clusterId] - The clusterId to filter for a priority host.\n * @returns {string} - The priority host url.\n */\n _getPriorityHostUrl(clusterId) {\n if (this.hosts.length === 0) {\n return this.defaultUrl;\n }\n\n let filteredHosts = clusterId\n ? this.hosts.filter((host) => host.id === clusterId)\n : this.hosts.filter((host) => host.homeCluster);\n\n // Filter out hosts with non-positive priorities (including -1)\n filteredHosts = filteredHosts.filter((host) => host.priority > 0);\n\n // If no valid hosts remain after filtering, return the default URL\n if (filteredHosts.length === 0) {\n return this.defaultUrl;\n }\n\n const aliveHosts = filteredHosts.filter((host) => !host.failed);\n\n filteredHosts =\n aliveHosts.length === 0\n ? filteredHosts.map((host) => {\n /* eslint-disable-next-line no-param-reassign */\n host.failed = false;\n\n return host;\n })\n : aliveHosts;\n\n return this._generateHostUrl(\n filteredHosts.reduce(\n (previous, current) =>\n previous.priority > current.priority || !previous.homeCluster ? current : previous,\n filteredHosts[0]\n ).host\n );\n },\n\n /**\n * Attempt to mark a host from this `ServiceUrl` as failed and return true\n * if the provided url has a host that could be successfully marked as failed.\n *\n * @param {string} url\n * @returns {boolean}\n */\n failHost(url) {\n if (url === this.defaultUrl) {\n return true;\n }\n\n const {hostname} = Url.parse(url);\n const foundHost = this.hosts.find((hostObj) => hostObj.host === hostname);\n\n if (foundHost) {\n foundHost.failed = true;\n }\n\n return foundHost !== undefined;\n },\n\n /**\n * Get the current `defaultUrl` or generate a url using the host with the\n * highest priority via host rendering.\n *\n * @param {boolean} [priorityHost] - Retrieve the priority host.\n * @param {string} [clusterId] - Cluster to match a host against.\n * @returns {string} - The full service url.\n */\n get(priorityHost, clusterId) {\n if (!priorityHost) {\n return this.defaultUrl;\n }\n\n return this._getPriorityHostUrl(clusterId);\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceUrl;\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA,IAAME,UAAU,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACjCC,SAAS,EAAE,YAAY;EAEvBC,KAAK,EAAE;IACLC,UAAU,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAEC,SAAS,CAAC;IACvCC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE;MAAA,OAAM,EAAE;IAAA,EAAC;IACjCC,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAEF,SAAS;EAClC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEG,gBAAgB,WAAhBA,gBAAgBA,CAACC,OAAO,EAAE;IACxB,IAAMC,GAAG,GAAGC,YAAG,CAACC,KAAK,CAAC,IAAI,CAACR,UAAU,CAAC;;IAEtC;IACA;IACAM,GAAG,CAACG,IAAI,MAAAC,MAAA,CAAML,OAAO,EAAAK,MAAA,CAAGJ,GAAG,CAACK,IAAI,OAAAD,MAAA,CAAOJ,GAAG,CAACK,IAAI,IAAK,EAAE,CAAE;IAExD,OAAOJ,YAAG,CAACK,MAAM,CAACN,GAAG,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEO,YAAY,WAAZA,YAAYA,CAAA,EAAG;IAAA,IAAAC,KAAA;IACb,OAAO,IAAI,CAACZ,KAAK,CAACa,GAAG,CAAC,UAACN,IAAI;MAAA,OAAM;QAC/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QAAQ,GAAGY,OAAO,CAACZ,QAAQ,IAAI,CAACW,QAAQ,CAACJ,WAAW,GAAGK,OAAO,GAAGD,QAAQ;IAAA,GACpFP,aAAa,CAAC,CAAC,CACjB,CAAC,CAACX,IACJ,CAAC;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEoB,QAAQ,WAARA,QAAQA,CAACvB,GAAG,EAAE;IACZ,IAAIA,GAAG,KAAK,IAAI,CAACN,UAAU,EAAE;MAC3B,OAAO,IAAI;IACb;IAEA,IAAA8B,UAAA,GAAmBvB,YAAG,CAACC,KAAK,CAACF,GAAG,CAAC;MAA1ByB,QAAQ,GAAAD,UAAA,CAARC,QAAQ;IACf,IAAMC,SAAS,GAAG,IAAI,CAAC9B,KAAK,CAAC+B,IAAI,CAAC,UAACC,OAAO;MAAA,OAAKA,OAAO,CAACzB,IAAI,KAAKsB,QAAQ;IAAA,EAAC;IAEzE,IAAIC,SAAS,EAAE;MACbA,SAAS,CAACP,MAAM,GAAG,IAAI;IACzB;IAEA,OAAOO,SAAS,KAAK/B,SAAS;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEkC,GAAG,WAAHA,GAAGA,CAACC,YAAY,EAAElB,SAAS,EAAE;IAC3B,IAAI,CAACkB,YAAY,EAAE;MACjB,OAAO,IAAI,CAACpC,UAAU;IACxB;IAEA,OAAO,IAAI,CAACiB,mBAAmB,CAACC,SAAS,CAAC;EAC5C;AACF,CAAC,CAAC;AACF;AAAA,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEe5C,UAAU","ignoreList":[]}
@@ -1425,7 +1425,7 @@ var Services = _webexPlugin.default.extend({
1425
1425
  }, _callee4);
1426
1426
  })));
1427
1427
  },
1428
- version: "3.10.0-next.13"
1428
+ version: "3.10.0-next.14"
1429
1429
  });
1430
1430
  /* eslint-enable no-underscore-dangle */
1431
1431
  var _default = exports.default = Services;
@@ -1355,7 +1355,7 @@ var Services = _webexPlugin.default.extend({
1355
1355
  }, _callee3);
1356
1356
  })));
1357
1357
  },
1358
- version: "3.10.0-next.13"
1358
+ version: "3.10.0-next.14"
1359
1359
  });
1360
1360
  /* eslint-enable no-underscore-dangle */
1361
1361
  var _default = exports.default = Services;
@@ -57,7 +57,7 @@ var Logger = _webexPlugin.default.extend({
57
57
  info: wrapConsoleMethod('info'),
58
58
  debug: wrapConsoleMethod('debug'),
59
59
  trace: wrapConsoleMethod('trace'),
60
- version: "3.10.0-next.13"
60
+ version: "3.10.0-next.14"
61
61
  });
62
62
  (0, _webexCore.registerPlugin)('logger', Logger);
63
63
  var _default = exports.default = Logger;
@@ -96,7 +96,7 @@ var MAX_FILE_SIZE_IN_MB = 2048;
96
96
  * @class
97
97
  */
98
98
  var WebexCore = _ampersandState.default.extend((_obj = {
99
- version: "3.10.0-next.13",
99
+ version: "3.10.0-next.14",
100
100
  children: {
101
101
  internal: _webexInternalCore.default
102
102
  },
@@ -634,7 +634,7 @@ var WebexCore = _ampersandState.default.extend((_obj = {
634
634
  });
635
635
  }
636
636
  }, (0, _applyDecoratedDescriptor2.default)(_obj, "_uploadPhaseUpload", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, "_uploadPhaseUpload"), _obj), _obj));
637
- WebexCore.version = "3.10.0-next.13";
637
+ WebexCore.version = "3.10.0-next.14";
638
638
  (0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);
639
639
  (0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);
640
640
  var _default = exports.default = WebexCore;
package/package.json CHANGED
@@ -33,10 +33,10 @@
33
33
  "@sinonjs/fake-timers": "^6.0.1",
34
34
  "@webex/babel-config-legacy": "0.0.0",
35
35
  "@webex/eslint-config-legacy": "0.0.0",
36
- "@webex/internal-plugin-device": "3.10.0-next.13",
36
+ "@webex/internal-plugin-device": "3.10.0-next.14",
37
37
  "@webex/jest-config-legacy": "0.0.0",
38
38
  "@webex/legacy-tools": "0.0.0",
39
- "@webex/plugin-logger": "3.10.0-next.13",
39
+ "@webex/plugin-logger": "3.10.0-next.14",
40
40
  "@webex/test-helper-chai": "3.10.0-next.1",
41
41
  "@webex/test-helper-make-local-url": "3.10.0-next.1",
42
42
  "@webex/test-helper-mocha": "3.10.0-next.1",
@@ -73,5 +73,5 @@
73
73
  "test:style": "eslint ./src/**/*.*",
74
74
  "test:unit": "webex-legacy-tools test --unit --runner jest"
75
75
  },
76
- "version": "3.10.0-next.13"
76
+ "version": "3.10.0-next.14"
77
77
  }
@@ -60,6 +60,14 @@ const ServiceUrl = AmpState.extend({
60
60
  ? this.hosts.filter((host) => host.id === clusterId)
61
61
  : this.hosts.filter((host) => host.homeCluster);
62
62
 
63
+ // Filter out hosts with non-positive priorities (including -1)
64
+ filteredHosts = filteredHosts.filter((host) => host.priority > 0);
65
+
66
+ // If no valid hosts remain after filtering, return the default URL
67
+ if (filteredHosts.length === 0) {
68
+ return this.defaultUrl;
69
+ }
70
+
63
71
  const aliveHosts = filteredHosts.filter((host) => !host.failed);
64
72
 
65
73
  filteredHosts =
@@ -76,7 +84,7 @@ const ServiceUrl = AmpState.extend({
76
84
  filteredHosts.reduce(
77
85
  (previous, current) =>
78
86
  previous.priority > current.priority || !previous.homeCluster ? current : previous,
79
- {}
87
+ filteredHosts[0]
80
88
  ).host
81
89
  );
82
90
  },
@@ -151,6 +151,116 @@ describe('webex-core', () => {
151
151
 
152
152
  assert.isTrue(homeClusterUrls.every((host) => !host.failed));
153
153
  });
154
+
155
+ describe('when hosts have negative priorities', () => {
156
+ it('should return defaultUrl when all hosts have negative priorities', () => {
157
+ const negativeServiceUrl = new ServiceUrl({
158
+ defaultUrl: 'https://default.example.com/api/v1',
159
+ hosts: [
160
+ {
161
+ host: 'example-host-neg1.com',
162
+ priority: -1,
163
+ ttl: -1,
164
+ id: '1',
165
+ homeCluster: true,
166
+ },
167
+ {
168
+ host: 'example-host-neg2.com',
169
+ priority: -1,
170
+ ttl: -1,
171
+ id: '2',
172
+ homeCluster: true,
173
+ },
174
+ ],
175
+ name: 'negative-priority-test',
176
+ });
177
+
178
+ assert.equal(
179
+ negativeServiceUrl._getPriorityHostUrl(),
180
+ 'https://default.example.com/api/v1'
181
+ );
182
+ });
183
+
184
+ it('should return defaultUrl when all hosts have zero priority', () => {
185
+ const zeroServiceUrl = new ServiceUrl({
186
+ defaultUrl: 'https://default.example.com/api/v1',
187
+ hosts: [
188
+ {
189
+ host: 'example-host-zero.com',
190
+ priority: 0,
191
+ ttl: -1,
192
+ id: '1',
193
+ homeCluster: true,
194
+ },
195
+ ],
196
+ name: 'zero-priority-test',
197
+ });
198
+
199
+ assert.equal(zeroServiceUrl._getPriorityHostUrl(), 'https://default.example.com/api/v1');
200
+ });
201
+
202
+ it('should ignore hosts with negative priorities and return valid host', () => {
203
+ const mixedServiceUrl = new ServiceUrl({
204
+ defaultUrl: 'https://default.example.com/api/v1',
205
+ hosts: [
206
+ {
207
+ host: 'example-host-neg.com',
208
+ priority: -1,
209
+ ttl: -1,
210
+ id: '1',
211
+ homeCluster: true,
212
+ },
213
+ {
214
+ host: 'example-host-valid.com',
215
+ priority: 5,
216
+ ttl: -1,
217
+ id: '2',
218
+ homeCluster: true,
219
+ },
220
+ ],
221
+ name: 'mixed-priority-test',
222
+ });
223
+
224
+ const result = mixedServiceUrl._getPriorityHostUrl();
225
+
226
+ assert.include(result, 'example-host-valid.com');
227
+ assert.notInclude(result, 'example-host-neg.com');
228
+ });
229
+
230
+ it('should select lowest positive priority host when mixed with negative priorities', () => {
231
+ const mixedServiceUrl = new ServiceUrl({
232
+ defaultUrl: 'https://default.example.com/api/v1',
233
+ hosts: [
234
+ {
235
+ host: 'example-host-neg.com',
236
+ priority: -1,
237
+ ttl: -1,
238
+ id: '1',
239
+ homeCluster: true,
240
+ },
241
+ {
242
+ host: 'example-host-p5.com',
243
+ priority: 5,
244
+ ttl: -1,
245
+ id: '2',
246
+ homeCluster: true,
247
+ },
248
+ {
249
+ host: 'example-host-p2.com',
250
+ priority: 2,
251
+ ttl: -1,
252
+ id: '3',
253
+ homeCluster: true,
254
+ },
255
+ ],
256
+ name: 'mixed-priority-test',
257
+ });
258
+
259
+ const result = mixedServiceUrl._getPriorityHostUrl();
260
+
261
+ assert.include(result, 'example-host-p2.com');
262
+ });
263
+ });
154
264
  });
155
265
 
156
266
  describe('#failHost()', () => {