Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
36e09bbc
Commit
36e09bbc
authored
Aug 14, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CryptStorage and Jio tests
parent
08c3aa1d
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
152 deletions
+124
-152
OfficeJS/src/jio.storage/cryptstorage.js
OfficeJS/src/jio.storage/cryptstorage.js
+82
-96
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+42
-56
No files found.
OfficeJS/src/jio.storage/cryptstorage.js
View file @
36e09bbc
This diff is collapsed.
Click to expand it.
OfficeJS/test/jiotests.js
View file @
36e09bbc
...
@@ -1157,29 +1157,27 @@ test ('Document save' , function () {
...
@@ -1157,29 +1157,27 @@ test ('Document save' , function () {
storage
:{
type
:
'
local
'
,
storage
:{
type
:
'
local
'
,
username
:
'
cryptsavelocal
'
,
username
:
'
cryptsavelocal
'
,
applicationname
:
'
jiotests
'
}});
applicationname
:
'
jiotests
'
}});
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
!
result
)
{
if
(
err
)
{
result
=
'
done
'
;
err
=
err
.
status
;
}
else
{
result
=
'
fail
'
;
}
}
deepEqual
(
result
,
'
done
'
,
'
save ok
'
);
deepEqual
(
err
||
val
,{
ok
:
true
,
id
:
'
testsave
'
}
,
'
save ok
'
);
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
o
.
jio
.
saveDocument
(
'
testsave
'
,
'
contentoftest
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
put
({
_id
:
'
testsave
'
,
content
:
'
contentoftest
'
},
o
.
f
);
clock
.
tick
(
1000
);
clock
.
tick
(
1000
);
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
ok
(
false
,
'
no response / too much results
'
);
ok
(
false
,
'
no response / too much results
'
);
}
}
// encrypt 'testsave' with 'cryptsave:mypwd' password
// encrypt 'testsave' with 'cryptsave:mypwd' password
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
// '/' = '%2F'
'
jio/local/cryptsavelocal/jiotests/rZx5PJxttlf9QpZER
/
5x354bfX54QFa1
'
);
'
jio/local/cryptsavelocal/jiotests/rZx5PJxttlf9QpZER
%2F
5x354bfX54QFa1
'
);
if
(
o
.
tmp
)
{
if
(
o
.
tmp
)
{
delete
o
.
tmp
.
last_modified
;
delete
o
.
tmp
.
_
last_modified
;
delete
o
.
tmp
.
creation_date
;
delete
o
.
tmp
.
_
creation_date
;
}
}
deepEqual
(
o
.
tmp
,
deepEqual
(
o
.
tmp
,
{
name
:
'
rZx5PJxttlf9QpZER/5x354bfX54QFa1
'
,
{
_id
:
'
rZx5PJxttlf9QpZER/5x354bfX54QFa1
'
,
content
:
'
upZkPIpitF3QMT/DU5jM3gP0SEbwo1n81rMOfLE
'
},
content
:
'
upZkPIpitF3QMT/DU5jM3gP0SEbwo1n81rMOfLE
'
},
'
Check if the document is realy encrypted
'
);
'
Check if the document is realy encrypted
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
...
@@ -1194,26 +1192,20 @@ test ('Document load' , function () {
...
@@ -1194,26 +1192,20 @@ test ('Document load' , function () {
storage
:{
type
:
'
local
'
,
storage
:{
type
:
'
local
'
,
username
:
'
cryptloadlocal
'
,
username
:
'
cryptloadlocal
'
,
applicationname
:
'
jiotests
'
}});
applicationname
:
'
jiotests
'
}});
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
result
&&
!
result
.
status
)
{
deepEqual
(
err
||
val
,{
deepEqual
(
result
,
_id
:
'
testload
'
,
content
:
'
contentoftest
'
,
{
name
:
'
testload
'
,
_last_modified
:
500
,
_creation_date
:
500
},
'
load ok
'
);
content
:
'
contentoftest
'
,
last_modified
:
500
,
creation_date
:
500
},
'
load ok
'
);
}
else
{
ok
(
false
,
'
cannot load
'
);
}
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
// encrypt 'testload' with 'cryptload:mypwd' password
// encrypt 'testload' with 'cryptload:mypwd' password
// and 'contentoftest' with 'cryptload:mypwd'
// and 'contentoftest' with 'cryptload:mypwd'
o
.
doc
=
{
name
:
'
hiG4H80pwkXCCrlLl1X0BD0BfWLZwDUX
'
,
o
.
doc
=
{
content
:
'
kSulH8Qo105dSKHcY2hEBXWXC9b+3PCEFSm1k7k
'
,
_id
:
'
hiG4H80pwkXCCrlLl1X0BD0BfWLZwDUX
'
,
last_modified
:
500
,
creation_date
:
500
};
content
:
'
kSulH8Qo105dSKHcY2hEBXWXC9b+3PCEFSm1k7k
'
,
_last_modified
:
500
,
_creation_date
:
500
};
addFileToLocalStorage
(
'
cryptloadlocal
'
,
'
jiotests
'
,
o
.
doc
);
addFileToLocalStorage
(
'
cryptloadlocal
'
,
'
jiotests
'
,
o
.
doc
);
o
.
jio
.
loadDocument
(
'
testload
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
get
(
'
testload
'
,
o
.
f
);
clock
.
tick
(
1000
);
clock
.
tick
(
1000
);
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
ok
(
false
,
'
no response / too much results
'
);
ok
(
false
,
'
no response / too much results
'
);
...
@@ -1230,13 +1222,9 @@ test ('Get Document List', function () {
...
@@ -1230,13 +1222,9 @@ test ('Get Document List', function () {
storage
:{
type
:
'
local
'
,
storage
:{
type
:
'
local
'
,
username
:
'
cryptgetlistlocal
'
,
username
:
'
cryptgetlistlocal
'
,
applicationname
:
'
jiotests
'
}});
applicationname
:
'
jiotests
'
}});
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
result
&&
!
result
.
status
)
{
deepEqual
(
err
||
objectifyDocumentArray
(
val
.
rows
),
deepEqual
(
objectifyDocumentArray
(
result
),
objectifyDocumentArray
(
o
.
doc_list
),
'
Getting list
'
);
objectifyDocumentArray
(
o
.
doc_list
),
'
Getting list
'
);
}
else
{
ok
(
false
,
'
Cannot get list
'
);
}
};
};
o
.
tick
=
function
(
tick
)
{
o
.
tick
=
function
(
tick
)
{
clock
.
tick
(
tick
||
1000
);
clock
.
tick
(
tick
||
1000
);
...
@@ -1249,29 +1237,32 @@ test ('Get Document List', function () {
...
@@ -1249,29 +1237,32 @@ test ('Get Document List', function () {
}
}
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
o
.
doc_list
=
[
o
.
doc_list
=
[{
{
name
:
'
testgetlist1
'
,
last_modified
:
500
,
creation_date
:
200
},
id
:
'
testgetlist1
'
,
key
:
'
testgetlist1
'
,
value
:{
{
name
:
'
testgetlist2
'
,
last_modified
:
300
,
creation_date
:
300
}
_last_modified
:
500
,
_creation_date
:
200
}
];
},{
id
:
'
testgetlist2
'
,
key
:
'
testgetlist2
'
,
value
:{
_last_modified
:
300
,
_creation_date
:
300
}
}];
o
.
doc_encrypt_list
=
[
o
.
doc_encrypt_list
=
[
{
name
:
'
541eX0WTMDw7rqIP7Ofxd1nXlPOtejxGnwOzMw
'
,
{
_id
:
'
541eX0WTMDw7rqIP7Ofxd1nXlPOtejxGnwOzMw
'
,
content
:
'
/4dBPUdmLolLfUaDxPPrhjRPdA
'
,
content
:
'
/4dBPUdmLolLfUaDxPPrhjRPdA
'
,
last_modified
:
500
,
creation_date
:
200
},
_last_modified
:
500
,
_
creation_date
:
200
},
{
name
:
'
541eX0WTMDw7rqIMyJ5tx4YHWSyxJ5UjYvmtqw
'
,
{
_id
:
'
541eX0WTMDw7rqIMyJ5tx4YHWSyxJ5UjYvmtqw
'
,
content
:
'
/4FBALhweuyjxxD53eFQDSm4VA
'
,
content
:
'
/4FBALhweuyjxxD53eFQDSm4VA
'
,
last_modified
:
300
,
creation_date
:
300
}
_last_modified
:
300
,
_
creation_date
:
300
}
];
];
// encrypt with 'cryptgetlist:mypwd' as password
// encrypt with 'cryptgetlist:mypwd' as password
LocalOrCookieStorage
.
setItem
(
LocalOrCookieStorage
.
setItem
(
'
jio/local_file_name_array/cryptgetlistlocal/jiotests
'
,
'
jio/local_file_name_array/cryptgetlistlocal/jiotests
'
,
[
o
.
doc_encrypt_list
[
0
].
name
,
o
.
doc_encrypt_list
[
1
].
name
]);
[
o
.
doc_encrypt_list
[
0
].
_id
,
o
.
doc_encrypt_list
[
1
].
_id
]);
LocalOrCookieStorage
.
setItem
(
LocalOrCookieStorage
.
setItem
(
'
jio/local/cryptgetlistlocal/jiotests/
'
+
o
.
doc_encrypt_list
[
0
].
name
,
'
jio/local/cryptgetlistlocal/jiotests/
'
+
o
.
doc_encrypt_list
[
0
].
_id
,
o
.
doc_encrypt_list
[
0
]);
o
.
doc_encrypt_list
[
0
]);
LocalOrCookieStorage
.
setItem
(
LocalOrCookieStorage
.
setItem
(
'
jio/local/cryptgetlistlocal/jiotests/
'
+
o
.
doc_encrypt_list
[
1
].
name
,
'
jio/local/cryptgetlistlocal/jiotests/
'
+
o
.
doc_encrypt_list
[
1
].
_id
,
o
.
doc_encrypt_list
[
1
]);
o
.
doc_encrypt_list
[
1
]);
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
allDocs
(
o
.
f
);
o
.
tick
(
10000
);
o
.
tick
(
10000
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
...
@@ -1286,20 +1277,15 @@ test ('Remove document', function () {
...
@@ -1286,20 +1277,15 @@ test ('Remove document', function () {
storage
:{
type
:
'
local
'
,
storage
:{
type
:
'
local
'
,
username
:
'
cryptremovelocal
'
,
username
:
'
cryptremovelocal
'
,
applicationname
:
'
jiotests
'
}});
applicationname
:
'
jiotests
'
}});
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
!
result
)
{
deepEqual
(
err
||
val
,{
ok
:
true
,
id
:
'
file
'
},
'
Document remove
'
);
result
=
'
done
'
;
}
else
{
result
=
'
fail
'
;
}
deepEqual
(
result
,
'
done
'
,
'
Document remove
'
);
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
// encrypt with 'cryptremove:mypwd' as password
// encrypt with 'cryptremove:mypwd' as password
o
.
doc
=
{
name
:
'
JqCLTjyxQqO9jwfxD/lyfGIX+qA
'
,
o
.
doc
=
{
_id
:
'
JqCLTjyxQqO9jwfxD/lyfGIX+qA
'
,
content
:
'
LKaLZopWgML6IxERqoJ2mUyyO
'
,
content
:
'
LKaLZopWgML6IxERqoJ2mUyyO
'
,
last_modified
:
500
,
creation_date
:
500
};
_last_modified
:
500
,
_
creation_date
:
500
};
o
.
jio
.
remove
Document
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},
o
.
f
);
clock
.
tick
(
1000
);
clock
.
tick
(
1000
);
if
(
!
o
.
f
.
calledOnce
){
if
(
!
o
.
f
.
calledOnce
){
ok
(
false
,
'
no response / too much results
'
);
ok
(
false
,
'
no response / too much results
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment