@webex/internal-plugin-wdm
Advanced tools
Comparing version 1.61.3 to 1.62.0
@@ -137,2 +137,3 @@ 'use strict'; | ||
intranetInactivityCheckUrl: 'string', | ||
inNetworkInactivityDuration: 'number', // Newly added duration for internal network inactivity | ||
/** | ||
@@ -231,3 +232,7 @@ * Is ECM (external content management) enabled for the whole org | ||
logoutTimer: 'any', | ||
lastUserActivityDate: 'number' | ||
inNetworkLogoutTimer: 'any', // Second logout timer when client is connected to org's internal network | ||
lastUserActivityDate: 'number', | ||
lastInNetworkUserActivityDate: 'number', // Update last user activity date to reset inNetworkInactivityTimer | ||
isInMeeting: 'boolean', // Boolean for checking user is in meeting to prevent in advertent timeout due to inactivity | ||
isInNetwork: 'boolean' // Boolean to ensure _resetLogoutTimer isn't called repeatedly once its known client is connected to org's internal network | ||
}, | ||
@@ -399,13 +404,34 @@ | ||
this.isInNetwork = false; | ||
this.on('change:serviceHostMap', this._updateServiceCatalog); | ||
this.listenToAndRun(this, 'change:intranetInactivityCheckUrl', function () { | ||
return _this4._resetLogoutTimer(); | ||
_this4._resetLogoutTimer();_this4._inNetworkResetLogoutTimer(); | ||
}); | ||
this.listenToAndRun(this, 'change:intranetInactivityDuration', function () { | ||
return _this4._resetLogoutTimer(); | ||
_this4._resetLogoutTimer();_this4._inNetworkResetLogoutTimer(); | ||
}); | ||
this.listenToAndRun(this, 'change:inNetworkInactivityDuration', function () { | ||
_this4._resetLogoutTimer();_this4._inNetworkResetLogoutTimer(); | ||
}); | ||
this.listenTo(this.webex, 'user-activity', function () { | ||
_this4.lastUserActivityDate = Date.now(); | ||
_this4.lastInNetworkUserActivityDate = Date.now(); | ||
}); | ||
/** | ||
* Meeting started and ended event listenrs | ||
* When client enters into the meeting set isInMeeting to true | ||
* This tells also triggers both the timers inturn un-setting the timers until meeting ends | ||
* On meeting end/clean-up the timers are reset. | ||
*/ | ||
this.listenTo(this.webex, 'meeting started', function () { | ||
_this4.isInMeeting = true; | ||
_this4._resetLogoutTimer(); | ||
_this4._inNetworkResetLogoutTimer(); | ||
}); | ||
this.listenTo(this.webex, 'meeting ended', function () { | ||
_this4.isInMeeting = false; | ||
_this4._resetLogoutTimer(); | ||
_this4._inNetworkResetLogoutTimer(); | ||
}); | ||
}, | ||
@@ -415,6 +441,6 @@ | ||
/** | ||
* Don't log the features object | ||
* @param {number} depth | ||
* @returns {Object} | ||
*/ | ||
* Don't log the features object | ||
* @param {number} depth | ||
* @returns {Object} | ||
*/ | ||
inspect: function inspect(depth) { | ||
@@ -428,2 +454,23 @@ return _util2.default.inspect((0, _omit3.default)(this.serialize(), 'features'), { depth: depth }); | ||
}, | ||
/** | ||
* Meeting started and Meeting Ended | ||
* These are device.internal functions that can be accessible from web-client | ||
* These are used to trigger the events for meeting start/end from within web client. | ||
* @returns {boolean} | ||
*/ | ||
meetingStarted: function meetingStarted() { | ||
this.webex.trigger('meeting started'); | ||
}, | ||
/** | ||
* Meeting started and Meeting Ended | ||
* These are device.internal functions that can be accessible from web-client | ||
* These are used to trigger the events for meeting start/end from within web client. | ||
* @returns {boolean} | ||
*/ | ||
meetingEnded: function meetingEnded() { | ||
this.webex.trigger('meeting ended'); | ||
}, | ||
isPreDiscoveryServiceUrl: function isPreDiscoveryServiceUrl(uri) { | ||
@@ -720,28 +767,70 @@ if (!uri) { | ||
this.unset('logoutTimer'); | ||
if (this.config.enableInactivityEnforcement && this.intranetInactivityCheckUrl && this.intranetInactivityDuration) { | ||
this.on('change:lastUserActivityDate', function () { | ||
return _this11._resetLogoutTimer(); | ||
}); | ||
var timer = (0, _commonTimers.safeSetTimeout)(function () { | ||
_this11.webex.request({ | ||
headers: { | ||
'cisco-no-http-redirect': null, | ||
'spark-user-agent': null, | ||
trackingid: null | ||
}, | ||
method: 'GET', | ||
uri: _this11.intranetInactivityCheckUrl | ||
}).catch(function () { | ||
_this11.logger.info('device: did not reach internal ping endpoint; logging out after inactivity on a public network'); | ||
/** | ||
* _resetLogoutTimer | ||
* Initially clears the timer and removes the onChange event listener for lastUserActivityDate and unsets the timer | ||
* Checks if the client is not in meeting | ||
* Checks for the inactivityEnforcement, intranetInactivityCheckUrl, intranetDuration, also if intranetDuration isn't | ||
* -1 which is the value set for duration option None/default value for the duration. | ||
* It also checks if the url was reachable once then sets the isInNetwork to true there by preventing the reset timer | ||
* from being called each time meeting events resets the timer. | ||
*/ | ||
if (!this.isInMeeting) { | ||
if (this.config.enableInactivityEnforcement && this.intranetInactivityCheckUrl && this.intranetInactivityDuration && !this.isInNetwork && this.intranetInactivityDuration !== -1) { | ||
this.on('change:lastUserActivityDate', function () { | ||
_this11._resetLogoutTimer(); | ||
}); | ||
var timer = (0, _commonTimers.safeSetTimeout)(function () { | ||
_this11.webex.request({ | ||
headers: { | ||
'cisco-no-http-redirect': null, | ||
'spark-user-agent': null, | ||
trackingid: null | ||
}, | ||
method: 'GET', | ||
uri: _this11.intranetInactivityCheckUrl | ||
}).then(function () { | ||
_this11.isInNetwork = true; | ||
}).catch(function () { | ||
_this11.logger.info('device: did not reach internal ping endpoint; logging out after inactivity on a public network'); | ||
return _this11.webex.logout(); | ||
}).catch(function (reason) { | ||
_this11.logger.warn('device: logout failed', reason); | ||
return _this11.webex.logout(); | ||
}).catch(function (reason) { | ||
_this11.logger.warn('device: logout failed', reason); | ||
}); | ||
}, this.intranetInactivityDuration * 1000); | ||
this.logoutTimer = timer; | ||
} | ||
} | ||
}, | ||
_inNetworkResetLogoutTimer: function _inNetworkResetLogoutTimer() { | ||
var _this12 = this; | ||
clearTimeout(this.inNetworkLogoutTimer); | ||
this.off('change:lastInNetworkUserActivityDate'); // removes previous event listener | ||
this.unset('inNetworkLogoutTimer'); | ||
/** | ||
* _inNetworkResetLogoutTimer | ||
* Initially clears the timer and removes the onChange event listener for lastInNetworkUserActivityDate and unsets the timer | ||
* Checks if the client is not in meeting | ||
* Checks for the inactivityEnforcement, intranetInactivityCheckUrl, inNetworkInactivityDuration, also if | ||
* inNetworkInactivityDuration isn't -1 which is the value set for duration option None/default value for the duration. | ||
* It logs the user out on successful/unsuccessful ping of the url. This action is with the following point in mind, | ||
* In-Network Duration is expected to be greater than the Off-Network so if the url turns out to be un-reachable its | ||
* saft to log the user out. | ||
*/ | ||
if (!this.isInMeeting) { | ||
if (this.config.enableInactivityEnforcement && this.inNetworkInactivityDuration && this.inNetworkInactivityDuration !== -1) { | ||
this.on('change:lastInNetworkUserActivityDate', function () { | ||
_this12._inNetworkResetLogoutTimer(); | ||
}); | ||
}, this.intranetInactivityDuration * 1000); | ||
var inNetworkTimer = (0, _commonTimers.safeSetTimeout)(function () { | ||
_this12.webex.logout(); | ||
}, this.inNetworkInactivityDuration * 1000); | ||
this.logoutTimer = timer; | ||
this.inNetworkLogoutTimer = inNetworkTimer; | ||
} | ||
} | ||
}, | ||
version: '1.61.3' | ||
version: '1.62.0' | ||
}, (_applyDecoratedDescriptor(_obj, 'determineService', [_dec], (0, _getOwnPropertyDescriptor2.default)(_obj, 'determineService'), _obj), _applyDecoratedDescriptor(_obj, 'getServiceUrl', [_dec2], (0, _getOwnPropertyDescriptor2.default)(_obj, 'getServiceUrl'), _obj), _applyDecoratedDescriptor(_obj, 'initialize', [_dec3], (0, _getOwnPropertyDescriptor2.default)(_obj, 'initialize'), _obj), _applyDecoratedDescriptor(_obj, 'isService', [_dec4], (0, _getOwnPropertyDescriptor2.default)(_obj, 'isService'), _obj), _applyDecoratedDescriptor(_obj, 'isServiceUrl', [_dec5], (0, _getOwnPropertyDescriptor2.default)(_obj, 'isServiceUrl'), _obj), _applyDecoratedDescriptor(_obj, 'isSpecificService', [_dec6], (0, _getOwnPropertyDescriptor2.default)(_obj, 'isSpecificService'), _obj), _applyDecoratedDescriptor(_obj, 'refresh', [_common.oneFlight, _dec7], (0, _getOwnPropertyDescriptor2.default)(_obj, 'refresh'), _obj), _applyDecoratedDescriptor(_obj, 'register', [_common.oneFlight, _dec8], (0, _getOwnPropertyDescriptor2.default)(_obj, 'register'), _obj), _applyDecoratedDescriptor(_obj, 'unregister', [_common.oneFlight, _dec9], (0, _getOwnPropertyDescriptor2.default)(_obj, 'unregister'), _obj)), _obj))); | ||
@@ -748,0 +837,0 @@ |
{ | ||
"name": "@webex/internal-plugin-wdm", | ||
"version": "1.61.3", | ||
"version": "1.62.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -55,2 +55,3 @@ /*! | ||
intranetInactivityCheckUrl: 'string', | ||
inNetworkInactivityDuration: 'number', // Newly added duration for internal network inactivity | ||
/** | ||
@@ -143,3 +144,7 @@ * Is ECM (external content management) enabled for the whole org | ||
logoutTimer: 'any', | ||
lastUserActivityDate: 'number' | ||
inNetworkLogoutTimer: 'any', // Second logout timer when client is connected to org's internal network | ||
lastUserActivityDate: 'number', | ||
lastInNetworkUserActivityDate: 'number', // Update last user activity date to reset inNetworkInactivityTimer | ||
isInMeeting: 'boolean', // Boolean for checking user is in meeting to prevent in advertent timeout due to inactivity | ||
isInNetwork: 'boolean' // Boolean to ensure _resetLogoutTimer isn't called repeatedly once its known client is connected to org's internal network | ||
}, | ||
@@ -165,3 +170,3 @@ | ||
if (url.startsWith(serviceUrl)) { | ||
// "ServiceUrl" is 10 characters | ||
// "ServiceUrl" is 10 characters | ||
return Promise.resolve(key.substr(0, key.length - 10)); | ||
@@ -175,3 +180,3 @@ } | ||
@waitForValue('@') | ||
@waitForValue('@') | ||
getServiceUrl(service) { | ||
@@ -190,4 +195,4 @@ const feature = this.features.developer.get('web-high-availability'); | ||
getPreDiscoveryServiceUrl(service) { | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
return Promise.resolve(this._getServiceUrl(this.config.preDiscoveryServices, service)); | ||
@@ -224,4 +229,4 @@ }, | ||
}) | ||
// it's likely we fail here because we've cycled though all hosts, | ||
// reset all hosts and then retry connecting | ||
// it's likely we fail here because we've cycled though all hosts, | ||
// reset all hosts and then retry connecting | ||
.catch(() => this._resetAllAndRetry(url)); | ||
@@ -242,4 +247,4 @@ }, | ||
fetchNewUrls(url) { | ||
// we want to get the current service first, just in case the | ||
// refreshed catalog has different host names | ||
// we want to get the current service first, just in case the | ||
// refreshed catalog has different host names | ||
return new Promise((resolve) => this.serviceCatalog.inferServiceFromUrl(url) | ||
@@ -253,3 +258,3 @@ .then((s) => { | ||
@persist('@', decider) | ||
@persist('@', decider) | ||
initialize(...args) { | ||
@@ -266,14 +271,35 @@ Reflect.apply(WebexPlugin.prototype.initialize, this, args); | ||
this.isInNetwork = false; | ||
this.on('change:serviceHostMap', this._updateServiceCatalog); | ||
this.listenToAndRun(this, 'change:intranetInactivityCheckUrl', () => this._resetLogoutTimer()); | ||
this.listenToAndRun(this, 'change:intranetInactivityDuration', () => this._resetLogoutTimer()); | ||
this.listenTo(this.webex, 'user-activity', () => { this.lastUserActivityDate = Date.now(); }); | ||
this.listenToAndRun(this, 'change:intranetInactivityCheckUrl', () => { this._resetLogoutTimer(); this._inNetworkResetLogoutTimer(); }); | ||
this.listenToAndRun(this, 'change:intranetInactivityDuration', () => { this._resetLogoutTimer(); this._inNetworkResetLogoutTimer(); }); | ||
this.listenToAndRun(this, 'change:inNetworkInactivityDuration', () => { this._resetLogoutTimer(); this._inNetworkResetLogoutTimer(); }); | ||
this.listenTo(this.webex, 'user-activity', () => { | ||
this.lastUserActivityDate = Date.now(); | ||
this.lastInNetworkUserActivityDate = Date.now(); | ||
}); | ||
/** | ||
* Meeting started and ended event listenrs | ||
* When client enters into the meeting set isInMeeting to true | ||
* This tells also triggers both the timers inturn un-setting the timers until meeting ends | ||
* On meeting end/clean-up the timers are reset. | ||
*/ | ||
this.listenTo(this.webex, 'meeting started', () => { | ||
this.isInMeeting = true; | ||
this._resetLogoutTimer(); | ||
this._inNetworkResetLogoutTimer(); | ||
}); | ||
this.listenTo(this.webex, 'meeting ended', () => { | ||
this.isInMeeting = false; | ||
this._resetLogoutTimer(); | ||
this._inNetworkResetLogoutTimer(); | ||
}); | ||
}, | ||
/** | ||
* Don't log the features object | ||
* @param {number} depth | ||
* @returns {Object} | ||
*/ | ||
* Don't log the features object | ||
* @param {number} depth | ||
* @returns {Object} | ||
*/ | ||
inspect(depth) { | ||
@@ -284,7 +310,26 @@ return util.inspect(omit(this.serialize(), 'features'), {depth}); | ||
isPreDiscoveryService(service) { | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
return Promise.resolve(this._isService(this.config.preDiscoveryServices, service)); | ||
}, | ||
/** | ||
* Meeting started and Meeting Ended | ||
* These are device.internal functions that can be accessible from web-client | ||
* These are used to trigger the events for meeting start/end from within web client. | ||
* @returns {boolean} | ||
*/ | ||
meetingStarted() { | ||
this.webex.trigger('meeting started'); | ||
}, | ||
/** | ||
* Meeting started and Meeting Ended | ||
* These are device.internal functions that can be accessible from web-client | ||
* These are used to trigger the events for meeting start/end from within web client. | ||
* @returns {boolean} | ||
*/ | ||
meetingEnded() { | ||
this.webex.trigger('meeting ended'); | ||
}, | ||
isPreDiscoveryServiceUrl(uri) { | ||
@@ -300,3 +345,3 @@ if (!uri) { | ||
@waitForValue('@') | ||
@waitForValue('@') | ||
isService(service) { | ||
@@ -317,6 +362,6 @@ if (service === 'idbroker') { | ||
@waitForValue('@') | ||
@waitForValue('@') | ||
isServiceUrl(uri) { | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
// The Promise.resolve here is temporary. A future PR will make the | ||
// corresponding _ method async to allow for lazy device registration | ||
if (!uri) { | ||
@@ -329,3 +374,3 @@ return Promise.reject(new Error('`uri` is a required parameter')); | ||
if (this._isServiceUrl(this.serviceHostMap.serviceLinks, uri) || | ||
this._isServiceUrlFromCatalog(this.serviceHostMap.hostCatalog, uri)) { | ||
this._isServiceUrlFromCatalog(this.serviceHostMap.hostCatalog, uri)) { | ||
return Promise.resolve(true); | ||
@@ -340,3 +385,3 @@ } | ||
@waitForValue('@') | ||
@waitForValue('@') | ||
isSpecificService(service, key) { | ||
@@ -352,3 +397,3 @@ if (key === service) { | ||
_getServiceUrl(target, service) { | ||
/* istanbul ignore if */ | ||
/* istanbul ignore if */ | ||
if (!service) { | ||
@@ -407,3 +452,3 @@ return Promise.reject(new Error('`service` is a required parameter')); | ||
if (hostName && !hostName.includes('idbroker') && | ||
find(hostCatalog, (service) => find(service, (availableHost) => availableHost.host === hostName))) { | ||
find(hostCatalog, (service) => find(service, (availableHost) => availableHost.host === hostName))) { | ||
return true; | ||
@@ -415,4 +460,4 @@ } | ||
@oneFlight | ||
@waitForValue('@') | ||
@oneFlight | ||
@waitForValue('@') | ||
refresh() { | ||
@@ -441,4 +486,4 @@ this.logger.info('device: refreshing'); | ||
if (reason.statusCode === 404) { | ||
// If we get a 404, it means the device is no longer valid and we need | ||
// to register a new one. | ||
// If we get a 404, it means the device is no longer valid and we need | ||
// to register a new one. | ||
this.logger.info('device: refresh failed with 404, attempting to register new device'); | ||
@@ -454,6 +499,6 @@ this.clear(); | ||
@oneFlight | ||
@waitForValue('@') | ||
@oneFlight | ||
@waitForValue('@') | ||
register() { | ||
/* eslint no-invalid-this: [0] */ | ||
/* eslint no-invalid-this: [0] */ | ||
this.logger.info('device: registering'); | ||
@@ -482,4 +527,4 @@ | ||
@oneFlight | ||
@waitForValue('@') | ||
@oneFlight | ||
@waitForValue('@') | ||
unregister() { | ||
@@ -522,4 +567,4 @@ this.logger.info('device: unregistering'); | ||
if (newRegistration.serviceHostMap && | ||
newRegistration.serviceHostMap.serviceLinks && | ||
newRegistration.serviceHostMap.hostCatalog) { | ||
newRegistration.serviceHostMap.serviceLinks && | ||
newRegistration.serviceHostMap.hostCatalog) { | ||
Object.keys(newRegistration.serviceHostMap.serviceLinks).forEach((key) => { | ||
@@ -538,3 +583,3 @@ const hostName = Url.parse(newRegistration.serviceHostMap.serviceLinks[key]).hostname; | ||
else { | ||
// if user has old device in localStorage, refresh device | ||
// if user has old device in localStorage, refresh device | ||
this.refresh(); | ||
@@ -549,26 +594,68 @@ } | ||
this.unset('logoutTimer'); | ||
if (this.config.enableInactivityEnforcement && this.intranetInactivityCheckUrl && this.intranetInactivityDuration) { | ||
this.on('change:lastUserActivityDate', () => this._resetLogoutTimer()); | ||
const timer = safeSetTimeout(() => { | ||
this.webex.request({ | ||
headers: { | ||
'cisco-no-http-redirect': null, | ||
'spark-user-agent': null, | ||
trackingid: null | ||
}, | ||
method: 'GET', | ||
uri: this.intranetInactivityCheckUrl | ||
}) | ||
.catch(() => { | ||
this.logger.info('device: did not reach internal ping endpoint; logging out after inactivity on a public network'); | ||
return this.webex.logout(); | ||
/** | ||
* _resetLogoutTimer | ||
* Initially clears the timer and removes the onChange event listener for lastUserActivityDate and unsets the timer | ||
* Checks if the client is not in meeting | ||
* Checks for the inactivityEnforcement, intranetInactivityCheckUrl, intranetDuration, also if intranetDuration isn't | ||
* -1 which is the value set for duration option None/default value for the duration. | ||
* It also checks if the url was reachable once then sets the isInNetwork to true there by preventing the reset timer | ||
* from being called each time meeting events resets the timer. | ||
*/ | ||
if (!this.isInMeeting) { | ||
if (this.config.enableInactivityEnforcement && this.intranetInactivityCheckUrl && | ||
this.intranetInactivityDuration && !this.isInNetwork && this.intranetInactivityDuration !== -1) { | ||
this.on('change:lastUserActivityDate', () => { this._resetLogoutTimer(); }); | ||
const timer = safeSetTimeout(() => { | ||
this.webex.request({ | ||
headers: { | ||
'cisco-no-http-redirect': null, | ||
'spark-user-agent': null, | ||
trackingid: null | ||
}, | ||
method: 'GET', | ||
uri: this.intranetInactivityCheckUrl | ||
}) | ||
.catch((reason) => { | ||
this.logger.warn('device: logout failed', reason); | ||
}); | ||
}, this.intranetInactivityDuration * 1000); | ||
.then(() => { | ||
this.isInNetwork = true; | ||
}) | ||
.catch(() => { | ||
this.logger.info('device: did not reach internal ping endpoint; logging out after inactivity on a public network'); | ||
this.logoutTimer = timer; | ||
return this.webex.logout(); | ||
}) | ||
.catch((reason) => { | ||
this.logger.warn('device: logout failed', reason); | ||
}); | ||
}, this.intranetInactivityDuration * 1000); | ||
this.logoutTimer = timer; | ||
} | ||
} | ||
}, | ||
_inNetworkResetLogoutTimer() { | ||
clearTimeout(this.inNetworkLogoutTimer); | ||
this.off('change:lastInNetworkUserActivityDate'); // removes previous event listener | ||
this.unset('inNetworkLogoutTimer'); | ||
/** | ||
* _inNetworkResetLogoutTimer | ||
* Initially clears the timer and removes the onChange event listener for lastInNetworkUserActivityDate and unsets the timer | ||
* Checks if the client is not in meeting | ||
* Checks for the inactivityEnforcement, intranetInactivityCheckUrl, inNetworkInactivityDuration, also if | ||
* inNetworkInactivityDuration isn't -1 which is the value set for duration option None/default value for the duration. | ||
* It logs the user out on successful/unsuccessful ping of the url. This action is with the following point in mind, | ||
* In-Network Duration is expected to be greater than the Off-Network so if the url turns out to be un-reachable its | ||
* saft to log the user out. | ||
*/ | ||
if (!this.isInMeeting) { | ||
if (this.config.enableInactivityEnforcement && | ||
this.inNetworkInactivityDuration && this.inNetworkInactivityDuration !== -1) { | ||
this.on('change:lastInNetworkUserActivityDate', () => { this._inNetworkResetLogoutTimer(); }); | ||
const inNetworkTimer = safeSetTimeout(() => { | ||
this.webex.logout(); | ||
}, this.inNetworkInactivityDuration * 1000); | ||
this.inNetworkLogoutTimer = inNetworkTimer; | ||
} | ||
} | ||
} | ||
@@ -575,0 +662,0 @@ }); |
@@ -24,3 +24,5 @@ /*! | ||
device: { | ||
enableInactivityEnforcement: true | ||
enableInactivityEnforcement: true, | ||
isInMeeting: false, | ||
isInNetwork: false | ||
} | ||
@@ -48,11 +50,17 @@ } | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.intranetInactivityCheckUrl = 'http://ping.example.com/ping'; | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.intranetInactivityDuration = 2; | ||
webex.internal.device.inNetworkInactivityDuration = 2; | ||
assert.isDefined(webex.internal.device.logoutTimer); | ||
assert.isDefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.unset('intranetInactivityCheckUrl'); | ||
webex.internal.device.unset('inNetworkLogoutTimer'); | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
}); | ||
@@ -66,14 +74,20 @@ }); | ||
intranetInactivityDuration: 8 * 60 * 60, | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping' | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping', | ||
inNetworkInactivityDuration: 8 * 60 * 60 | ||
}); | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.intranetInactivityCheckUrl = 'http://ping.example.com/ping'; | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.intranetInactivityDuration = 2; | ||
webex.internal.device.inNetworkInactivityDuration = 2; | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
webex.internal.device.unset('intranetInactivityCheckUrl'); | ||
assert.isUndefined(webex.internal.device.logoutTimer); | ||
assert.isUndefined(webex.internal.device.inNetworkLogoutTimer); | ||
}); | ||
@@ -83,3 +97,4 @@ }); | ||
describe('when the policy configuration is specified', () => { | ||
it('logs the user out according to the policy configuration', () => { | ||
// Off Networ Inactivity Timer | ||
it('logs the user out according to the policy configuration when ping url can\'t be reached', () => { | ||
webex.request.returns(Promise.reject()); | ||
@@ -89,3 +104,5 @@ | ||
intranetInactivityDuration: 8 * 60 * 60, | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping' | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping', | ||
isInMeeting: false, | ||
isInNetwork: false | ||
}); | ||
@@ -107,5 +124,17 @@ assert.isDefined(webex.internal.device.logoutTimer); | ||
return Promise.resolve() | ||
.then(() => assert.calledOnce(webex.logout)); | ||
.catch(() => assert.calledOnce(webex.logout)); | ||
}); | ||
// In Network Inactivity Timer | ||
it('logs the user out according to the policy configuration when ping url can\'t be reached even when in network', () => { | ||
webex.internal.device.set({ | ||
inNetworkInactivityDuration: 8 * 60 * 60, | ||
isInMeeting: false | ||
}); | ||
assert.isDefined(webex.internal.device.inNetworkLogoutTimer); | ||
clock.tick(8 * 60 * 60 * 1000); | ||
assert.calledOnce(webex.logout); | ||
}); | ||
describe('when the ping url can be reached', () => { | ||
@@ -119,3 +148,5 @@ it('resets the logout timer', () => { | ||
intranetInactivityDuration: 8 * 60 * 60, | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping' | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping', | ||
isInMeeting: false, | ||
isInNetwork: false | ||
}); | ||
@@ -137,4 +168,19 @@ assert.isDefined(webex.internal.device.logoutTimer); | ||
return Promise.resolve() | ||
.then(() => assert.notCalled(webex.logout)); | ||
.then(() => { | ||
assert.notCalled(webex.logout); | ||
assert.isTrue(webex.internal.device.isInNetwork); | ||
}); | ||
}); | ||
// In Network Timer | ||
it('logs the user out', () => { | ||
webex.internal.device.set({ | ||
inNetworkInactivityDuration: 8 * 60 * 60, | ||
isInMeeting: false, | ||
isInNetwork: false | ||
}); | ||
assert.isDefined(webex.internal.device.inNetworkLogoutTimer); | ||
clock.tick(8 * 60 * 60 * 1000); | ||
assert.calledOnce(webex.logout); | ||
}); | ||
}); | ||
@@ -170,9 +216,28 @@ | ||
return Promise.resolve() | ||
.then(() => assert.notCalled(webex.logout)); | ||
.catch(() => assert.notCalled(webex.logout)); | ||
}); | ||
// In Network Timer | ||
it('resets the in network logout timer', () => { | ||
webex.internal.device.set({ | ||
inNetworkInactivityDuration: 8 * 60 * 60, | ||
isInMeeting: false | ||
}); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
webex.emit('user-activity'); | ||
clock.tick(7 * 60 * 60 * 1000); | ||
assert.notCalled(webex.logout); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
assert.calledOnce(webex.logout); | ||
}); | ||
it('does not call _resetLogoutTimer in arithmetic progression with every post', () => { | ||
webex.internal.device.set({ | ||
intranetInactivityDuration: 8 * 60 * 60, | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping' | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping', | ||
isInMeeting: false, | ||
isInNetwork: false | ||
}); | ||
@@ -202,2 +267,33 @@ | ||
}); | ||
it('does not call _inNetworkResetLogoutTimer in arithmetic progression with every post', () => { | ||
webex.internal.device.set({ | ||
inNetworkInactivityDuration: 8 * 60 * 60, | ||
intranetInactivityCheckUrl: 'http://ping.example.com/ping', | ||
isInMeeting: false, | ||
isInNetwork: false | ||
}); | ||
const inNetworkResetLogoutTimerSpy = sinon.spy(webex.internal.device, '_inNetworkResetLogoutTimer'); | ||
webex.emit('user-activity'); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
assert.equal(inNetworkResetLogoutTimerSpy.callCount, 1); | ||
inNetworkResetLogoutTimerSpy.reset(); | ||
webex.emit('user-activity'); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
assert.equal(inNetworkResetLogoutTimerSpy.callCount, 1); | ||
inNetworkResetLogoutTimerSpy.reset(); | ||
webex.emit('user-activity'); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
assert.equal(inNetworkResetLogoutTimerSpy.callCount, 1); | ||
inNetworkResetLogoutTimerSpy.reset(); | ||
webex.emit('user-activity'); | ||
clock.tick(1 * 60 * 60 * 1000); | ||
assert.equal(inNetworkResetLogoutTimerSpy.callCount, 1); | ||
inNetworkResetLogoutTimerSpy.reset(); | ||
}); | ||
}); | ||
@@ -204,0 +300,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245235
4496