annotate client/tests/unit/session/session.spec.js @ 3540:b268cae2df39

merge with branch password
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 31 May 2019 09:34:31 +0200
parents 0c5cbbafbd94
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1364
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
2 * without warranty, see README.md and license for details.
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
3 *
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
4 * SPDX-License-Identifier: AGPL-3.0-or-later
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
5 * License-Filename: LICENSES/AGPL-3.0.txt
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
6 *
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
7 * Copyright (C) 2018 by via donau
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
9 * Software engineering by Intevation GmbH
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
10 *
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
11 * Author(s):
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
12 * Thomas Junk <thomas.junk@intevation.de>
0c5cbbafbd94 add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents: 660
diff changeset
13 */
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
14 import {
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
15 sessionStillActive,
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
16 toMillisFromString
660
79db27e3a999 geo function added
Thomas Junk <thomas.junk@intevation.de>
parents: 165
diff changeset
17 } from "../../../src/application/lib/session";
162
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
19 test("No session counts as expired session", () => {
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
20 expect(sessionStillActive(null)).toBe(false);
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
21 });
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
22
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
23 test("Session expired", () => {
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
24 const expired = Date.now() - 60000;
162
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
25 expect(sessionStillActive(expired)).toBe(false);
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
26 });
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
27
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
28 test("Session alive", () => {
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
29 const active = Date.now() + 60000;
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
30 expect(sessionStillActive(active)).toBe(true);
9908260d1e6a Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
31 });
163
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
32
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
33 test("Session alive with string", () => {
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
34 const active = "" + Date.now() / 1000 + 60000;
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
35 expect(sessionStillActive(toMillisFromString(active))).toBe(true);
163
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
36 });
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
37
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
38 test("Session expired with string", () => {
165
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
39 const expired = "" + Date.now() / 1000 - 60000;
4bf2173748f3 refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents: 164
diff changeset
40 expect(sessionStillActive(toMillisFromString(expired))).toBe(false);
163
30c212a6f580 fix: Bugfix for session evaluation
Thomas Junk <thomas.junk@intevation.de>
parents: 162
diff changeset
41 });