mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-23 22:39:33 -05:00
adding js test to generate v2 example pastes to be used in the development of the server side logic, adding one of these into the helper class of the php tests
This commit is contained in:
parent
eeca365e18
commit
5652a43d1d
@ -3736,6 +3736,17 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* return currently set data, used in unit testing
|
||||
*
|
||||
* @name ServerInteraction.getData
|
||||
* @function
|
||||
*/
|
||||
me.getData = function()
|
||||
{
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
* set success function
|
||||
*
|
||||
|
40
js/test/ServerInteraction.js
Normal file
40
js/test/ServerInteraction.js
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
describe('ServerInteraction', function () {
|
||||
describe('prepare', function () {
|
||||
afterEach(async function () {
|
||||
// pause to let async functions conclude
|
||||
await new Promise(resolve => setTimeout(resolve, 1900));
|
||||
});
|
||||
this.timeout(30000);
|
||||
it('can prepare an encrypted paste', function () {
|
||||
jsc.check(jsc.forall(
|
||||
'string',
|
||||
'string',
|
||||
'string',
|
||||
async function (key, password, message) {
|
||||
// pause to let async functions conclude
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
let clean = jsdom();
|
||||
window.crypto = new WebCrypto();
|
||||
message = message.trim();
|
||||
|
||||
$.PrivateBin.ServerInteraction.prepare();
|
||||
$.PrivateBin.ServerInteraction.setCryptParameters(password, key);
|
||||
$.PrivateBin.ServerInteraction.setUnencryptedData('adata', [
|
||||
// encryption parameters defined by CryptTool, format, discussion, burn after reading
|
||||
null, 'plaintext', 0, 0
|
||||
]);
|
||||
$.PrivateBin.ServerInteraction.setUnencryptedData('meta', {'expire': '5min'});
|
||||
await $.PrivateBin.ServerInteraction.setCipherMessage({'paste': message});
|
||||
//console.log($.PrivateBin.ServerInteraction.getData());
|
||||
clean();
|
||||
// TODO currently not testing anything and just used to generate v2 pastes for starting development of server side v2 implementation
|
||||
return true;
|
||||
}
|
||||
),
|
||||
{tests: 3});
|
||||
});
|
||||
});
|
||||
});
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-qHTvFreACpXmDG5WUwZdsbV9ZcnMqfi+OCgmPRY7TjZVuaS9GqpvhH+EiTZh5rGUPvHr/jPCa1X9LHwgVlKi/g==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-fTiFZAR0zCUF7FKtJSM4f424f/79EYC6r4Rt2tgNDvJGTMpL079J1KRSBZjVqhq2ePRHkLnBlzTRlzIO1LhoYw==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-qHTvFreACpXmDG5WUwZdsbV9ZcnMqfi+OCgmPRY7TjZVuaS9GqpvhH+EiTZh5rGUPvHr/jPCa1X9LHwgVlKi/g==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-fTiFZAR0zCUF7FKtJSM4f424f/79EYC6r4Rt2tgNDvJGTMpL079J1KRSBZjVqhq2ePRHkLnBlzTRlzIO1LhoYw==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
@ -31,11 +31,11 @@ class Helper
|
||||
private static $pasteid = '5e9bc25c89fb3bf9';
|
||||
|
||||
/**
|
||||
* example paste
|
||||
* example paste version 1
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $paste = array(
|
||||
private static $pasteV1 = array(
|
||||
'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}',
|
||||
'attachment' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}',
|
||||
'attachmentname' => '{"iv":"76MkAtOGC4oFogX/aSMxRA","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"b6Ae/U1xJdsX/+lATud4sQ"}',
|
||||
@ -46,6 +46,32 @@ class Helper
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* example paste version 2
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $pasteV2 = array(
|
||||
'adata' => array(
|
||||
array(
|
||||
'gMSNoLOk4z0RnmsYwXZ8mw==',
|
||||
'TZO+JWuIuxs=',
|
||||
100000,
|
||||
256,
|
||||
128,
|
||||
'aes',
|
||||
'gcm',
|
||||
'zlib'
|
||||
),
|
||||
'plaintext',
|
||||
0,
|
||||
0
|
||||
),
|
||||
'meta' => array( 'expire' => '5min' ),
|
||||
'v' => 2,
|
||||
'ct' => 'ME5JF/YBEijp2uYMzLZozbKtWc5wfy6R59NBb7SmRig='
|
||||
);
|
||||
|
||||
/**
|
||||
* example ID of a comment
|
||||
*
|
||||
@ -103,7 +129,7 @@ class Helper
|
||||
*/
|
||||
public static function getPasteWithAttachment($meta = array())
|
||||
{
|
||||
$example = self::$paste;
|
||||
$example = self::$pasteV1;
|
||||
$example['meta']['salt'] = ServerSalt::generate();
|
||||
$example['meta'] = array_merge($example['meta'], $meta);
|
||||
return $example;
|
||||
|
Loading…
Reference in New Issue
Block a user