Skip to content

Commit a1f0755

Browse files
committed
capture expiring notification time
1 parent 7771c15 commit a1f0755

2 files changed

Lines changed: 51 additions & 26 deletions

File tree

‎src/UserManagerSettings.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
import Log from './Log';
55
import OidcClientSettings from './OidcClientSettings';
66

7+
const DefaultExpiringNotificationTime = 60;
8+
79
export default class UserManagerSettings extends OidcClientSettings {
810
constructor({
911
popup_redirect_uri,
1012
silent_redirect_uri,
11-
enableAutomaticSilentRenew = true
13+
enableAutomaticSilentRenew = true,
14+
expiringNotificationTime = DefaultExpiringNotificationTime
1215
} = {}) {
1316
super(arguments[0]);
1417

1518
this._popup_redirect_uri = popup_redirect_uri;
1619
this._silent_redirect_uri = silent_redirect_uri;
1720
this._enableAutomaticSilentRenew = !!enableAutomaticSilentRenew;
21+
this._expiringNotificationTime = expiringNotificationTime;
1822
}
1923

2024
get popup_redirect_uri(){
@@ -27,4 +31,8 @@ export default class UserManagerSettings extends OidcClientSettings {
2731
get automaticSilentRenewEnabled() {
2832
return !!(this.silent_redirect_uri && this._enableAutomaticSilentRenew);
2933
}
34+
35+
get expiringNotificationTime(){
36+
return this._expiringNotificationTime;
37+
}
3038
}

‎test/unit/UserManagerSettings.spec.js‎

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,85 @@ import chai from 'chai';
88
chai.should();
99
let assert = chai.assert;
1010

11-
describe("UserManagerSettings", function() {
11+
describe("UserManagerSettings", function () {
1212

13-
beforeEach(function() {
13+
beforeEach(function () {
1414
Log.logger = console;
1515
Log.level = Log.NONE;
1616
});
1717

18-
describe("constructor", function() {
18+
describe("constructor", function () {
1919

20-
it("should allow no settings", function() {
20+
it("should allow no settings", function () {
2121
let subject = new UserManagerSettings();
2222
});
23-
24-
it("should pass settings to base class", function() {
23+
24+
it("should pass settings to base class", function () {
2525
let subject = new UserManagerSettings({ client_id: 'client' });
2626
subject.client_id.should.equal('client');
2727
});
2828

2929
});
3030

31-
describe("popup_redirect_uri", function() {
31+
describe("popup_redirect_uri", function () {
3232

33-
it("should return value from initial settings", function() {
33+
it("should return value from initial settings", function () {
3434
let subject = new UserManagerSettings({ popup_redirect_uri: 'test' });
3535
subject.popup_redirect_uri.should.equal('test');
3636
});
3737

3838
});
39-
40-
describe("silent_redirect_uri", function() {
4139

42-
it("should return value from initial settings", function() {
40+
describe("silent_redirect_uri", function () {
41+
42+
it("should return value from initial settings", function () {
4343
let subject = new UserManagerSettings({ silent_redirect_uri: 'test' });
4444
subject.silent_redirect_uri.should.equal('test');
4545
});
4646

4747
});
48-
49-
describe("automaticSilentRenewEnabled", function() {
5048

51-
it("should return value from initial settings", function() {
52-
let subject = new UserManagerSettings({
53-
silent_redirect_uri: 'test',
54-
enableAutomaticSilentRenew: false
49+
describe("automaticSilentRenewEnabled", function () {
50+
51+
it("should return value from initial settings", function () {
52+
let subject = new UserManagerSettings({
53+
silent_redirect_uri: 'test',
54+
enableAutomaticSilentRenew: false
5555
});
5656
subject.automaticSilentRenewEnabled.should.be.false;
5757
});
58-
59-
it("should use default value", function() {
60-
let subject = new UserManagerSettings({
61-
silent_redirect_uri: 'test'
58+
59+
it("should use default value", function () {
60+
let subject = new UserManagerSettings({
61+
silent_redirect_uri: 'test'
6262
});
6363
subject.automaticSilentRenewEnabled.should.be.true;
6464
});
65-
66-
it("should be false if no silent redirect uri", function() {
67-
let subject = new UserManagerSettings({
68-
enableAutomaticSilentRenew: true
65+
66+
it("should be false if no silent redirect uri", function () {
67+
let subject = new UserManagerSettings({
68+
enableAutomaticSilentRenew: true
6969
});
7070
subject.automaticSilentRenewEnabled.should.be.false;
7171
});
7272

7373
});
7474

75+
describe("expiringNotificationTime", function () {
76+
77+
it("should return value from initial settings", function () {
78+
let subject = new UserManagerSettings({
79+
expiringNotificationTime: 10
80+
});
81+
subject.expiringNotificationTime.should.equal(10);
82+
});
83+
84+
it("should use default value", function () {
85+
let subject = new UserManagerSettings({
86+
});
87+
subject.expiringNotificationTime.should.equal(60);
88+
});
89+
90+
});
91+
7592
});

0 commit comments

Comments
 (0)