|
|
|
@ -22,6 +22,7 @@ global.sjcl = require('./sjcl-1.0.6');
|
|
|
|
|
global.Base64 = require('./base64-2.1.9').Base64;
|
|
|
|
|
global.RawDeflate = require('./rawdeflate-0.5').RawDeflate;
|
|
|
|
|
global.RawDeflate.inflate = require('./rawinflate-0.3').RawDeflate.inflate;
|
|
|
|
|
require('./bootstrap-3.3.7');
|
|
|
|
|
require('./privatebin');
|
|
|
|
|
|
|
|
|
|
// redirect console messages to log file
|
|
|
|
@ -1264,3 +1265,40 @@ describe('PasteStatus', function () {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
before(function () {
|
|
|
|
|
cleanup();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jsc.property(
|
|
|
|
|
'returns the password fed into the dialog',
|
|
|
|
|
'string',
|
|
|
|
|
function (password) {
|
|
|
|
|
password = password.replace(/\r+/g, '');
|
|
|
|
|
var clean = jsdom('', {url: 'ftp://example.com/#0'});
|
|
|
|
|
$('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>' +
|
|
|
|
|
'</form></div></div></div></div><div id="cipherdata">{}</div>'
|
|
|
|
|
);
|
|
|
|
|
$.PrivateBin.Model.init();
|
|
|
|
|
$.PrivateBin.Prompt.init();
|
|
|
|
|
$.PrivateBin.Prompt.requestPassword();
|
|
|
|
|
$('#passworddecrypt').val(password);
|
|
|
|
|
$('#passwordform').submit();
|
|
|
|
|
var result = $.PrivateBin.Prompt.getPassword();
|
|
|
|
|
clean();
|
|
|
|
|
return result == password;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|