aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-10 16:42:25 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-10 16:42:25 +0100
commit9c22e99331fe7261c575bc26e2381d78c189521d (patch)
tree3211c033ac70d65d04cb1c0c9279b7790768d1dc /core/js
parentb246ca96ffe45bfad8fbcc744be6d2e158228987 (diff)
downloadnextcloud-server-9c22e99331fe7261c575bc26e2381d78c189521d.tar.gz
nextcloud-server-9c22e99331fe7261c575bc26e2381d78c189521d.zip
Add extra test cases for password confirmation
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/tests/specs/coreSpec.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index b27294b0f32..616e7509f7c 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -1552,7 +1552,7 @@ describe('Core base tests', function() {
stubJsPageLoadTime.restore();
});
- it('should not show the password confirmation dialog', function () {
+ it('should not show the password confirmation dialog when server time is earlier than local time', function () {
// add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000);
window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000);
@@ -1564,7 +1564,7 @@ describe('Core base tests', function() {
expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy();
});
- it('should show the password confirmation dialog', function () {
+ it('should show the password confirmation dialog when server time is earlier than local time', function () {
// add server variables
window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000);
window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000);
@@ -1575,5 +1575,29 @@ describe('Core base tests', function() {
expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy();
});
+
+ it('should not show the password confirmation dialog when server time is later than local time', function () {
+ // add server variables
+ window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000);
+ window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 0, 0).getTime() / 1000);
+ window.backendAllowsPasswordConfirmation = true;
+
+ stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime());
+ stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 20, 0).getTime());
+
+ expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy();
+ });
+
+ it('should show the password confirmation dialog when server time is later than local time', function () {
+ // add server variables
+ window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000);
+ window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 0, 0).getTime() / 1000);
+ window.backendAllowsPasswordConfirmation = true;
+
+ stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime());
+ stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 31, 0).getTime());
+
+ expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy();
+ });
});
});