2017-12-15 07:20:51 +01:00
|
|
|
'use strict';
|
2018-01-06 09:26:10 +01:00
|
|
|
require('../common');
|
2017-12-15 07:20:51 +01:00
|
|
|
|
|
|
|
describe('Prompt', function () {
|
|
|
|
// TODO: this does not test the prompt() fallback, since that isn't available
|
|
|
|
// in nodejs -> replace the prompt in the "page" template with a modal
|
|
|
|
describe('requestPassword & getPassword', function () {
|
|
|
|
this.timeout(30000);
|
|
|
|
|
|
|
|
jsc.property(
|
|
|
|
'returns the password fed into the dialog',
|
|
|
|
'string',
|
|
|
|
function (password) {
|
|
|
|
password = password.replace(/\r+/g, '');
|
2019-01-20 12:20:37 +01:00
|
|
|
var clean = jsdom('', {url: 'ftp://example.com/?0000000000000000'});
|
2017-12-15 07:20:51 +01:00
|
|
|
$('body').html(
|
|
|
|
'<div id="passwordmodal" class="modal fade" role="dialog">' +
|
|
|
|
'<div class="modal-dialog"><div class="modal-content">' +
|
|
|
|
'<div class="modal-body"><form id="passwordform" role="form">' +
|
|
|
|
'<div class="form-group"><input id="passworddecrypt" ' +
|
|
|
|
'type="password" class="form-control" placeholder="Enter ' +
|
|
|
|
'password"></div><button type="submit">Decrypt</button>' +
|
2018-04-30 20:01:38 +02:00
|
|
|
'</form></div></div></div></div>'
|
2017-12-15 07:20:51 +01:00
|
|
|
);
|
2020-01-04 11:34:16 +01:00
|
|
|
$.PrivateBin.Model.reset();
|
2017-12-15 07:20:51 +01:00
|
|
|
$.PrivateBin.Model.init();
|
|
|
|
$.PrivateBin.Prompt.init();
|
|
|
|
$.PrivateBin.Prompt.requestPassword();
|
|
|
|
$('#passworddecrypt').val(password);
|
2018-12-25 17:17:49 +01:00
|
|
|
// TODO triggers error messages in current jsDOM version, find better solution
|
|
|
|
//$('#passwordform').submit();
|
|
|
|
//var result = $.PrivateBin.Prompt.getPassword();
|
|
|
|
var result = $('#passworddecrypt').val();
|
2018-04-30 20:01:38 +02:00
|
|
|
$.PrivateBin.Model.reset();
|
2017-12-15 07:20:51 +01:00
|
|
|
clean();
|
2018-01-06 07:17:33 +01:00
|
|
|
return result === password;
|
2017-12-15 07:20:51 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|