adding tests for Prompt class, typos
This commit is contained in:
parent
984941f901
commit
360a0921e2
|
@ -1468,7 +1468,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
throw 'password prompt canceled';
|
throw 'password prompt canceled';
|
||||||
}
|
}
|
||||||
if (password.length === 0) {
|
if (password.length === 0) {
|
||||||
// recursive…
|
// recurse…
|
||||||
return me.requestPassword();
|
return me.requestPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
38
js/test.js
38
js/test.js
|
@ -22,6 +22,7 @@ global.sjcl = require('./sjcl-1.0.6');
|
||||||
global.Base64 = require('./base64-2.1.9').Base64;
|
global.Base64 = require('./base64-2.1.9').Base64;
|
||||||
global.RawDeflate = require('./rawdeflate-0.5').RawDeflate;
|
global.RawDeflate = require('./rawdeflate-0.5').RawDeflate;
|
||||||
global.RawDeflate.inflate = require('./rawinflate-0.3').RawDeflate.inflate;
|
global.RawDeflate.inflate = require('./rawinflate-0.3').RawDeflate.inflate;
|
||||||
|
require('./bootstrap-3.3.7');
|
||||||
require('./privatebin');
|
require('./privatebin');
|
||||||
|
|
||||||
// redirect console messages to log file
|
// 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;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/foCCYtW+1hgr5bCBVfnt2GxFOVEd6p3e3d3Wn4TLeIQy8WI5w8ywxBhxvqjjpOvDNPKoQlIf9Zi7xmEK9IYUQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rDOydUZZZd8/nPpB9EekhSoXRF1ezh7veCT1ImGX6lH2gupGIboh6O7S3I9r/B21ytB22AsbrTBGjZ4ORvpFSQ==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/foCCYtW+1hgr5bCBVfnt2GxFOVEd6p3e3d3Wn4TLeIQy8WI5w8ywxBhxvqjjpOvDNPKoQlIf9Zi7xmEK9IYUQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rDOydUZZZd8/nPpB9EekhSoXRF1ezh7veCT1ImGX6lH2gupGIboh6O7S3I9r/B21ytB22AsbrTBGjZ4ORvpFSQ==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
Loading…
Reference in New Issue