move legacy support to api
This commit is contained in:
parent
cd7737d65b
commit
dec12d81a7
13 changed files with 215 additions and 122 deletions
|
@ -89,6 +89,15 @@ trees.push(
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (app.env === 'development' || app.env === 'test') {
|
||||||
|
trees.push(
|
||||||
|
pickFiles('tests/dummyData', {
|
||||||
|
srcDir: '/',
|
||||||
|
destDir: '/data'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
trees.push(app.toTree());
|
trees.push(app.toTree());
|
||||||
var mergeTrees = require('broccoli-merge-trees');
|
var mergeTrees = require('broccoli-merge-trees');
|
||||||
module.exports = mergeTrees(trees);
|
module.exports = mergeTrees(trees);
|
||||||
|
|
|
@ -185,13 +185,19 @@ class Model {
|
||||||
|
|
||||||
$data = self::convertFromStorage($storageObject);
|
$data = self::convertFromStorage($storageObject);
|
||||||
|
|
||||||
|
if(method_exists($model, 'restoreLegacySupportHook')) {
|
||||||
|
$model->restoreLegacySupportHook($data);
|
||||||
|
}
|
||||||
|
|
||||||
$properties = array_merge(
|
$properties = array_merge(
|
||||||
static::ENCRYPTED_PROPERTIES,
|
static::ENCRYPTED_PROPERTIES,
|
||||||
static::PLAIN_PROPERTIES,
|
static::PLAIN_PROPERTIES,
|
||||||
static::SERVER_PROPERTIES
|
static::SERVER_PROPERTIES
|
||||||
);
|
);
|
||||||
foreach ($properties as $property) {
|
foreach ($properties as $property) {
|
||||||
$model->set($property, $data->$property);
|
if (isset($data->$property)) {
|
||||||
|
$model->set($property, $data->$property);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static::PROOF_KEY_KNOWLEDGE === 'save') {
|
if (static::PROOF_KEY_KNOWLEDGE === 'save') {
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Poll extends model {
|
||||||
protected function getUsers() {
|
protected function getUsers() {
|
||||||
$users = [];
|
$users = [];
|
||||||
|
|
||||||
$userDir = DATA_FOLDER . $this->get('id') . '/users/';
|
$userDir = DATA_FOLDER . $this->get('id') . '/user/';
|
||||||
if (is_dir($userDir)) {
|
if (is_dir($userDir)) {
|
||||||
$dir = opendir($userDir);
|
$dir = opendir($userDir);
|
||||||
while(false !== ($file = readdir($dir))) {
|
while(false !== ($file = readdir($dir))) {
|
||||||
|
@ -129,4 +129,20 @@ class Poll extends model {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function restoreLegacySupportHook(&$data) {
|
||||||
|
if (!isset($data->version) || $data->version === 'v0.3-0') {
|
||||||
|
if (isset($data->poll) && is_object($data->poll)) {
|
||||||
|
$data = $data->poll;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $key => $value) {
|
||||||
|
if (strpos($key, 'encrypted') === 0) {
|
||||||
|
$newKey = lcfirst(substr($key, 9));
|
||||||
|
$data->$newKey = $data->$key;
|
||||||
|
unset($data->$key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class User extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDir() {
|
protected function getDir() {
|
||||||
return $this->getPollDir() . 'users/';
|
return $this->getPollDir() . 'user/';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPollDir() {
|
protected function getPollDir() {
|
||||||
|
@ -74,4 +74,20 @@ class User extends Model {
|
||||||
Poll::isValidId($parts[0]) &&
|
Poll::isValidId($parts[0]) &&
|
||||||
intval($parts[1]) == $parts[1];
|
intval($parts[1]) == $parts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function restoreLegacySupportHook(&$data) {
|
||||||
|
if (!isset($data->version) || $data->version === 'v0.3-0') {
|
||||||
|
if (isset($data->user) && is_object($data->user)) {
|
||||||
|
$data = $data->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $key => $value) {
|
||||||
|
if (strpos($key, 'encrypted') === 0) {
|
||||||
|
$newKey = lcfirst(substr($key, 9));
|
||||||
|
$data->$newKey = $data->$key;
|
||||||
|
unset($data->$key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ $pollJson = '{"anonymousUser":"{\"iv\":\"gVHZSXyMm10Fn+kDooa7uw==\",\"v\":1,\"it
|
||||||
$userJson = '{"user":{"name":"{\"iv\":\"kizIqK7FPNmRuQB7VHsMOw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"UsYMzrww3HKR8vl2TKVE\"}","selections":"{\"iv\":\"hRmiZagEhQVhw2cg6UJNrg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"2zIPGpiSC6wJHRoAMYBFPXx3qmlZg0Z/Jt/15mY+sHPLCqoAn97TKGN6KIvl/5gmgCFqLQFNo6uppCTUhljoV5y2kMtGvm0g3+NdpcejWGOeMACDPcp1mpXII87ZTfC6WrtxcWCB6UGYN8EynOdndFTGp+WVZnXCCya7YPThk/QRwoHoPWS6+TJFT9WeHV4i4kUIg2K3kdz3Op7S/c7l7KbOc8GsyjZzv0bRDnAm68/+FlJyZnvfMfU8vTxExsIsd0pBy4JBV4hg9SlCPectb5BAvBCULLDPA08prf262RUmVKJ+M3P1+5KkBQcnQwnUW/fzAQ7lqA==\"}","creationDate":"{\"iv\":\"xqdDY/A7MHLeAsoU9S/j+A==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"TQOhbjveZbvdiyYpxfwNyu5pi1PLia9FApJJRmr3QoyrWA==\"}","version":"v0.3.0+0ae62f31","poll":"' . $pollId . '"}}';
|
$userJson = '{"user":{"name":"{\"iv\":\"kizIqK7FPNmRuQB7VHsMOw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"UsYMzrww3HKR8vl2TKVE\"}","selections":"{\"iv\":\"hRmiZagEhQVhw2cg6UJNrg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"2zIPGpiSC6wJHRoAMYBFPXx3qmlZg0Z/Jt/15mY+sHPLCqoAn97TKGN6KIvl/5gmgCFqLQFNo6uppCTUhljoV5y2kMtGvm0g3+NdpcejWGOeMACDPcp1mpXII87ZTfC6WrtxcWCB6UGYN8EynOdndFTGp+WVZnXCCya7YPThk/QRwoHoPWS6+TJFT9WeHV4i4kUIg2K3kdz3Op7S/c7l7KbOc8GsyjZzv0bRDnAm68/+FlJyZnvfMfU8vTxExsIsd0pBy4JBV4hg9SlCPectb5BAvBCULLDPA08prf262RUmVKJ+M3P1+5KkBQcnQwnUW/fzAQ7lqA==\"}","creationDate":"{\"iv\":\"xqdDY/A7MHLeAsoU9S/j+A==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"TQOhbjveZbvdiyYpxfwNyu5pi1PLia9FApJJRmr3QoyrWA==\"}","version":"v0.3.0+0ae62f31","poll":"' . $pollId . '"}}';
|
||||||
|
|
||||||
$pollDir = 'tests/_tmp/data/' . $pollId . '/';
|
$pollDir = 'tests/_tmp/data/' . $pollId . '/';
|
||||||
$userDir = $pollDir . 'users/';
|
$userDir = $pollDir . 'user/';
|
||||||
mkdir($pollDir);
|
mkdir($pollDir);
|
||||||
file_put_contents($pollDir . 'poll_data', $pollJson, LOCK_EX);
|
file_put_contents($pollDir . 'poll_data', $pollJson, LOCK_EX);
|
||||||
file_put_contents($pollDir . 'key_knowledge', $proofKeyKnowledge, LOCK_EX);
|
file_put_contents($pollDir . 'key_knowledge', $proofKeyKnowledge, LOCK_EX);
|
||||||
|
|
85
api/tests/api/GetLegacyPollWithUsersCept.php
Normal file
85
api/tests/api/GetLegacyPollWithUsersCept.php
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$pollId = substr(md5(__FILE__), 0, 10);
|
||||||
|
$pollJson = '{"poll":{"encryptedTitle":"{\"iv\":\"G1QGS+OHz5Z6Y4Og/3UFRQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"rgMRyJep4e0+Jj+K0ZTqbJS1j/gaouoTCoSHgXFdccn5L9gHBo1JO7Sl\"}","encryptedDescription":"{\"iv\":\"StcBqdGghIip/N3gLFmTMQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"5fgh7XABR7OifXoqHxE+c89mnVwkKUAG+x7D+BOGzoZK8dGT\"}","encryptedPollType":"{\"iv\":\"JYFdfUTb6xLWja302/bAKQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"wW+J3cGGF1tQUNfxt4gENDcZXQ==\"}","encryptedAnswerType":"{\"iv\":\"i0lDlvIVg2Le8pBSb47CIA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"+LNTLmILvxsN1X6E+vWa\"}","encryptedAnswers":"{\"iv\":\"xQV29b/F+gvlLl0zDCB7yw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"n5CwLLhSE5d28NU2/rOB7o6tXXWdDE7/uPr951Rr2ZQsmhsadmVwYE0K3Cxt+Hif4Am1jliS+PFjgVralrsSB00vlIH53wvDqQmNdk1Q/2zIebsVhHueamL4REyXn+18uVrjRarioojwOPYJLxNJHh0kPHATd0TgJxTb87RXgqUvAr1xc6DL7hY+fIbGoa6Otzt+OqIPhRTpaL+My1TYFXWQSlJxpPVSOILe1G/y6wg3Cp1lx4aFdHmGOGmrW+EF5pW9XrIz4A+3kNapSyUsDyuMk8wejrJpRHNcFpIlyRkxgUU=\"}","encryptedOptions":"{\"iv\":\"ruAw1xvAVLh9D19ngrEDgw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"pl1JeMRamWBuScBb1QOT9eqheJG2KD3y8RjtoPhNVid90wmoOQDm6WGtwt+gz6QXQEWUmIIXt8lyAJTH7updSnceW1SihfDi7xMmPTOf/338uSt3RdA2q+F+skiT14gheXHMtSFQaeVGvS8QfDXQfJBY9zJYp+On\"}","encryptedCreationDate":"{\"iv\":\"H/eApLF+Ja7ebX/1tPg7+w==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"8BhpHOrgM3L7XftckMdkXSFzXi2evkfheanKfcjMFxzYsg==\"}","encryptedForceAnswer":"{\"iv\":\"DapF8f4GhKPORoIrDPiRXg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"WfPqwu5yBkhrHJWR\"}","encryptedAnonymousUser":"{\"iv\":\"sIclbapCBCxkHi0QrlCqOA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"SXyhfk7DVgfVKfp7Kw==\"}","encryptedIsDateTime":"{\"iv\":\"CbB/QEzDlENL3qRK2ZjWxA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"TD0rnzzHaawAWyUP\"}","encryptedTimezone":"{\"iv\":\"wQQXNefWW5QC9VZ1KkQQmA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"5Zkx8f0WQAgBBG1s0DcxoHeA5Dc/fEI=\"}","version":"v0.3-0"}}';
|
||||||
|
$user1Json = '{"user":{"encryptedName":"{\"iv\":\"wibexCADUTTMP8vjmegTwA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"r6Vu5fzAgvXctXaCx70/Pr1ldaOE\"}","encryptedSelections":"{\"iv\":\"gCMgC5Rie++L3s42RGzQJg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"jTmkMEkFTUiy8vGJinXAUmi7u8RNQ/FnLgnd+CMKL2XtqjeZuXgfMMDAdTEZnzNQTK7p/IhHBZrcrksUTnWkv68+f76msMs3rOqnYi7jhVL7O7NZMVNXysAgzalrQ+78Zz8TqoJ1qIARksTTCOi7Md07XKkYptCr3QUu0r8kfgk3KbGDuIE3tS4gGuB5CLKuPfFcbE0DjWAcr9IIEXpSPgjzJyEAx3bDd89ZfbRE0RaMoAR7Vqx+L3Hs6pXoUSbtnBJOQypNQYqUYycWA/kxCcuQEBlHwIR5qq7c9VsXNBG9SfGSA62scmbg6pxVXd3jEyTaxw3+B5r705mpMgAEY6NiJykob34x8LThdJP7XZKfe/tyczcKAlcQtJ7ocQsac0l1gRLK6eKHcNs8I3Zzi5iBzyqZtg0OVHzI8NiYpjwvg7piTHawsujAZIYkw/S4Pt29wkbb/heWpUsdJOF2xlfYYkTHnrPbX5jwZbNIgA==\"}","encryptedCreationDate":"{\"iv\":\"NGuUKkuLbabetQG5co01ZA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"ratk7+pQ14nax+slSf7ttOk2IIbQx7W2iu3I5VuUIR8RGg==\"}","version":"v0.3-0","poll":"gpwW7uZhbP"}}';
|
||||||
|
$user2Json = '{"user":{"encryptedName":"{\"iv\":\"GsRvWloC3GYi+MoOCUQ1vg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"0upVYhihQhWZcWpXcx5xKGHOTKTcVptz\"}","encryptedSelections":"{\"iv\":\"1FQ0Bf91k3JQbr23AhTszg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"u6qAugU7o/gTUvjaBrSjlNsU1AJ5oIPiSqrXs7iC7117ss2iX0aENcwsGG09XUk+K1llyrGAI7Fp2uBqn6fyujpacJrJG5oO7SR7F8xwc5TpMlWp/CHN2C9VPdOnm8KhdDtt6IUbNV+McjBxa3FtNVttkF4FAtUGYSurrrEscRad7bvSVbYzYkMs+83xS/ui+pJ3NLuNPntfErRIJw3EKacaUfm2eHCftBVvPHTy3AQbJ9mSKy3tMch+qu1nLnyFSMKjRieCFOgkT3LkQcvfpSteV3V/UNfm82ERy7AYOB8KZ0hW1R/vDp2R+EjFS3/0cw+a8luW6HGcyY0fs18uIbsSUaLOiThKTjp9pYhupXEa9gz1DeZMC51M79Ha4YC9uy3AyG5hH29DYF5yhBPD1Z0iYcgosJ8TweiYN0AvlCYsy939VRSzFGeiI/ZFN76DF0YP1LAOK9bTXHN9n8oyDoQbBMKcY48/uWZZpCAvBw==\"}","encryptedCreationDate":"{\"iv\":\"gLvf5OObVV10vRrQbMcrDw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"sWHHRuInJDY=\",\"ct\":\"2S5gjZmZ8QQRPfovPpLTbvQLsurgNIHXhkG0Ze8OpTScCw==\"}","version":"v0.3-0","poll":"gpwW7uZhbP"}}';
|
||||||
|
|
||||||
|
$pollDir = 'tests/_tmp/data/' . $pollId . '/';
|
||||||
|
$userDir = $pollDir . 'user/';
|
||||||
|
mkdir($pollDir);
|
||||||
|
file_put_contents($pollDir . 'poll_data', $pollJson);
|
||||||
|
mkdir($userDir);
|
||||||
|
file_put_contents($userDir . '0', $user1Json);
|
||||||
|
file_put_contents($userDir . '1', $user2Json);
|
||||||
|
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo('get an existing legacy (v0.3.0) poll with users');
|
||||||
|
$I->sendGET('/polls/' . $pollId);
|
||||||
|
$I->seeResponseCodeIs(200);
|
||||||
|
$I->seeResponseIsJson();
|
||||||
|
|
||||||
|
$pollData = json_decode($pollJson, true)["poll"];
|
||||||
|
unset($pollData["serverExpirationDate"]);
|
||||||
|
foreach($pollData as $key => $value) {
|
||||||
|
if (strpos($key, 'encrypted') === 0) {
|
||||||
|
$key = lcfirst(substr($key, 9));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$key = $key;
|
||||||
|
}
|
||||||
|
$I->seeResponseContainsJson(
|
||||||
|
array(
|
||||||
|
'poll' => array(
|
||||||
|
$key => $value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$I->seeResponseContainsJson(["poll" => ["id" => $pollId]]);
|
||||||
|
$I->dontSeeResponseJsonMatchesJsonPath('poll.serverExpirationDate');
|
||||||
|
$I->seeResponseJsonMatchesJsonPath('poll.users');
|
||||||
|
$users = $I->grabDataFromResponseByJsonPath('poll.users')[0];
|
||||||
|
\PHPUnit_Framework_Assert::assertTrue(
|
||||||
|
is_array($users),
|
||||||
|
'user should be an array'
|
||||||
|
);
|
||||||
|
\PHPUnit_Framework_Assert::assertEquals(
|
||||||
|
count($users),
|
||||||
|
2,
|
||||||
|
'user array should contain 2 users'
|
||||||
|
);
|
||||||
|
|
||||||
|
function wellformUser($user) {
|
||||||
|
$return = $user["user"];
|
||||||
|
foreach ($return as $key => $value) {
|
||||||
|
if(strpos($key, 'encrypted') === 0) {
|
||||||
|
$return[lcfirst(substr($key, 9))] = $value;
|
||||||
|
unset($return[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
$I->seeResponseContainsJson([
|
||||||
|
"poll" => [
|
||||||
|
"users" => [
|
||||||
|
wellformUser(json_decode($user1Json, true)),
|
||||||
|
wellformUser(json_decode($user2Json, true))
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$I->seeResponseJsonMatchesJsonPath('poll.users.0.id');
|
||||||
|
$I->seeResponseJsonMatchesJsonPath('poll.users.1.id');
|
||||||
|
$user1Id = $I->grabDataFromResponseByJsonPath('poll.users.0.id')[0];
|
||||||
|
$user2Id = $I->grabDataFromResponseByJsonPath('poll.users.1.id')[0];
|
||||||
|
\PHPUnit_Framework_Assert::assertTrue(
|
||||||
|
$user1Id !== $user2Id,
|
||||||
|
'user ids are unique'
|
||||||
|
);
|
||||||
|
\PHPUnit_Framework_Assert::assertEquals(
|
||||||
|
explode('_', $user1Id)[0],
|
||||||
|
$pollId,
|
||||||
|
'user id starts by poll id'
|
||||||
|
);
|
|
@ -6,7 +6,7 @@ $user1Json = '{"name":"{\"iv\":\"GJXPSYYmTVfEsst31BD92w==\",\"v\":1,\"iter\":100
|
||||||
$user2Json = '{"name":"{\"iv\":\"DVNTCOFfACEOrgtVNVMyww==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"eug7bstOm7T\/CCFs32o=\"}","selections":"{\"iv\":\"ubEuXoXzw4QFuzjAyvXC6w==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"PfQ4v4hkBf+S0GX7JmnIp2LO5sh\/jg9nEIPn8NeU2Gn9Rb7cqsjCLgKOQ2xkiIzCyimVBOYg0fjGCyzM\/b6ZPQnY+86teNGogEteD4fjqGHhO832FNOy7Oci0YC8VAM1x9SlQNBI9V+vFc706JbZgwA8JY46UMiGK3HU49pgbYMpdnWEmt4dGzGrLMnNbh4J1Or5JydKmrp4dXaMiiggSXhmUTgBJSRhF7dxQm16oaA1lJpCWoQBvu+WTJv34LnBXHbgg6JcAEEONaQRw1jmMeqo36tQJxSdjiVfcDWzMifWiz\/nhQMqDHkc19iOAmDBo2Rf+yrGWA==\"}","creationDate":"{\"iv\":\"Sj4pVW\/maHa8DUNFHhyUrw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"HaY9MtEzVmEg3dxtI\/pfaIrsivBJSNeC5l5iJHQrvyYQGA==\"}","version":"v0.3.0+0ae62f31","poll":"l3zyFJUWcQ"}';
|
$user2Json = '{"name":"{\"iv\":\"DVNTCOFfACEOrgtVNVMyww==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"eug7bstOm7T\/CCFs32o=\"}","selections":"{\"iv\":\"ubEuXoXzw4QFuzjAyvXC6w==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"PfQ4v4hkBf+S0GX7JmnIp2LO5sh\/jg9nEIPn8NeU2Gn9Rb7cqsjCLgKOQ2xkiIzCyimVBOYg0fjGCyzM\/b6ZPQnY+86teNGogEteD4fjqGHhO832FNOy7Oci0YC8VAM1x9SlQNBI9V+vFc706JbZgwA8JY46UMiGK3HU49pgbYMpdnWEmt4dGzGrLMnNbh4J1Or5JydKmrp4dXaMiiggSXhmUTgBJSRhF7dxQm16oaA1lJpCWoQBvu+WTJv34LnBXHbgg6JcAEEONaQRw1jmMeqo36tQJxSdjiVfcDWzMifWiz\/nhQMqDHkc19iOAmDBo2Rf+yrGWA==\"}","creationDate":"{\"iv\":\"Sj4pVW\/maHa8DUNFHhyUrw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mhO9ROu+dr4=\",\"ct\":\"HaY9MtEzVmEg3dxtI\/pfaIrsivBJSNeC5l5iJHQrvyYQGA==\"}","version":"v0.3.0+0ae62f31","poll":"l3zyFJUWcQ"}';
|
||||||
|
|
||||||
$pollDir = 'tests/_tmp/data/' . $pollId . '/';
|
$pollDir = 'tests/_tmp/data/' . $pollId . '/';
|
||||||
$userDir = $pollDir . 'users/';
|
$userDir = $pollDir . 'user/';
|
||||||
mkdir($pollDir);
|
mkdir($pollDir);
|
||||||
file_put_contents($pollDir . 'poll_data', $pollJson);
|
file_put_contents($pollDir . 'poll_data', $pollJson);
|
||||||
mkdir($userDir);
|
mkdir($userDir);
|
||||||
|
|
|
@ -25,31 +25,12 @@ export default DS.RESTSerializer.extend({
|
||||||
var decryptionKey = dummyRecord.get('encryption.key');
|
var decryptionKey = dummyRecord.get('encryption.key');
|
||||||
dummyRecord.destroyRecord();
|
dummyRecord.destroyRecord();
|
||||||
|
|
||||||
// legacy support for versions before v0.4.0
|
|
||||||
if (!resourceHash.version || resourceHash.version === 'v0.3-0')
|
|
||||||
{
|
|
||||||
for(var key in resourceHash) {
|
|
||||||
// attributes got renamed in v0.4.0
|
|
||||||
// encrypted prefix was removed
|
|
||||||
if(key.indexOf('encrypted') === 0) {
|
|
||||||
let newKey;
|
|
||||||
// remove prefix 'encrypted'
|
|
||||||
newKey = key.substring(9);
|
|
||||||
// first char to lower case
|
|
||||||
newKey = newKey[0].toLowerCase() + newKey.slice(1);
|
|
||||||
// set correct attribute name in hash and delete wrong one
|
|
||||||
resourceHash[newKey] = resourceHash[key];
|
|
||||||
delete resourceHash[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// run before serialization of attribute hash
|
// run before serialization of attribute hash
|
||||||
modelClass.eachAttribute(function(key, attributes) {
|
modelClass.eachAttribute(function(key, attributes) {
|
||||||
if (
|
if (
|
||||||
attributes.options.encrypted !== false
|
attributes.options.encrypted !== false
|
||||||
) {
|
) {
|
||||||
if (typeof resourceHash[key] !== "undefined") {
|
if (typeof resourceHash[key] !== "undefined" && resourceHash[key] !== null) {
|
||||||
try {
|
try {
|
||||||
resourceHash[key] = JSON.parse(
|
resourceHash[key] = JSON.parse(
|
||||||
sjcl.decrypt(decryptionKey, resourceHash[key])
|
sjcl.decrypt(decryptionKey, resourceHash[key])
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
import Ember from 'ember';
|
|
||||||
import { module, test } from 'qunit';
|
|
||||||
import startApp from 'croodle/tests/helpers/start-app';
|
|
||||||
import Pretender from 'pretender';
|
|
||||||
/* jshint proto: true */
|
|
||||||
/* global moment */
|
|
||||||
|
|
||||||
var application, server;
|
|
||||||
|
|
||||||
module('Acceptance | legacy support', {
|
|
||||||
beforeEach: function() {
|
|
||||||
application = startApp();
|
|
||||||
application.__container__.lookup('adapter:application').__proto__.namespace = '';
|
|
||||||
|
|
||||||
server = new Pretender();
|
|
||||||
},
|
|
||||||
|
|
||||||
afterEach: function() {
|
|
||||||
server.shutdown();
|
|
||||||
|
|
||||||
Ember.run(application, 'destroy');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('show a default poll created with v0.3.0', function(assert) {
|
|
||||||
var id = 'xDF516KCyI',
|
|
||||||
encryptionKey = 'i7yjbKl8X6rObvnN9YuuwCIRdBxx5443T4GTKSny';
|
|
||||||
|
|
||||||
server.get('/polls/' + id, function() {
|
|
||||||
return [
|
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
'{"poll":{"encryptedTitle":"{\\"iv\\":\\"UX3elmjGqNKrEG8VaBQKBQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"nXvJ+mvLM8jWOg2VUMsFtk4MwEc0cDdb2Ult3KgwX\\/Qcckq9ynuemGrB\\"}","encryptedDescription":"{\\"iv\\":\\"XOd2nsI7tPQhJq5TpcTaOQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"Km2lCbdP9UnTG1bCHHWZVSr8itBPDZHPRTR25lTxX\\/kyzbpHv9AalmwW7ho9U+VdT2D4HcjCQXS6gBppkAvouhbhJJBcoCTYyQQWRprLDhlRJDdlXoxvLAQ8mkprYjPbd9hDSgP+wCgeaP4srVfIZ1Nzs\\/aCVX5dZVy0h3xo\\"}","encryptedPollType":"{\\"iv\\":\\"42b5q7Edr81oZQe\\/JbaUhA==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"KL9G5\\/9mUWIMUde8MSPrsL8mVA==\\"}","encryptedAnswerType":"{\\"iv\\":\\"D6ILcXVWJjJrqVcOvIpaPQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"UfNLQ\\/\\/oyu1k\\/QGFMj1z\\"}","encryptedAnswers":"{\\"iv\\":\\"NJ+zUA8q\\/1kCTZ6RvUtVWA==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"RG2+2EMqIcomBHhTYvLj2\\/tk5sO\\/JcNUDO9nSW\\/6I2eHD6qICQyvh9AANEDca39fGSsyIDWdEGb5vUBO698U3tKmbLT5Wc+VnpUibZNkKudrhwyAW6ZBXqQbACFHcwIrEDzAcmcJEEpF2LfB07VSBAZv3+uBc1L8KJdpYpnnJEk8Vrh3XuICqFK4i9AxJEhoWu+WG4D8K8G+cVnK20JYVUykNwO5cwqxOGWOb04gTPVT8zflX6z99ur1u6QqpIMO9hUUX54y25XuARbm\\/wCLsXAifM\\/K8b0vWjrRYgcnTvno\\/rk=\\"}","encryptedOptions":"{\\"iv\\":\\"zbNGX5ve+E0ciwgQOwiUyQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"iC7lhzhChLa0dNZWUw9EEQQbTKwnsFQuGhslARzstggj4AG1f1mOdd1ExipGkye66TQ5SyCV3A==\\"}","encryptedCreationDate":"{\\"iv\\":\\"tX2yNkFpx9mEk1DB1UdFGg==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"546yKMVB2jRhjUtqJWT\\/C+irV7JjG0WgJp3+Ag3QkMny6Q==\\"}","encryptedForceAnswer":"{\\"iv\\":\\"Erp3h7I11PeHZhL60+\\/4CQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"yTm6HgIhNC8UHSzP\\"}","encryptedAnonymousUser":"{\\"iv\\":\\"c6EOvuJYw8eNCxnFAJ0eTw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"CO7J61aKRneZno7bCg==\\"}","encryptedIsDateTime":"{\\"iv\\":\\"1iHh8UZYj3Aqyl\\/nM06fRQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"x6b6MeO8ipO2K38GxA==\\"}","encryptedTimezone":"{\\"iv\\":\\"kZc64suFcN5PO3VsRvGQbw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"ataOh9JNWpvhjA==\\"}","version":"v0.3-0","id":"xDF516KCyI","users":[{"encryptedName":"{\\"iv\\":\\"pE4nQuD924O+ODNYRWJ7jg==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"m4EzKUdHStkFjcvt5q0MlusOESk4ew==\\"}","encryptedSelections":"{\\"iv\\":\\"VXGMuKcGpizAwFvpztXM3A==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"HeIxQ\\/bU11G0\\/fDXUkKzO94RpK72Ytnof2Hm11pqY3Lwot7kfxpLJ6DD3kKGVYruMe375Hii3bsXOjAroMAe+KUQ9SG0y0aOhJRCc\\/P8O6sAg6NPwBx\\/71LXxxaLr8ORDFzyCwZx3kjXWNS7j017w\\/zJNHJbzY7CimRaG8dtbK5UFFjb28T1SRmLzOvaQ4yJgaTbsnGBIeMrVI9qiEQ1Uo44bRqT6Js9OBzykt\\/aU4FXce3iJ3hctbeYqPRx\\/+TJTS07Wf6LYZG0VRhFhRqmIJLky3PhyZsXgwtY0gJJDyLa9ctN7POurxoFXzyk4fk1AANtHUDVbA==\\"}","encryptedCreationDate":"{\\"iv\\":\\"GUDjdSw2hW2e0wBhwoPx3Q==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Sv34vSd\\/b14=\\",\\"ct\\":\\"zMRHnbJF28bidi6+9uN9T+CvlrvtZzi4nrLeqQuwHpUj5Q==\\"}","version":"v0.3-0","poll":"xDF516KCyI","id":"0"}]}}'
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
visit('/poll/' + id + '?encryptionKey=' + encryptionKey);
|
|
||||||
|
|
||||||
andThen(function() {
|
|
||||||
pollTitleEqual(assert, 'default poll created with v0.3.0');
|
|
||||||
pollDescriptionEqual(assert, 'two dates selected: 1.1.2016, 2.2.2016; no times specified\nanswers: yes, no\nanonymous user: no\nforce answers: yes');
|
|
||||||
|
|
||||||
pollHasOptions(assert, [
|
|
||||||
moment('2016-01-01').format(
|
|
||||||
moment.localeData().longDateFormat('LLLL')
|
|
||||||
.replace(
|
|
||||||
moment.localeData().longDateFormat('LT'), '')
|
|
||||||
.trim()
|
|
||||||
),
|
|
||||||
moment('2016-02-02').format(
|
|
||||||
moment.localeData().longDateFormat('LLLL')
|
|
||||||
.replace(
|
|
||||||
moment.localeData().longDateFormat('LT'), '')
|
|
||||||
.trim()
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
assert.ok(
|
|
||||||
find('input', find('.newUserSelection')[0]).length,
|
|
||||||
'answers are correct (count)'
|
|
||||||
);
|
|
||||||
assert.ok(
|
|
||||||
find('.newUserSelection label .yes') && find('.newUserSelection label .no'),
|
|
||||||
'answers are correct (class)'
|
|
||||||
);
|
|
||||||
|
|
||||||
pollHasAnswers(assert, ['Yes','No']);
|
|
||||||
|
|
||||||
pollHasUsersCount(assert, 1);
|
|
||||||
pollHasUser(assert, 'Juri Gagarin', [Ember.I18n.t('answerTypes.yes.label'), Ember.I18n.t('answerTypes.no.label')]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('show a poll (makeAPoll, freeText) created with v0.3.0', function(assert) {
|
|
||||||
var id = 'NLI7U2QEOE',
|
|
||||||
encryptionKey = 'tEig58l8DsEw8B629Kc544VvmegkYfbd1GozImKj';
|
|
||||||
|
|
||||||
server.get('/polls/' + id, function() {
|
|
||||||
return [
|
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
'{"poll":{"encryptedTitle":"{\\"iv\\":\\"qPvy66kw9BDSGeMRE0kAVA==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"3eHLf1mM8Sbu8w6mPpQxoTVbo\\/z8myRMAemCYvCh+jA16myx2Oq5CHtVFBI+0v7jdWtBWHAU\\/xo=\\"}","encryptedDescription":"{\\"iv\\":\\"YTeSNaW622Jq5FP+ViYKqw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"nxUebyFUKF6bnSyg6MRleJ4M8oHEtCIsiXFlZbXfTBt9Ryk7dNAAzDfTnJzdzxzTvUXHPCkHVP2rHhLq3CKgAkJDo1AmU2p4Qcc=\\"}","encryptedPollType":"{\\"iv\\":\\"nAsa8b4WuvoT4q5PrZ\\/APw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"aysnMipL7WAAylWIcjeeOvovDQ==\\"}","encryptedAnswerType":"{\\"iv\\":\\"X\\/s19dp4Xx8FWfljx13n7A==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"iPBCoXKzCDwZqkUXAUGIeZLp\\"}","encryptedAnswers":"{\\"iv\\":\\"dkrELfNfFpXDItFEZdDPIw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"XuDMfuNVnk0R7w==\\"}","encryptedOptions":"{\\"iv\\":\\"5Ta3GQeDl43b07eYnHjDyQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"d6oQ4wslFq80bxQZHF53sfiJyEZUYnJ4rNMQGsM03B+wug99ijQif9BGucMJ9bbNz8cD\\"}","encryptedCreationDate":"{\\"iv\\":\\"Hrh0aKUB3suiZurJksVExQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"BeGbWW55MXFKcshjmEWVCMGZ\\/5h1VF52LjLEQUGCBsyKWg==\\"}","encryptedForceAnswer":"{\\"iv\\":\\"84p+nSsIAOJHv\\/FprCsvDg==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"Y4o5JddmJ+4bq5Z2\\"}","encryptedAnonymousUser":"{\\"iv\\":\\"FwrZNpE05Dwk3Kwsd835vw==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"OacRpsJn7NhePn61Eg==\\"}","encryptedIsDateTime":"{\\"iv\\":\\"+8oX1bwIzPhhteIwH1Ce+w==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"tsv6mHV2vdziajjq3w==\\"}","encryptedTimezone":"{\\"iv\\":\\"ZY\\/UQmqSHQWUuVncuS3j\\/w==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"rnjPdsDJcbeciw==\\"}","version":"v0.3-0","id":"NLI7U2QEOE","users":[{"encryptedName":"{\\"iv\\":\\"\\/LdIkuVBjJBJRXYuJfyBlQ==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"rGsCm8TWuV4fjF1lDXaAmDmA79mx\\"}","encryptedSelections":"{\\"iv\\":\\"AfALavJ3clleK1ku63XC2A==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"6i77y3I8iZJkUuxJb+pc0a1zdSA3otK3d660cI9CCOpgmsZsQGkgq6x2XN9dSgdrMLrXAw==\\"}","encryptedCreationDate":"{\\"iv\\":\\"en9XKkmIub2ROGCc6RX9gg==\\",\\"v\\":1,\\"iter\\":1000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"Go+BZ2BlBbA=\\",\\"ct\\":\\"nZGqAHCtszEpX27WWL3trpJp1qzFnudGefSgnPXkMZ+xdQ==\\"}","version":"v0.3-0","poll":"NLI7U2QEOE","id":"0"}]}}'
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
visit('/poll/' + id + '?encryptionKey=' + encryptionKey);
|
|
||||||
|
|
||||||
andThen(function() {
|
|
||||||
pollTitleEqual(assert, 'poll (makeAPoll, freeText) created with v0.3.0');
|
|
||||||
pollDescriptionEqual(assert, 'poll type: makeAPoll\nanswer type: freeText\ncreated with v0.3.0');
|
|
||||||
|
|
||||||
pollHasOptions(assert, ['Option 1', 'Option 2']);
|
|
||||||
|
|
||||||
pollHasUsersCount(assert, 1);
|
|
||||||
pollHasUser(assert, 'Georg Elser', ['Answer I', 'Answer II']);
|
|
||||||
});
|
|
||||||
});
|
|
1
tests/dummyData/JlHpRs0Pzi/poll_data
Normal file
1
tests/dummyData/JlHpRs0Pzi/poll_data
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"poll":{"encryptedTitle":"{\"iv\":\"CyFXJkaPR8nHPxfZ3QzHKQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"z0VpAWbE9xa/NeIwpFNmFNvWDPAWyR+qafTWjlpE0K9B2kvRETpbO1q+\"}","encryptedDescription":"{\"iv\":\"fLP+ThbrPBgHZtKXR7OQZQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"x5693dRA11H2jt9rsb0IrT2Ys7AmF0eEmO0c9Qd6PAaU/VMU\"}","encryptedPollType":"{\"iv\":\"8i9uQL/a2p/wSPOrZVAWuA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"FHfDWlVEgPVl6lbS3GyErLgEng==\"}","encryptedAnswerType":"{\"iv\":\"XGHKVaXBqOJKRjIz5YQ7yw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"HnKzX+jpn2rO04Ujb/YEx6knzjY=\"}","encryptedAnswers":"{\"iv\":\"S3UKahavBtSR53oo43/0rg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"47unEVJ1d3kd4iIMxQLRDYjXoDlZc5Dgl/Mn8CI6NxeMlD23P3yNpe8ho77H9ms3ciZGxqK4WgEn3DSALqmQWc9vM3SBk+zBfs0y+WMQJjeaC4n7DZ8ZvFihvOOGoq2IHUzkg7/Yuuld4YKYcPE8abOYKXr7qeZFkZLEEqC6vESSHnMp1J/S0Na0TiB9mqtNI+e+PvSso4K+IfHBYtk4lzMcjorsEkKJwhLENJ1M/7YaLnfAU7nWIAu5QmV5PPmTEshyR4Nwildba7FhLFmAXcM46T4s3bTAxjBkBUYJbpiehkFBj4fEKMlCXb748nlrn9NmJPPUwhLEQPW/a+0Ts1zlB2X8c0nmKWrsPJ3UahrUX/hFTyl4w9eC/9wgKjSXDbPDozZntt75bwPZ8hrZWY443nDn0UwO4xJ2dhfXxEtjf6jxpqAOtqEhQSveq/YZlaFs3wgbdXdbfObC\"}","encryptedOptions":"{\"iv\":\"H2Odh5d8xiV41Gmp5cNNEA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"Cnm1bbdRSntawnkB0cxjAKlGGndzIKc2QyIFT/o4/JDZ/DGvBS2JMdh7nGjUG396SGvEMEWH/vApnkr6pvsyVH/j9PgIG51fGkKH+l1MqD/RsRulcEHKTDT5sBbyn4FlXoTvtYvohK9dQmJTx0KQGtK5uXYXJhWI\"}","encryptedCreationDate":"{\"iv\":\"FCtLmBGvQp3daBCDPOMeWA==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"R8htP6LflfZpWdKvWrFG+0tk/fO/Tane0x+Go7XJcf4FnQ==\"}","encryptedForceAnswer":"{\"iv\":\"h2Ry/duNbzOqYqfWL5FJtw==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"aRkdAO1OTcMSbWIz\"}","encryptedAnonymousUser":"{\"iv\":\"OfiX9GP1gi5oDUGsA/ffXg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"GHCi6A0ve9XnC8scyw==\"}","encryptedIsDateTime":"{\"iv\":\"zsWI4NKCNlDniMQi2tI0Bg==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"OtTqPoepCqkdb3VZ\"}","encryptedTimezone":"{\"iv\":\"0SFZbfB+AuOrfgmwsOfPbQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"5D0biig/kbVJVOz8flj7yVt0Hk+HzjA=\"}","version":"v0.3-0"}}
|
1
tests/dummyData/JlHpRs0Pzi/user/0
Normal file
1
tests/dummyData/JlHpRs0Pzi/user/0
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"user":{"encryptedName":"{\"iv\":\"R/cXZ6m3CHSsuO4CpDyb+Q==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"IwrPVCSqALv0as20uD8vfA0CgHtj\"}","encryptedSelections":"{\"iv\":\"6UONFgK1lipRlfPGhT669w==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"QD7mUdwuP65KUPJWZzY2Nj6Ebz8gzU5XNFAqU2YyaxENDQEG8tCedS6YoPATevunL8JmlLk99JU1WVr9YagAfwx1RqBC9RGoo8yrqtUgY4YhY8QS4euZUisUH1vHJo6UrxiehsJ3Gg457L1qs5d073wslfTIVpsT1FBQE4QejlNizxINGidTsKnNGyY/pfNhESvtVlyuQkzMMrQZr2V5gkcngqxnJL7Xr1QWT8IyxX7o8DCffO3IYHWzUprf+vFfxnKb91vWcuNHH4iIcnQqrcOEn2sEnuF8SK5G9pHMOl29yCKySUeq+snf+teLH3NE0jRkeb1ygeNYwRQa6WdD3bAh4r2RqRXmmvj/K+YZmPHwzYuIl5bgnBv5itfHBSbGOa7JnErXEp9qyUxw81Nev27EnDu+jJmurak7Ub05wUgVojuZodwutoxRT+Cv3LEn8ZhJsVs4+ujFiDG7OxyNfo4tGyqWGZbY60XKg5xOZA==\"}","encryptedCreationDate":"{\"iv\":\"fvMSYH7eGacN3pWZt79n1Q==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"lU+lEqixsqC3WAxYnrXsAFXRHpaG4l9j49CvAsmlvNEWTg==\"}","version":"v0.3-0","poll":"JlHpRs0Pzi"}}
|
1
tests/dummyData/JlHpRs0Pzi/user/1
Normal file
1
tests/dummyData/JlHpRs0Pzi/user/1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"user":{"encryptedName":"{\"iv\":\"dJqDMtpybxd3Va0OWAz7dQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"q0EXDJx6OlJmk6GHSG095h6PCoy619ak\"}","encryptedSelections":"{\"iv\":\"3bMHwpqBVfNJddrzwLIe2Q==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"HHtQJievHhOf0tVY3GEGZIY36FNUlw67j9ZIvL/Tyfd2FghrwmPF+VMDrl8Rnr0x93JF+S9p5ZgXEC9GpuVT34S9kJY6dwaDkaSaORkVqXFTvXDEEMXwD0mA9FL6aDwYT25UY5OdEIYXpFkhiv0Hi+xtTvOJpxuq3FiOtgYxB4JU3JY53G20E2lPbVAOl89pnWT83eVNq/1dEd+SzVXR0J4pYNuuP7qrBJv+lN0c7456FL+32/NGo7e9UbLRYV++0UxIu10Jnc7A9VKRnGz/pghmX593DXG9NIHhCfvXu5t6zcMJp57NY6O+CAa5gSVzKw2Q80BJNgh3byjcvH+lqdu41/GONhqylVOc7RtPj0pqr4Up46gSe7tbHJA+84lWnwoIl9tSzgnwau0Fzxy3e+eDwSaHwhUiwOQGA4DJo9eCx7m/6Wj6u0yIOagKrP67S7HWoEiMVfBfPERiELhN2vsR4DSRDSDYA/gXkhu6N3LPnrhBwRdG6P+P\"}","encryptedCreationDate":"{\"iv\":\"nVUmPzlIuIdllptB865sIQ==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"mHJC65Kkl9c=\",\"ct\":\"FpW40CLc5nprDoyrGHGMx+B3tX/UHI+1+pLn2/R8kwJjdA==\"}","version":"v0.3-0","poll":"JlHpRs0Pzi"}}
|
74
tests/integration/legacy-support-test.js
Normal file
74
tests/integration/legacy-support-test.js
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import startApp from 'croodle/tests/helpers/start-app';
|
||||||
|
/* global moment */
|
||||||
|
|
||||||
|
var application;
|
||||||
|
|
||||||
|
module('Integration | legacy support', {
|
||||||
|
beforeEach: function() {
|
||||||
|
application = startApp();
|
||||||
|
},
|
||||||
|
|
||||||
|
afterEach: function() {
|
||||||
|
Ember.run(application, 'destroy');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('show a default poll created with v0.3.0', function(assert) {
|
||||||
|
var id = 'JlHpRs0Pzi',
|
||||||
|
encryptionKey = '5MKFuNTKILUXw6RuqkAw6ooZw4k3mWWx98ZQw8vH',
|
||||||
|
timezone = 'Europe/Berlin';
|
||||||
|
|
||||||
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey);
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
pollTitleEqual(assert, 'default poll created with v0.3.0');
|
||||||
|
pollDescriptionEqual(assert, 'used for integration tests');
|
||||||
|
|
||||||
|
pollHasOptionsDates(assert, [
|
||||||
|
moment('2015-12-24').format(
|
||||||
|
moment.localeData().longDateFormat('LLLL')
|
||||||
|
.replace(
|
||||||
|
moment.localeData().longDateFormat('LT'), '')
|
||||||
|
.trim()
|
||||||
|
),
|
||||||
|
moment('2015-12-31').format(
|
||||||
|
moment.localeData().longDateFormat('LLLL')
|
||||||
|
.replace(
|
||||||
|
moment.localeData().longDateFormat('LT'), '')
|
||||||
|
.trim()
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
pollHasOptionsTimes(assert, [
|
||||||
|
moment.tz('2015-12-24T17:00:00.000Z', timezone).format('LT'),
|
||||||
|
moment.tz('2015-12-24T19:00:00.000Z', timezone).format('LT'),
|
||||||
|
moment.tz('2015-12-31T22:59:00.000Z', timezone).format('LT')
|
||||||
|
]);
|
||||||
|
|
||||||
|
pollHasAnswers(assert, [
|
||||||
|
Ember.I18n.t('answerTypes.yes.label'),
|
||||||
|
Ember.I18n.t('answerTypes.maybe.label'),
|
||||||
|
Ember.I18n.t('answerTypes.no.label')
|
||||||
|
]);
|
||||||
|
|
||||||
|
pollHasUsersCount(assert, 2);
|
||||||
|
pollHasUser(assert,
|
||||||
|
'Fritz Bauer',
|
||||||
|
[
|
||||||
|
Ember.I18n.t('answerTypes.yes.label'),
|
||||||
|
Ember.I18n.t('answerTypes.no.label'),
|
||||||
|
Ember.I18n.t('answerTypes.no.label')
|
||||||
|
]
|
||||||
|
);
|
||||||
|
pollHasUser(assert,
|
||||||
|
'Lothar Hermann',
|
||||||
|
[
|
||||||
|
Ember.I18n.t('answerTypes.maybe.label'),
|
||||||
|
Ember.I18n.t('answerTypes.yes.label'),
|
||||||
|
Ember.I18n.t('answerTypes.no.label')
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue