Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jio
Commits
74f6eb98
Commit
74f6eb98
authored
Oct 18, 2013
by
Jonathan Rivalan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validation for unit tests except listing
parent
95d90c8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
111 deletions
+145
-111
src/jio.storage/s3storage.js
src/jio.storage/s3storage.js
+79
-46
test/jio.storage/s3storage.tests.js
test/jio.storage/s3storage.tests.js
+66
-65
No files found.
src/jio.storage/s3storage.js
View file @
74f6eb98
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
var
b64_hmac_sha1
=
sha1
.
b64_hmac_sha1
;
var
b64_hmac_sha1
=
sha1
.
b64_hmac_sha1
;
jIO
.
addStorage
(
"
s3
"
,
function
(
spec
,
my
)
{
jIO
.
addStorage
(
"
s3
"
,
function
(
spec
,
my
)
{
var
evt
,
that
,
priv
=
{},
lastDigest
;
var
evt
,
that
,
priv
=
{},
lastDigest
,
isDelete
;
that
=
this
;
that
=
this
;
//nomenclature param
//nomenclature param
...
@@ -260,9 +260,6 @@
...
@@ -260,9 +260,6 @@
return
StringToSign
;
return
StringToSign
;
};
};
that
.
encodePolicy
=
function
(
form
)
{
that
.
encodePolicy
=
function
(
form
)
{
//generates the policy
//generates the policy
//enables the choice for the http response code
//enables the choice for the http response code
...
@@ -273,10 +270,7 @@
...
@@ -273,10 +270,7 @@
{
"
bucket
"
:
priv
.
server
},
{
"
bucket
"
:
priv
.
server
},
[
"
starts-with
"
,
"
$key
"
,
""
],
[
"
starts-with
"
,
"
$key
"
,
""
],
{
"
acl
"
:
priv
.
acl
},
{
"
acl
"
:
priv
.
acl
},
{
"
success_action_redirect
"
:
""
},
[
"
starts-with
"
,
"
$Content-Type
"
,
""
]
{
"
success_action_status
"
:
http_code
},
[
"
starts-with
"
,
"
$Content-Type
"
,
""
],
[
"
content-length-range
"
,
0
,
524288000
]
]
]
};
};
...
@@ -321,9 +315,7 @@
...
@@ -321,9 +315,7 @@
if
(
jio
===
true
)
{
if
(
jio
===
true
)
{
if
(
isAttachment
===
true
)
{
if
(
isAttachment
===
true
)
{
//méthode that.getAttachment
//méthode that.getAttachment
console
.
log
(
this
);
response
=
this
.
response
;
response
=
this
.
response
;
console
.
log
(
response
);
command
.
success
(
this
.
status
,{
'
data
'
:
response
,
'
digest
'
:
lastDigest
});
command
.
success
(
this
.
status
,{
'
data
'
:
response
,
'
digest
'
:
lastDigest
});
}
}
//n'est pas un attachment
//n'est pas un attachment
...
@@ -368,13 +360,25 @@
...
@@ -368,13 +360,25 @@
//error
//error
//reason "reason"
//reason "reason"
//message "did not work"
//message "did not work"
err
.
statustext
=
"
not_foud
"
;
return
command
.
error
(
err
.
reason
=
"
file does not exist
"
;
404
,
err
.
error
=
"
not_found
"
;
"
Not Found
"
,
command
.
error
(
err
);
"
File does not exist
"
);
}
else
{
}
else
{
//not jio
callback
(
'
404
'
);
if
(
isDelete
===
true
){
isDelete
=
false
;
return
command
.
error
(
404
,
"
Not Found
"
,
"
File does not exist
"
);
}
else
{
callback
(
'
404
'
);
}
}
}
}
else
{
}
else
{
//status
//status
...
@@ -382,9 +386,13 @@
...
@@ -382,9 +386,13 @@
//error
//error
//reason "reason"
//reason "reason"
//message "did not work"
//message "did not work"
err
.
error
=
"
not_found
"
;
return
command
.
error
(
command
.
error
(
err
);
404
,
"
Not Found
"
,
"
File does not exist
"
);
}
}
//fin 404
}
}
if
(
this
.
status
===
409
)
{
if
(
this
.
status
===
409
)
{
//status
//status
...
@@ -392,8 +400,11 @@
...
@@ -392,8 +400,11 @@
//error
//error
//reason "reason"
//reason "reason"
//message "did not work"
//message "did not work"
err
.
error
=
"
already_exists
"
;
return
command
.
error
(
command
.
error
(
err
);
409
,
"
Already Exists
"
,
"
File does exist
"
);
}
}
}
}
}
}
...
@@ -478,7 +489,7 @@
...
@@ -478,7 +489,7 @@
+
"
:
"
+
"
:
"
+
Signature
);
+
Signature
);
xhr
.
setRequestHeader
(
"
Content-Type
"
,
mime
);
xhr
.
setRequestHeader
(
"
Content-Type
"
,
mime
);
if
(
http
==
'
GET
'
&&
jio
==
true
&&
is_attachment
==
true
){
if
(
http
==
'
GET
'
&&
jio
==
true
&&
is_attachment
==
true
){
xhr
.
responseType
=
'
blob
'
;
xhr
.
responseType
=
'
blob
'
;
}
else
{
}
else
{
...
@@ -508,13 +519,16 @@
...
@@ -508,13 +519,16 @@
* @param {object} command The JIO command
* @param {object} command The JIO command
**/
**/
that
.
post
=
function
(
command
)
{
that
.
post
=
function
(
command
,
metadata
)
{
//as S3 encoding key are directly inserted within the FormData(),
//as S3 encoding key are directly inserted within the FormData(),
//use of XHRwrapper function ain't pertinent
//use of XHRwrapper function ain't pertinent
var
doc
,
doc_id
,
mime
;
var
doc
,
doc_id
,
mime
;
doc
=
command
.
cloneDoc
();
doc
=
metadata
;
doc_id
=
command
.
getDocId
();
doc_id
=
doc
.
_id
;
console
.
log
(
doc
);
console
.
log
(
doc_id
);
function
postDocument
()
{
function
postDocument
()
{
var
http_response
,
fd
,
Signature
,
xhr
;
var
http_response
,
fd
,
Signature
,
xhr
;
...
@@ -534,15 +548,15 @@
...
@@ -534,15 +548,15 @@
priv
.
contenTType
=
"
text/plain
"
;
priv
.
contenTType
=
"
text/plain
"
;
fd
.
append
(
'
Content-Type
'
,
priv
.
contenTType
);
fd
.
append
(
'
Content-Type
'
,
priv
.
contenTType
);
//allows specification of a success url redirection
//allows specification of a success url redirection
fd
.
append
(
'
success_action_redirect
'
,
''
);
//
fd.append('success_action_redirect', '');
//allows to specify the http code response if the request is successful
//allows to specify the http code response if the request is successful
fd
.
append
(
'
success_action_status
'
,
http_response
);
//
fd.append('success_action_status', http_response);
//login AWS
//login AWS
fd
.
append
(
'
AWSAccessKeyId
'
,
priv
.
AWSIdentifier
);
fd
.
append
(
'
AWSAccessKeyId
'
,
priv
.
AWSIdentifier
);
//exchange policy with the amazon s3 service
//exchange policy with the amazon s3 service
//can be common to all uploads or specific
//can be common to all uploads or specific
//that.encodePolicy(fd);
that
.
encodePolicy
(
fd
);
that
.
encodePolicy
(
fd
);
//priv.b64_policy = that.encodePolicy(fd);
fd
.
append
(
'
policy
'
,
priv
.
b64_policy
);
fd
.
append
(
'
policy
'
,
priv
.
b64_policy
);
//signature through the base64.hmac.sha1(secret key, policy) method
//signature through the base64.hmac.sha1(secret key, policy) method
Signature
=
b64_hmac_sha1
(
priv
.
password
,
priv
.
b64_policy
);
Signature
=
b64_hmac_sha1
(
priv
.
password
,
priv
.
b64_policy
);
...
@@ -610,7 +624,12 @@
...
@@ -610,7 +624,12 @@
mime
=
'
text/plain; charset=UTF-8
'
;
mime
=
'
text/plain; charset=UTF-8
'
;
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
isJIO
,
false
,
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
isJIO
,
false
,
function
(
response
)
{
function
(
response
)
{
lastDigest
=
JSON
.
parse
(
response
)[
"
_attachments
"
][
param
.
_attachment
][
'
digest
'
];
var
responseObj
=
JSON
.
parse
(
response
)[
"
_attachments
"
];
if
(
responseObj
!==
undefined
){
if
(
responseObj
[
param
.
_attachment
]
!==
undefined
){
lastDigest
=
JSON
.
parse
(
response
)[
"
_attachments
"
][
param
.
_attachment
][
'
digest
'
];
}
}
getTheAttachment
();
getTheAttachment
();
});
});
}
}
...
@@ -654,10 +673,12 @@
...
@@ -654,10 +673,12 @@
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
false
,
false
,
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
false
,
false
,
function
(
response
)
{
function
(
response
)
{
//if (response === '404') {}
var
responseObj
=
JSON
.
parse
(
response
);
if
(
response
.
_attachments
!==
undefined
)
{
doc
.
_attachments
=
response
.
_attachments
;
if
(
responseObj
.
_attachments
!==
undefined
)
{
doc
.
_attachments
=
responseObj
.
_attachments
;
}
}
putDocument
();
putDocument
();
//TODO : control non existing document to throw a 201 http code
//TODO : control non existing document to throw a 201 http code
}
}
...
@@ -682,7 +703,6 @@
...
@@ -682,7 +703,6 @@
attachment_id
=
param
.
_attachment
;
attachment_id
=
param
.
_attachment
;
attachment_data
=
param
.
_blob
;
attachment_data
=
param
.
_blob
;
console
.
log
(
param
.
_blob
);
jIO
.
util
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
e
)
{
jIO
.
util
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
e
)
{
var
binary_string
=
e
.
target
.
result
;
var
binary_string
=
e
.
target
.
result
;
...
@@ -708,12 +728,16 @@
...
@@ -708,12 +728,16 @@
function
putDocument
()
{
function
putDocument
()
{
var
attachment_obj
,
data
,
doc
;
var
attachment_obj
,
data
,
doc
;
attachment_mimetype
=
param
.
_blob
.
type
;
attachment_length
=
param
.
_blob
.
size
;
attachment_obj
=
{
attachment_obj
=
{
//"revpos": 3, // optional
//"revpos": 3, // optional
"
digest
"
:
attachment_digest
,
"
digest
"
:
attachment_digest
,
"
content_type
"
:
attachment_mimetype
,
"
content_type
"
:
attachment_mimetype
,
"
length
"
:
attachment_length
"
length
"
:
attachment_length
};
};
data
=
JSON
.
parse
(
my_document
);
data
=
JSON
.
parse
(
my_document
);
doc
=
priv
.
updateMeta
(
data
,
docId
,
attachId
,
"
add
"
,
attachment_obj
);
doc
=
priv
.
updateMeta
(
data
,
docId
,
attachId
,
"
add
"
,
attachment_obj
);
...
@@ -750,12 +774,13 @@
...
@@ -750,12 +774,13 @@
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
remove
=
function
(
command
)
{
that
.
remove
=
function
(
command
,
param
,
options
)
{
var
docId
,
mime
;
var
docId
,
mime
;
docId
=
command
.
getDocId
()
;
docId
=
param
.
_id
;
mime
=
'
text/plain; charset=UTF-8
'
;
mime
=
'
text/plain; charset=UTF-8
'
;
isDelete
=
true
;
function
deleteDocument
()
{
function
deleteDocument
()
{
isDelete
=
false
;
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
DELETE
'
,
mime
,
''
,
true
,
false
,
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
DELETE
'
,
mime
,
''
,
true
,
false
,
function
(
reponse
)
{
function
(
reponse
)
{
command
.
success
({
command
.
success
({
...
@@ -794,7 +819,7 @@
...
@@ -794,7 +819,7 @@
);
);
};
};
that
.
removeAttachment
=
function
(
command
)
{
that
.
removeAttachment
=
function
(
command
,
param
,
options
)
{
var
my_document
,
var
my_document
,
docId
,
docId
,
attachId
,
attachId
,
...
@@ -806,16 +831,16 @@
...
@@ -806,16 +831,16 @@
attachment_length
;
attachment_length
;
my_document
=
null
;
my_document
=
null
;
docId
=
command
.
getDocId
()
;
docId
=
param
.
_id
;
attachId
=
command
.
getAttachmentId
()
||
''
;
attachId
=
param
.
_attachment
;
mime
=
'
text/plain; charset=UTF-8
'
;
mime
=
'
text/plain; charset=UTF-8
'
;
//récupération des variables de l'attachement
//récupération des variables de l'attachement
attachment_id
=
command
.
getAttachmentId
();
//
attachment_id = command.getAttachmentId();
attachment_data
=
command
.
getAttachmentData
();
//
attachment_data = command.getAttachmentData();
attachment_md5
=
command
.
md5SumAttachmentData
();
//
attachment_md5 = command.md5SumAttachmentData();
attachment_mimetype
=
command
.
getAttachmentMimeType
();
//
attachment_mimetype = command.getAttachmentMimeType();
attachment_length
=
command
.
getAttachmentLength
();
//
attachment_length = command.getAttachmentLength();
function
removeAttachment
()
{
function
removeAttachment
()
{
that
.
XHRwrapper
(
command
,
docId
,
attachId
,
'
DELETE
'
,
mime
,
''
,
true
,
that
.
XHRwrapper
(
command
,
docId
,
attachId
,
'
DELETE
'
,
mime
,
''
,
true
,
...
@@ -837,9 +862,17 @@
...
@@ -837,9 +862,17 @@
function
getDocument
()
{
function
getDocument
()
{
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
false
,
false
,
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
false
,
false
,
function
(
reponse
)
{
function
(
response
)
{
my_document
=
reponse
;
my_document
=
response
;
putDocument
();
if
(
JSON
.
parse
(
my_document
).
_attachments
[
attachId
]
!==
undefined
){
putDocument
();
}
else
{
return
command
.
error
(
404
,
"
missing attachment
"
,
"
This Attachment does not exist
"
);
}
}
}
);
);
}
}
...
...
test/jio.storage/s3storage.tests.js
View file @
74f6eb98
...
@@ -71,12 +71,13 @@
...
@@ -71,12 +71,13 @@
"
id
"
:
"
<uuid>
"
,
"
id
"
:
"
<uuid>
"
,
"
method
"
:
"
post
"
,
"
method
"
:
"
post
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
1
,
"
status
"
:
20
4
,
"
statusText
"
:
"
Created
"
"
statusText
"
:
"
No Content
"
},
"
Post a new document
"
);
},
"
Post a new document
"
);
ok
(
test_util
.
isUuid
(
uuid
),
"
New document id should look like
"
+
ok
(
/^no_document_id_
[
0-9
]
+$/
.
test
(
uuid
),
"
New document id should look like
"
+
"
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
:
"
+
uuid
);
"
no_document_id_479658600408584
:
"
+
uuid
);
shared
.
created_document_id
=
uuid
;
shared
.
created_document_id
=
uuid
;
}
}
function
getCreatedDocument
()
{
function
getCreatedDocument
()
{
...
@@ -114,8 +115,8 @@
...
@@ -114,8 +115,8 @@
"
id
"
:
"
b
"
,
"
id
"
:
"
b
"
,
"
method
"
:
"
post
"
,
"
method
"
:
"
post
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
1
,
"
status
"
:
20
4
,
"
statusText
"
:
"
Created
"
"
statusText
"
:
"
No Content
"
},
"
Post specific document
"
);
},
"
Post specific document
"
);
}
}
...
@@ -380,9 +381,9 @@
...
@@ -380,9 +381,9 @@
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
error
"
:
"
conflict
"
,
"
error
"
:
"
conflict
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, cannot overwrite document metadata.
"
,
"
message
"
:
"
Cannot create document
"
,
"
method
"
:
"
post
"
,
"
method
"
:
"
post
"
,
"
reason
"
:
"
Document exists
"
,
"
reason
"
:
"
Document
already
exists
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
"
status
"
:
409
,
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
"
statusText
"
:
"
Conflict
"
...
@@ -409,8 +410,8 @@
...
@@ -409,8 +410,8 @@
function
createAttachmentTest
(
answer
)
{
function
createAttachmentTest
(
answer
)
{
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
attachment
"
:
"
aa
"
,
"
digest
"
:
"
sha256-9834876dcfb05cb167a5c24953eba58c4
"
+
"
digest
"
:
"
sha256-9834876dcfb05cb167a5c24953eba58c4
"
+
"
ac89b1adf57f28f2f9d09af107ee8f0
"
,
"
ac89b1adf57f28f2f9d09af107ee8f0
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
putAttachment
"
,
"
method
"
:
"
putAttachment
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
...
@@ -428,8 +429,8 @@
...
@@ -428,8 +429,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-
9834876dcfb05cb167a5c24953eba58c4
"
+
"
digest
"
:
"
sha256-
38760eabb666e8e61ee628a17c4090cc5
"
+
"
ac89b1adf57f28f2f9d09af107ee8f0
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
}
}
}
}
...
@@ -447,8 +448,8 @@
...
@@ -447,8 +448,8 @@
function
updateAttachmentTest
(
answer
)
{
function
updateAttachmentTest
(
answer
)
{
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
attachment
"
:
"
aa
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
putAttachment
"
,
"
method
"
:
"
putAttachment
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
...
@@ -466,8 +467,8 @@
...
@@ -466,8 +467,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
}
}
}
}
...
@@ -504,8 +505,8 @@
...
@@ -504,8 +505,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -525,8 +526,8 @@
...
@@ -525,8 +526,8 @@
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
put
"
,
"
method
"
:
"
put
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
20
4
,
"
status
"
:
20
0
,
"
statusText
"
:
"
No Content
"
"
statusText
"
:
"
Ok
"
},
"
Update document metadata
"
);
},
"
Update document metadata
"
);
}
}
...
@@ -539,8 +540,8 @@
...
@@ -539,8 +540,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -563,8 +564,8 @@
...
@@ -563,8 +564,8 @@
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
attachment
"
:
"
aa
"
,
"
data
"
:
"
<blob>
"
,
"
data
"
:
"
<blob>
"
,
"
digest
"
:
"
sha256-
9834876dcfb05cb167a5c24953eba58c4
"
+
"
digest
"
:
"
sha256-
38760eabb666e8e61ee628a17c4090cc5
"
+
"
ac89b1adf57f28f2f9d09af107ee8f0
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
getAttachment
"
,
"
method
"
:
"
getAttachment
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
...
@@ -573,7 +574,7 @@
...
@@ -573,7 +574,7 @@
},
"
Get first attachment
"
);
},
"
Get first attachment
"
);
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
e
.
target
.
result
,
"
aa
a
"
,
"
Check blob text content
"
);
deepEqual
(
e
.
target
.
result
,
"
aa
b
"
,
"
Check blob text content
"
);
},
function
(
err
)
{
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
});
...
@@ -588,8 +589,8 @@
...
@@ -588,8 +589,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -637,8 +638,8 @@
...
@@ -637,8 +638,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -660,8 +661,8 @@
...
@@ -660,8 +661,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -689,8 +690,8 @@
...
@@ -689,8 +690,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
},
},
"
ab
"
:
{
"
ab
"
:
{
...
@@ -726,8 +727,8 @@
...
@@ -726,8 +727,8 @@
"
_attachments
"
:
{
"
_attachments
"
:
{
"
aa
"
:
{
"
aa
"
:
{
"
content_type
"
:
"
text/plain
"
,
"
content_type
"
:
"
text/plain
"
,
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
digest
"
:
"
sha256-38760eabb666e8e61ee628a17c4090cc5
"
+
"
0728e095ff24218119d51bd22475363
"
,
"
0728e095ff24218119d51bd22475363
"
,
"
length
"
:
3
"
length
"
:
3
}
}
}
}
...
@@ -740,9 +741,9 @@
...
@@ -740,9 +741,9 @@
"
attachment
"
:
"
ab
"
,
"
attachment
"
:
"
ab
"
,
"
error
"
:
"
not_found
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, unable to get attachment.
"
,
"
message
"
:
"
File does not exist
"
,
"
method
"
:
"
getAttachment
"
,
"
method
"
:
"
getAttachment
"
,
"
reason
"
:
"
missing attachment
"
,
"
reason
"
:
"
Not Found
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
"
statusText
"
:
"
Not Found
"
...
@@ -812,7 +813,7 @@
...
@@ -812,7 +813,7 @@
"
attachment
"
:
"
ab
"
,
"
attachment
"
:
"
ab
"
,
"
error
"
:
"
not_found
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, document attachment not found.
"
,
"
message
"
:
"
This Attachment does not exist
"
,
"
method
"
:
"
removeAttachment
"
,
"
method
"
:
"
removeAttachment
"
,
"
reason
"
:
"
missing attachment
"
,
"
reason
"
:
"
missing attachment
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
...
@@ -861,9 +862,9 @@
...
@@ -861,9 +862,9 @@
"
attachment
"
:
"
aa
"
,
"
attachment
"
:
"
aa
"
,
"
error
"
:
"
not_found
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, unable to get attachment.
"
,
"
message
"
:
"
File does not exist
"
,
"
method
"
:
"
getAttachment
"
,
"
method
"
:
"
getAttachment
"
,
"
reason
"
:
"
missing document
"
,
"
reason
"
:
"
Not Found
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
"
statusText
"
:
"
Not Found
"
...
@@ -879,7 +880,7 @@
...
@@ -879,7 +880,7 @@
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
error
"
:
"
not_found
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, unable to get document.
"
,
"
message
"
:
"
File does not exist
"
,
"
method
"
:
"
get
"
,
"
method
"
:
"
get
"
,
"
reason
"
:
"
Not Found
"
,
"
reason
"
:
"
Not Found
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
...
@@ -897,7 +898,7 @@
...
@@ -897,7 +898,7 @@
deepEqual
(
answer
,
{
deepEqual
(
answer
,
{
"
error
"
:
"
not_found
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
DavStorage, unable to get metadata.
"
,
"
message
"
:
"
File does not exist
"
,
"
method
"
:
"
remove
"
,
"
method
"
:
"
remove
"
,
"
reason
"
:
"
Not Found
"
,
"
reason
"
:
"
Not Found
"
,
"
result
"
:
"
error
"
,
"
result
"
:
"
error
"
,
...
@@ -919,57 +920,57 @@
...
@@ -919,57 +920,57 @@
// # Post new documents, list them and remove them
// # Post new documents, list them and remove them
// post a 201
// post a 201
//
postNewDocument().then(postNewDocumentTest).
postNewDocument
().
then
(
postNewDocumentTest
).
// get 200
// get 200
//
then(getCreatedDocument).then(getCreatedDocumentTest).
then
(
getCreatedDocument
).
then
(
getCreatedDocumentTest
).
// post b 201
// post b 201
//
then(postSpecificDocument).then(postSpecificDocumentTest).
then
(
postSpecificDocument
).
then
(
postSpecificDocumentTest
).
// allD 200 2 documents
// allD 200 2 documents
//
then(listDocuments).then(list2DocumentsTest).
then
(
listDocuments
).
then
(
list2DocumentsTest
).
// remove a 204
// remove a 204
//
then(removeCreatedDocument).then(removeCreatedDocumentTest).
then
(
removeCreatedDocument
).
then
(
removeCreatedDocumentTest
).
// remove b 204
// remove b 204
//
then(removeSpecificDocument).then(removeSpecificDocumentTest).
then
(
removeSpecificDocument
).
then
(
removeSpecificDocumentTest
).
// allD 200 empty storage
// allD 200 empty storage
//
then(listEmptyStorage).then(listEmptyStorageTest).
then
(
listEmptyStorage
).
then
(
listEmptyStorageTest
).
// # Create and update documents, and some attachment and remove them
// # Create and update documents, and some attachment and remove them
// put 201
// put 201
putNewDocument
(
).
then
(
putNewDocumentTest
).
then
(
putNewDocument
).
then
(
putNewDocumentTest
).
// get 200
// get 200
then
(
getCreatedDocument2
).
then
(
getCreatedDocument2Test
).
then
(
getCreatedDocument2
).
then
(
getCreatedDocument2Test
).
// post 409
// post 409
//
then(postSameDocument).then(postSameDocumentTest).
then
(
postSameDocument
).
then
(
postSameDocumentTest
).
// putA a 204
// putA a 204
then
(
createAttachment
).
then
(
createAttachmentTest
).
then
(
createAttachment
).
then
(
createAttachmentTest
).
// putA a 204
// putA a 204
//
then(updateAttachment).then(updateAttachmentTest).
then
(
updateAttachment
).
then
(
updateAttachmentTest
).
// putA b 204
// putA b 204
//
then(createAnotherAttachment).then(createAnotherAttachmentTest).
then
(
createAnotherAttachment
).
then
(
createAnotherAttachmentTest
).
// put 204
// put 204
//
then(updateLastDocument).then(updateLastDocumentTest).
then
(
updateLastDocument
).
then
(
updateLastDocumentTest
).
// getA a 200
// getA a 200
then
(
getFirstAttachment
).
then
(
getFirstAttachmentTest
).
then
(
getFirstAttachment
).
then
(
getFirstAttachmentTest
).
// getA b 200
// getA b 200
//
then(getSecondAttachment).then(getSecondAttachmentTest).
then
(
getSecondAttachment
).
then
(
getSecondAttachmentTest
).
// get 200
// get 200
//
then(getLastDocument).then(getLastDocumentTest).
then
(
getLastDocument
).
then
(
getLastDocumentTest
).
// removeA b 204
// removeA b 204
//
then(removeSecondAttachment).then(removeSecondAttachmentTest).
then
(
removeSecondAttachment
).
then
(
removeSecondAttachmentTest
).
// getA b 404
// getA b 404
//
then(getInexistentSecondAttachment).
then
(
getInexistentSecondAttachment
).
//
then(getInexistentSecondAttachmentTest).
then
(
getInexistentSecondAttachmentTest
).
// get 200
// get 200
//
then(getOneAttachmentDocument).then(getOneAttachmentDocumentTest).
then
(
getOneAttachmentDocument
).
then
(
getOneAttachmentDocumentTest
).
// removeA b 404
// removeA b 404
//
then(removeSecondAttachmentAgain).then(removeSecondAttachmentAgainTest).
then
(
removeSecondAttachmentAgain
).
then
(
removeSecondAttachmentAgainTest
).
// remove 204
// remove 204
//
then(removeDocument).then(removeDocumentTest).
then
(
removeDocument
).
then
(
removeDocumentTest
).
// getA a 404
// getA a 404
//
then(getInexistentFirstAttachment).then(getInexistentFirstAttachmentTest).
then
(
getInexistentFirstAttachment
).
then
(
getInexistentFirstAttachmentTest
).
// get 404
// get 404
//
then(getInexistentDocument).then(getInexistentDocumentTest).
then
(
getInexistentDocument
).
then
(
getInexistentDocumentTest
).
// remove 404
// remove 404
//
then(removeInexistentDocument).then(removeInexistentDocumentTest).
then
(
removeInexistentDocument
).
then
(
removeInexistentDocumentTest
).
// check 204
// check 204
//then(checkDocument).done(checkDocumentTest).
//then(checkDocument).done(checkDocumentTest).
//then(checkStorage).done(checkStorageTest).
//then(checkStorage).done(checkStorageTest).
...
...
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