Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
4428686a
Commit
4428686a
authored
Feb 18, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DavStorage tests
parent
e81183d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
845 additions
and
1772 deletions
+845
-1772
src/jio.storage/davstorage.js
src/jio.storage/davstorage.js
+33
-35
test/jio.storage/davstorage.tests.js
test/jio.storage/davstorage.tests.js
+810
-1735
test/tests.html
test/tests.html
+2
-2
No files found.
src/jio.storage/davstorage.js
View file @
4428686a
...
@@ -5,15 +5,9 @@
...
@@ -5,15 +5,9 @@
*/
*/
/*jslint nomen: true*/
/*jslint nomen: true*/
/*global
window, jIO, RSVP, btoa, DOMParser, Blob, console
*/
/*global
jIO, RSVP, DOMParser, Blob
*/
// JIO Dav Storage Description :
// JIO Dav Storage Description :
// {
// type: "dav",
// url: {string}
// // No Authentication Here
// }
// {
// {
// type: "dav",
// type: "dav",
// url: {string},
// url: {string},
...
@@ -24,7 +18,7 @@
...
@@ -24,7 +18,7 @@
// curl --verbose -X OPTION http://domain/
// curl --verbose -X OPTION http://domain/
// In the headers: "WWW-Authenticate: Basic realm="DAV-upload"
// In the headers: "WWW-Authenticate: Basic realm="DAV-upload"
(
function
(
jIO
)
{
(
function
(
jIO
,
RSVP
,
DOMParser
,
Blob
)
{
"
use strict
"
;
"
use strict
"
;
function
ajax
(
storage
,
options
)
{
function
ajax
(
storage
,
options
)
{
...
@@ -79,23 +73,33 @@
...
@@ -79,23 +73,33 @@
if
(
typeof
spec
.
url
!==
'
string
'
)
{
if
(
typeof
spec
.
url
!==
'
string
'
)
{
throw
new
TypeError
(
"
DavStorage 'url' is not of type string
"
);
throw
new
TypeError
(
"
DavStorage 'url' is not of type string
"
);
}
}
// Remove last slash
this
.
_url
=
spec
.
url
;
this
.
_url
=
spec
.
url
.
replace
(
/
\/
$/
,
''
);
// XXX digest login
// XXX digest login
if
(
typeof
spec
.
basic_login
===
'
string
'
)
{
if
(
typeof
spec
.
basic_login
===
'
string
'
)
{
// this._auth_type = 'basic';
this
.
_authorization
=
"
Basic
"
+
spec
.
basic_login
;
this
.
_authorization
=
"
Basic
"
+
spec
.
basic_login
;
// } else {
// this._auth_type = 'none';
}
}
}
}
DavStorage
.
prototype
.
put
=
function
(
param
)
{
DavStorage
.
prototype
.
put
=
function
(
param
)
{
// XXX Reject if param has other properties than _id
var
id
=
restrictDocumentId
(
param
.
_id
);
delete
param
.
_id
;
if
(
Object
.
getOwnPropertyNames
(
param
).
length
>
0
)
{
// Reject if param has other properties than _id
throw
new
jIO
.
util
.
jIOError
(
"
Can not store properties:
"
+
Object
.
getOwnPropertyNames
(
param
),
400
);
}
return
ajax
(
this
,
{
return
ajax
(
this
,
{
type
:
"
MKCOL
"
,
type
:
"
MKCOL
"
,
url
:
this
.
_url
+
param
.
_id
url
:
this
.
_url
+
id
});
};
DavStorage
.
prototype
.
remove
=
function
(
param
)
{
var
id
=
restrictDocumentId
(
param
.
_id
);
return
ajax
(
this
,
{
type
:
"
DELETE
"
,
url
:
this
.
_url
+
id
});
});
};
};
...
@@ -111,6 +115,7 @@
...
@@ -111,6 +115,7 @@
url
:
context
.
_url
+
id
,
url
:
context
.
_url
+
id
,
dataType
:
"
text
"
,
dataType
:
"
text
"
,
headers
:
{
headers
:
{
// Increasing this value is a performance killer
Depth
:
"
1
"
Depth
:
"
1
"
}
}
});
});
...
@@ -121,9 +126,7 @@
...
@@ -121,9 +126,7 @@
// Extract all meta informations and return them to JSON
// Extract all meta informations and return them to JSON
var
i
,
var
i
,
result
=
{
result
=
{},
"
title
"
:
param
.
_id
},
attachment
=
{},
attachment
=
{},
id
,
id
,
attachment_list
=
new
DOMParser
().
parseFromString
(
attachment_list
=
new
DOMParser
().
parseFromString
(
...
@@ -143,7 +146,7 @@
...
@@ -143,7 +146,7 @@
attachment
[
id
]
=
{};
attachment
[
id
]
=
{};
}
}
}
}
if
(
attachment
.
length
!==
0
)
{
if
(
Object
.
getOwnPropertyNames
(
attachment
).
length
>
0
)
{
result
.
_attachments
=
attachment
;
result
.
_attachments
=
attachment
;
}
}
return
result
;
return
result
;
...
@@ -162,20 +165,11 @@
...
@@ -162,20 +165,11 @@
DavStorage
.
prototype
.
putAttachment
=
function
(
param
)
{
DavStorage
.
prototype
.
putAttachment
=
function
(
param
)
{
var
id
=
restrictDocumentId
(
param
.
_id
);
var
id
=
restrictDocumentId
(
param
.
_id
);
restrictAttachmentId
(
param
.
_attachment
);
restrictAttachmentId
(
param
.
_attachment
);
return
ajax
(
this
,
{
return
ajax
(
this
,
{
type
:
"
PUT
"
,
type
:
"
PUT
"
,
url
:
this
.
_url
+
id
+
param
.
_attachment
,
url
:
this
.
_url
+
id
+
param
.
_attachment
,
data
:
param
.
_blob
data
:
param
.
_blob
})
});
.
push
(
undefined
,
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
403
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
}
throw
error
;
});
};
};
DavStorage
.
prototype
.
getAttachment
=
function
(
param
)
{
DavStorage
.
prototype
.
getAttachment
=
function
(
param
)
{
...
@@ -192,15 +186,17 @@
...
@@ -192,15 +186,17 @@
});
});
})
})
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
return
new
Blob
(
return
{
data
:
new
Blob
(
[
response
.
target
.
response
],
[
response
.
target
.
response
||
response
.
target
.
responseText
],
{
"
type
"
:
response
.
target
.
getResponseHeader
(
'
Content-Type
'
)
||
{
"
type
"
:
response
.
target
.
getResponseHeader
(
'
Content-Type
'
)
||
"
application/octet-stream
"
}
"
application/octet-stream
"
}
);
)
}
;
},
function
(
error
)
{
},
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
(
error
.
target
.
status
===
404
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment:
"
+
param
.
_id
+
"
,
"
+
param
.
_attachment
,
404
);
}
}
throw
error
;
throw
error
;
});
});
...
@@ -222,7 +218,9 @@
...
@@ -222,7 +218,9 @@
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
(
error
.
target
.
status
===
404
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment:
"
+
param
.
_id
+
"
,
"
+
param
.
_attachment
,
404
);
}
}
throw
error
;
throw
error
;
});
});
...
@@ -257,4 +255,4 @@
...
@@ -257,4 +255,4 @@
jIO
.
addStorage
(
'
dav
'
,
DavStorage
);
jIO
.
addStorage
(
'
dav
'
,
DavStorage
);
}(
jIO
));
}(
jIO
,
RSVP
,
DOMParser
,
Blob
));
test/jio.storage/davstorage.tests.js
View file @
4428686a
/*jslint
maxlen: 120,
nomen: true */
/*jslint nomen: true */
/*global
localStorage, test_util, console,
Blob, sinon*/
/*global Blob, sinon*/
(
function
(
jIO
,
QUnit
,
sinon
)
{
(
function
(
jIO
,
QUnit
,
Blob
,
sinon
)
{
"
use strict
"
;
"
use strict
"
;
var
test
=
QUnit
.
test
,
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
stop
=
QUnit
.
stop
,
...
@@ -10,9 +10,41 @@
...
@@ -10,9 +10,41 @@
deepEqual
=
QUnit
.
deepEqual
,
deepEqual
=
QUnit
.
deepEqual
,
equal
=
QUnit
.
equal
,
equal
=
QUnit
.
equal
,
module
=
QUnit
.
module
,
module
=
QUnit
.
module
,
domain
=
"
https://example.org
"
;
domain
=
"
https://example.org
"
,
basic_login
=
"
login:passwd
"
;
module
(
"
davStorage
"
,
{
/////////////////////////////////////////////////////////////////
// davStorage constructor
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.constructor
"
);
test
(
"
Storage store URL
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
});
equal
(
jio
.
__type
,
"
dav
"
);
deepEqual
(
jio
.
__storage
.
_url
,
domain
);
deepEqual
(
jio
.
__storage
.
_authorization
,
undefined
);
});
test
(
"
Storage store basic login
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
equal
(
jio
.
__type
,
"
dav
"
);
deepEqual
(
jio
.
__storage
.
_url
,
domain
);
deepEqual
(
jio
.
__storage
.
_authorization
,
"
Basic login:passwd
"
);
});
/////////////////////////////////////////////////////////////////
// davStorage.put
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.put
"
,
{
setup
:
function
()
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
=
sinon
.
fakeServer
.
create
();
...
@@ -21,8 +53,8 @@
...
@@ -21,8 +53,8 @@
this
.
jio
=
jIO
.
createJIO
({
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
type
:
"
dav
"
,
url
:
domain
url
:
domain
,
// "none"
basic_login
:
basic_login
});
});
},
},
teardown
:
function
()
{
teardown
:
function
()
{
...
@@ -31,21 +63,249 @@
...
@@ -31,21 +63,249 @@
}
}
});
});
test
(
"
put document
"
,
function
()
{
var
url
=
domain
+
"
/put1/
"
,
server
=
this
.
server
;
this
.
server
.
respondWith
(
"
MKCOL
"
,
url
,
[
201
,
{
"
Content-Type
"
:
"
text/xml
"
},
""
]);
stop
();
expect
(
7
);
this
.
jio
.
put
({
"
_id
"
:
"
/put1/
"
})
.
then
(
function
()
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
MKCOL
"
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
status
,
201
);
equal
(
server
.
requests
[
0
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
0
].
responseText
,
""
);
deepEqual
(
server
.
requests
[
0
].
requestHeaders
,
{
Authorization
:
"
Basic login:passwd
"
,
"
Content-Type
"
:
"
text/plain;charset=utf-8
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
put
({
"
_id
"
:
"
put1/
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id put1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
put
({
"
_id
"
:
"
/put1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id /put1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject to store any property
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
put
({
"
_id
"
:
"
/put1/
"
,
title
:
"
foo
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Can not store properties: title
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// davStorage.remove
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.remove
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
remove document
"
,
function
()
{
var
url
=
domain
+
"
/remove1/
"
,
server
=
this
.
server
;
this
.
server
.
respondWith
(
"
DELETE
"
,
url
,
[
204
,
{
"
Content-Type
"
:
"
text/xml
"
},
""
]);
stop
();
expect
(
7
);
this
.
jio
.
remove
({
"
_id
"
:
"
/remove1/
"
})
.
then
(
function
()
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
DELETE
"
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
status
,
204
);
equal
(
server
.
requests
[
0
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
0
].
responseText
,
""
);
deepEqual
(
server
.
requests
[
0
].
requestHeaders
,
{
Authorization
:
"
Basic login:passwd
"
,
"
Content-Type
"
:
"
text/plain;charset=utf-8
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
remove
({
"
_id
"
:
"
remove1/
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id remove1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
remove
({
"
_id
"
:
"
/remove1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id /remove1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// davStorage.get
// davStorage.get
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.get
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
get
({
"
_id
"
:
"
get1/
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id get1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
get
({
"
_id
"
:
"
/get1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id /get1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
get inexistent document
"
,
function
()
{
test
(
"
get inexistent document
"
,
function
()
{
var
url
=
domain
+
"
/inexistent
"
;
var
url
=
domain
+
"
/inexistent
/
"
;
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
404
,
{
this
.
server
.
respondWith
(
"
PROPFIND
"
,
url
,
[
404
,
{
"
Content-Type
"
:
"
text/html
"
"
Content-Type
"
:
"
text/html
"
},
"
foo
"
]);
},
"
foo
"
]);
stop
();
stop
();
expect
(
3
);
expect
(
3
);
this
.
jio
.
get
({
"
_id
"
:
"
inexistent
"
})
this
.
jio
.
get
({
"
_id
"
:
"
/inexistent/
"
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document
"
);
equal
(
error
.
message
,
"
Cannot find document
"
);
equal
(
error
.
status_code
,
404
);
equal
(
error
.
status_code
,
404
);
...
@@ -58,12 +318,144 @@
...
@@ -58,12 +318,144 @@
});
});
});
});
test
(
"
get document
"
,
function
()
{
test
(
"
get document without attachment
"
,
function
()
{
var
id
=
"
post1
"
,
var
id
=
"
/id1/
"
;
url
=
domain
+
"
/
"
+
id
;
this
.
server
.
respondWith
(
"
PROPFIND
"
,
domain
+
id
,
[
200
,
{
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
200
,
{
"
Content-Type
"
:
"
text/xml
"
"
Content-Type
"
:
"
octet/stream
"
},
'
<?xml version="1.0" encoding="utf-8"?>
'
+
},
JSON
.
stringify
({
title
:
"
myPost1
"
})
'
<D:multistatus xmlns:D="DAV:">
'
+
'
<D:response xmlns:lp1="DAV:"
'
+
'
xmlns:lp2="http://apache.org/dav/props/">
'
+
'
<D:href>/uploads/</D:href>
'
+
'
<D:propstat>
'
+
'
<D:prop>
'
+
'
<lp1:resourcetype><D:collection/></lp1:resourcetype>
'
+
'
<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>
'
+
'
<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT
'
+
'
</lp1:getlastmodified>
'
+
'
<lp1:getetag>"240be-1000-4e9f88a305c4e"</lp1:getetag>
'
+
'
<D:supportedlock>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:exclusive/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:shared/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
</D:supportedlock>
'
+
'
<D:lockdiscovery/>
'
+
'
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
'
+
'
</D:prop>
'
+
'
<D:status>HTTP/1.1 200 OK</D:status>
'
+
'
</D:propstat>
'
+
'
</D:response>
'
+
'
</D:multistatus>
'
]);
stop
();
expect
(
1
);
this
.
jio
.
get
({
"
_id
"
:
id
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
"
_id
"
:
id
},
"
Check document
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
get document with attachment
"
,
function
()
{
var
id
=
"
/id1/
"
;
this
.
server
.
respondWith
(
"
PROPFIND
"
,
domain
+
id
,
[
200
,
{
"
Content-Type
"
:
"
text/xml
"
},
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<D:multistatus xmlns:D="DAV:">
'
+
'
<D:response xmlns:lp1="DAV:"
'
+
'
xmlns:lp2="http://apache.org/dav/props/">
'
+
'
<D:href>/uploads/</D:href>
'
+
'
<D:propstat>
'
+
'
<D:prop>
'
+
'
<lp1:resourcetype><D:collection/></lp1:resourcetype>
'
+
'
<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>
'
+
'
<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT
'
+
'
</lp1:getlastmodified>
'
+
'
<lp1:getetag>"240be-1000-4e9f88a305c4e"</lp1:getetag>
'
+
'
<D:supportedlock>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:exclusive/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:shared/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
</D:supportedlock>
'
+
'
<D:lockdiscovery/>
'
+
'
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
'
+
'
</D:prop>
'
+
'
<D:status>HTTP/1.1 200 OK</D:status>
'
+
'
</D:propstat>
'
+
'
</D:response>
'
+
'
<D:response xmlns:lp1="DAV:"
'
+
'
xmlns:lp2="http://apache.org/dav/props/">
'
+
'
<D:href>/uploads/attachment1</D:href>
'
+
'
<D:propstat>
'
+
'
<D:prop>
'
+
'
<lp1:resourcetype/>
'
+
'
<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>
'
+
'
<lp1:getcontentlength>66</lp1:getcontentlength>
'
+
'
<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT
'
+
'
</lp1:getlastmodified>
'
+
'
<lp1:getetag>"20568-42-4e9f88a2ea198"</lp1:getetag>
'
+
'
<lp2:executable>F</lp2:executable>
'
+
'
<D:supportedlock>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:exclusive/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:shared/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
</D:supportedlock>
'
+
'
<D:lockdiscovery/>
'
+
'
</D:prop>
'
+
'
<D:status>HTTP/1.1 200 OK</D:status>
'
+
'
</D:propstat>
'
+
'
</D:response>
'
+
'
<D:response xmlns:lp1="DAV:"
'
+
'
xmlns:lp2="http://apache.org/dav/props/">
'
+
'
<D:href>/uploads/attachment2</D:href>
'
+
'
<D:propstat>
'
+
'
<D:prop>
'
+
'
<lp1:resourcetype/>
'
+
'
<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>
'
+
'
<lp1:getcontentlength>25</lp1:getcontentlength>
'
+
'
<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT
'
+
'
</lp1:getlastmodified>
'
+
'
<lp1:getetag>"21226-19-4e9f88a305c4e"</lp1:getetag>
'
+
'
<lp2:executable>F</lp2:executable>
'
+
'
<D:supportedlock>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:exclusive/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
<D:lockentry>
'
+
'
<D:lockscope><D:shared/></D:lockscope>
'
+
'
<D:locktype><D:write/></D:locktype>
'
+
'
</D:lockentry>
'
+
'
</D:supportedlock>
'
+
'
<D:lockdiscovery/>
'
+
'
</D:prop>
'
+
'
<D:status>HTTP/1.1 200 OK</D:status>
'
+
'
</D:propstat>
'
+
'
</D:response>
'
+
'
</D:multistatus>
'
]);
]);
stop
();
stop
();
expect
(
1
);
expect
(
1
);
...
@@ -71,11 +463,14 @@
...
@@ -71,11 +463,14 @@
this
.
jio
.
get
({
"
_id
"
:
id
})
this
.
jio
.
get
({
"
_id
"
:
id
})
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
deepEqual
(
result
,
{
"
title
"
:
"
myPost1
"
"
_id
"
:
id
,
"
_attachments
"
:
{
attachment1
:
{},
attachment2
:
{}
}
},
"
Check document
"
);
},
"
Check document
"
);
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
console
.
error
(
error
.
stack
);
ok
(
false
,
error
);
ok
(
false
,
error
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
...
@@ -84,29 +479,64 @@
...
@@ -84,29 +479,64 @@
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// davStorage.p
os
t
// davStorage.p
utAttachmen
t
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
test
(
"
post without id
"
,
function
()
{
module
(
"
davStorage.putAttachment
"
,
{
var
id
=
"
post1
"
,
setup
:
function
()
{
url
=
domain
+
"
/
"
+
id
;
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
200
,
{
this
.
server
=
sinon
.
fakeServer
.
create
();
"
Content-Type
"
:
"
octet/stream
"
this
.
server
.
autoRespond
=
true
;
},
JSON
.
stringify
({
title
:
"
myPost1
"
})
this
.
server
.
autoRespondAfter
=
5
;
]);
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
putAttachment
({
"
_id
"
:
"
putAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
,
"
_blob
"
:
new
Blob
([
""
])
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id putAttachment1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
expect
(
2
);
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
stop
();
expect
(
3
);
this
.
jio
.
post
({})
this
.
jio
.
putAttachment
({
// .then(function (uuid) {
"
_id
"
:
"
/putAttachment1
"
,
// ok(util.isUuid(uuid), "Uuid should look like " +
"
_attachment
"
:
"
attachment1
"
,
// "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx : " + uuid);
"
_blob
"
:
new
Blob
([
""
])
// equal(davStorage[uuid], JSON.stringify({
})
// "_id": uuid
.
fail
(
function
(
error
)
{
// }));
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
// })
equal
(
error
.
message
,
"
id /putAttachment1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
ok
(
false
,
error
);
ok
(
false
,
error
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
...
@@ -114,37 +544,329 @@
...
@@ -114,37 +544,329 @@
});
});
});
});
test
(
"
post non empty document
"
,
function
()
{
test
(
"
reject attachment with / character
"
,
function
()
{
var
id
=
"
post1
"
,
stop
();
url
=
domain
+
"
/
"
+
id
,
expect
(
3
);
this
.
jio
.
putAttachment
({
"
_id
"
:
"
/putAttachment1/
"
,
"
_attachment
"
:
"
attach/ment1
"
,
"
_blob
"
:
new
Blob
([
""
])
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
attachment attach/ment1 is forbidden
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
putAttachment document
"
,
function
()
{
var
blob
=
new
Blob
([
"
foo
"
]),
url
=
domain
+
"
/putAttachment1/attachment1
"
,
server
=
this
.
server
;
server
=
this
.
server
;
this
.
server
.
respondWith
(
"
PUT
"
,
url
,
[
200
,
{
this
.
server
.
respondWith
(
"
PUT
"
,
url
,
[
204
,
{
"
Content-Type
"
:
"
octet/stream
"
"
Content-Type
"
:
"
text/xml
"
},
JSON
.
stringify
({
title
:
"
myPost1
"
})
},
""
]);
]);
stop
();
expect
(
7
);
this
.
jio
.
putAttachment
({
"
_id
"
:
"
/putAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
,
"
_blob
"
:
blob
})
.
then
(
function
()
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
PUT
"
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
status
,
204
);
equal
(
server
.
requests
[
0
].
requestBody
,
blob
);
equal
(
server
.
requests
[
0
].
responseText
,
""
);
deepEqual
(
server
.
requests
[
0
].
requestHeaders
,
{
Authorization
:
"
Basic login:passwd
"
,
"
Content-Type
"
:
"
text/plain;charset=utf-8
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// davStorage.removeAttachment
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.removeAttachment
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
expect
(
9
);
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
stop
();
expect
(
3
);
this
.
jio
.
post
({
"
_id
"
:
"
post1
"
,
"
title
"
:
"
myPost1
"
})
this
.
jio
.
removeAttachment
({
.
then
(
function
(
uuid
)
{
"
_id
"
:
"
removeAttachment1/
"
,
console
.
log
(
server
.
requests
);
"
_attachment
"
:
"
attachment1
"
equal
(
uuid
,
"
post1
"
);
})
equal
(
server
.
requests
.
length
,
2
);
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id removeAttachment1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
removeAttachment
({
"
_id
"
:
"
/removeAttachment1
"
,
"
_attachment
"
:
"
attachment1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id /removeAttachment1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject attachment with / character
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
removeAttachment
({
"
_id
"
:
"
/removeAttachment1/
"
,
"
_attachment
"
:
"
attach/ment1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
attachment attach/ment1 is forbidden
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
removeAttachment document
"
,
function
()
{
var
url
=
domain
+
"
/removeAttachment1/attachment1
"
,
server
=
this
.
server
;
this
.
server
.
respondWith
(
"
DELETE
"
,
url
,
[
204
,
{
"
Content-Type
"
:
"
text/xml
"
},
""
]);
stop
();
expect
(
7
);
this
.
jio
.
removeAttachment
({
"
_id
"
:
"
/removeAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
})
.
then
(
function
()
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
DELETE
"
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
status
,
204
);
equal
(
server
.
requests
[
0
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
0
].
responseText
,
""
);
deepEqual
(
server
.
requests
[
0
].
requestHeaders
,
{
Authorization
:
"
Basic login:passwd
"
,
"
Content-Type
"
:
"
text/plain;charset=utf-8
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
remove inexistent attachment
"
,
function
()
{
var
url
=
domain
+
"
/removeAttachment1/attachment1
"
;
this
.
server
.
respondWith
(
"
DELETE
"
,
url
,
[
404
,
{
"
Content-Type
"
:
"
text/xml
"
},
""
]);
stop
();
expect
(
3
);
this
.
jio
.
removeAttachment
({
"
_id
"
:
"
/removeAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
})
.
then
(
function
()
{
ok
(
false
);
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find attachment: /removeAttachment1/
"
+
"
, attachment1
"
);
equal
(
error
.
status_code
,
404
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// davStorage.getAttachment
/////////////////////////////////////////////////////////////////
module
(
"
davStorage.getAttachment
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
dav
"
,
url
:
domain
,
basic_login
:
basic_login
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
reject ID not starting with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
getAttachment
({
"
_id
"
:
"
getAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id getAttachment1/ is forbidden (no begin /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject ID not ending with /
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
getAttachment
({
"
_id
"
:
"
/getAttachment1
"
,
"
_attachment
"
:
"
attachment1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
id /getAttachment1 is forbidden (no end /)
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
reject attachment with / character
"
,
function
()
{
stop
();
expect
(
3
);
this
.
jio
.
getAttachment
({
"
_id
"
:
"
/getAttachment1/
"
,
"
_attachment
"
:
"
attach/ment1
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
attachment attach/ment1 is forbidden
"
);
equal
(
error
.
status_code
,
400
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
getAttachment document
"
,
function
()
{
var
url
=
domain
+
"
/getAttachment1/attachment1
"
,
server
=
this
.
server
;
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
200
,
{
"
Content-Type
"
:
"
text/plain
"
},
"
foo
\n
baré
"
]);
stop
();
expect
(
10
);
this
.
jio
.
getAttachment
({
"
_id
"
:
"
/getAttachment1/
"
,
"
_attachment
"
:
"
attachment1
"
})
.
then
(
function
(
result
)
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
GET
"
);
equal
(
server
.
requests
[
0
].
method
,
"
GET
"
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
url
,
url
);
equal
(
server
.
requests
[
0
].
status
,
404
);
equal
(
server
.
requests
[
0
].
status
,
200
);
equal
(
server
.
requests
[
1
].
method
,
"
PUT
"
);
equal
(
server
.
requests
[
0
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
1
].
url
,
url
);
equal
(
server
.
requests
[
0
].
responseText
,
"
foo
\n
baré
"
);
equal
(
server
.
requests
[
1
].
status
,
200
);
deepEqual
(
server
.
requests
[
0
].
requestHeaders
,
{
equal
(
server
.
requests
[
1
].
requestBody
,
JSON
.
stringify
({
Authorization
:
"
Basic login:passwd
"
"
_id
"
:
"
post1
"
,
});
"
title
"
:
"
myPost1
"
}));
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
text/plain
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
})
.
then
(
function
(
result
)
{
equal
(
result
.
target
.
result
,
"
foo
\n
baré
"
,
"
Attachment correctly fetched
"
);
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
console
.
error
(
error
.
stack
);
console
.
error
(
error
);
ok
(
false
,
error
);
ok
(
false
,
error
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
...
@@ -152,1678 +874,31 @@
...
@@ -152,1678 +874,31 @@
});
});
});
});
// test("post but document already exists", function () {
test
(
"
get inexistent attachment
"
,
function
()
{
// var id = "post1";
var
url
=
domain
+
"
/getAttachment1/attachment1
"
;
// davStorage[id] = JSON.stringify({
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
404
,
{
// "_id": id,
"
Content-Type
"
:
"
text/xml
"
// title: "myPost1"
},
""
]);
// });
// expect(4);
stop
();
// stop();
expect
(
3
);
//
// this.jio.post({"_id": "post1", "title": "myPost2"})
this
.
jio
.
getAttachment
({
// .then(function (result) {
"
_id
"
:
"
/getAttachment1/
"
,
// ok(false, result);
"
_attachment
"
:
"
attachment1
"
// })
})
// .fail(function (error) {
.
then
(
function
()
{
// ok(error instanceof jIO.util.jIOError);
ok
(
false
);
// equal(error.message, "Cannot create a new document");
})
// equal(error.status_code, 409);
.
fail
(
function
(
error
)
{
//
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
// equal(davStorage.post1, JSON.stringify({
equal
(
error
.
message
,
"
Cannot find attachment: /getAttachment1/
"
+
// "_id": "post1",
"
, attachment1
"
);
// "title": "myPost1"
equal
(
error
.
status_code
,
404
);
// }));
})
// })
.
always
(
function
()
{
// .always(function () {
start
();
// start();
});
// });
});
// });
}(
jIO
,
QUnit
,
Blob
,
sinon
));
}(
jIO
,
QUnit
,
sinon
));
// /*jslint indent: 2, maxlen: 80, nomen: true */
// /*global module, test, stop, start, expect, ok, deepEqual, location, sinon,
// davstorage_spec, RSVP, jIO, test_util, dav_storage, btoa, define,
// setTimeout, clearTimeout, parseInt, console */
//
// // define([module_name], [dependencies], module);
// (function (dependencies, module) {
// "use strict";
// if (typeof define === 'function' && define.amd) {
// return define(dependencies, module);
// }
// module(test_util, RSVP, jIO, dav_storage);
// }([
// 'test_util',
// 'rsvp',
// 'jio',
// 'davstorage',
// 'qunit'
// ], function (util, RSVP, jIO, dav_storage) {
// "use strict";
//
// var spec, use_fake_server = true;
// // if (typeof davstorage_spec === 'object') {
// // use_fake_server = false;
// // spec = dav_storage.createDescription(
// // davstorage_spec.url,
// // davstorage_spec.auth_type,
// // davstorage_spec.realm,
// // davstorage_spec.username,
// // davstorage_spec.password
// // );
// // } else {
// // spec = dav_storage.createDescription(
// // "http://localhost",
// // "none"
// // );
// // }
// spec = dav_storage.createDescription(
// "http://localhost",
// "none"
// );
//
// module("Dav Storage");
//
// // function success(promise) {
// // return new RSVP.Promise(function (resolve, reject, notify) {
// // /*jslint unparam: true*/
// // promise.then(resolve, resolve, notify);
// // }, function () {
// // promise.cancel();
// // });
// // }
//
// /**
// * Tested with local webDav server
// *
// * Used header are:
// * - Header always set Cache-Control "no-cache" # "private", "public",
// * "<seconds>" or "no-store" ("no-cache")
// * - Header always set Access-Control-Max-Age "0"
// * - Header always set Access-Control-Allow-Credentials "true"
// * - Header always set Access-Control-Allow-Origin "*"
// * - Header always set Access-Control-Allow-Methods "OPTIONS, GET, HEAD,
// * POST, PUT, DELETE, PROPFIND"
// * - Header always set Access-Control-Allow-Headers "Content-Type,
// * X-Requested-With, X-HTTP-Method-Override, Accept, Authorization,
// * Depth"
// */
// test("Scenario", 48, function () {
//
// var server, responses = [], shared = {}, jio = jIO.createJIO(spec, {
// "workspace": {},
// "max_retry": 2
// });
//
// stop();
//
// if (use_fake_server) {
// /*jslint regexp: true */
// // server = sinon.fakeServer.create();
// // server.autoRespond = true;
// // server.autoRespondAfter = 5;
// // server.respondWith(/.*/, function (xhr) {
// // var response = responses.shift();
// // if (response) {
// // return xhr.respond.apply(xhr, response);
// // }
// // ok(false, "No response associated to the latest request!");
// // });
// //////////////////////////////
// // Awaiting for some sinon js improvements to manage 'blob' xhr response
// // type. This hack overrides the jIO util ajax method which is used by
// // dav storage connector to do http requests. To restore the sinon js
// // fake server, just uncomment the above lines.
// server = {restore: function () {
// return;
// }};
// jIO.util.ajax = function (param) {
// var timeout, xhr = {}, response = responses.shift(), statusTexts = {
// "404": "Not Found"
// }, start, end, str;
// if (!Array.isArray(response)) {
// setTimeout(function () {
// throw new ReferenceError("Fake server, no response set for " +
// JSON.stringify(param, null, ' '));
// });
// }
// xhr.readyState = 1;
// xhr.setRequestHeader = function () {
// return;
// };
// xhr.getResponseHeader = function (name) {
// return response[1][name];
// };
// return new RSVP.Promise(function (resolve, reject) {
// xhr.readyState = 4;
// xhr.status = response[0];
// xhr.statusText = statusTexts[response[0]];
// xhr.responseType = param.dataType || "";
// timeout = setTimeout(function () {
// /*global Blob*/
// if (xhr.responseType === 'blob') {
// if (param.headers.Range !== undefined) {
// str = param.headers.Range;
// start = parseInt(str.substring(str.indexOf("=") + 1,
// str.indexOf("-")), 10);
// if (str.indexOf("NaN") !== -1) {
// response[2] = response[2].substring(start);
// } else {
// end = parseInt(str.substring(str.indexOf("-") + 1), 10);
// response[2] = response[2].substring(start, end + 1);
// }
// }
// xhr.response = new Blob([response[2]], {
// "type": response[1]["Content-Type"] ||
// response[1]["Content-type"] ||
// response[1]["content-type"] || ''
// });
// } else if (xhr.responseType === 'json') {
// xhr.responseText = response[2];
// try {
// xhr.response = JSON.parse(xhr.responseText);
// } catch (e) { // XXX
// xhr.responseText = undefined;
// xhr.status = 0;
// xhr.statusText = "Parse Error"; // XXX
// }
// } else {
// xhr.response = xhr.responseText = response[2];
// }
// // XXX ArrayBuffer
// if (xhr.status >= 400 || xhr.status === 0) {
// return reject({"target": xhr});
// }
// resolve({"target": xhr});
// }, 10);
// // XXX on error (if necessary)
// // XXX on progress
// if (typeof param.beforeSend === 'function') {
// param.beforeSend(xhr);
// }
// }, function () {
// clearTimeout(timeout);
// });
// };
// } else {
// responses.push = function () {
// return;
// };
// server = {restore: function () {
// return;
// }};
// }
//
// function postNewDocument() {
// // responses.push([404, {}, '']); // GET
// // responses.push([201, {}, '']); // PUT
// return jio.post({"title": "Unique ID"});
// }
//
// function postNewDocumentTest(answer) {
// var uuid = answer.id;
// answer.id = "<uuid>";
// deepEqual(answer, {
// "id": "<uuid>",
// "method": "post",
// "result": "success",
// "status": 201,
// "statusText": "Created"
// }, "Post a new document");
// ok(util.isUuid(uuid), "New document id should look like " +
// "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx : " + uuid);
// shared.created_document_id = uuid;
// }
//
// function getCreatedDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": shared.created_document_id,
// "title": "Unique ID"
// })]); // GET
// return jio.get({"_id": shared.created_document_id});
// }
//
// function getCreatedDocumentTest(answer) {
// deepEqual(answer, {
// "data": {
// "_id": shared.created_document_id,
// "title": "Unique ID"
// },
// "id": shared.created_document_id,
// "method": "get",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get new document");
// }
//
// function postSpecificDocument() {
// responses.push([404, {}, '']); // GET
// responses.push([201, {}, '']); // PUT
// return jio.post({"_id": "b", "title": "Bee"});
// }
//
// function postSpecificDocumentTest(answer) {
// deepEqual(answer, {
// "id": "b",
// "method": "post",
// "result": "success",
// "status": 201,
// "statusText": "Created"
// }, "Post specific document");
// }
//
// function checkDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "b",
// "title": "Bee"
// })]); // GET
// return jio.check({"_id": "b"});
// }
//
// function checkDocumentTest(answer) {
// deepEqual(answer, {
// "id": "b",
// "method": "check",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Check specific document");
// }
//
// function checkStorage() {
// responses.push([
// 207,
// {"Content-Type": "text/xml"},
// '<?xml version="1.0" encoding="utf-8"?>' +
// '<D:multistatus xmlns:D="DAV:">' +
// '<D:response xmlns:lp1="DAV:" ' +
// 'xmlns:lp2="http://apache.org/dav/props/">' +
// '<D:href>/uploads/</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
// '<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>' +
// '<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"240be-1000-4e9f88a305c4e"</lp1:getetag>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp1="DAV:" ' +
// 'xmlns:lp2="http://apache.org/dav/props/">' +
// '<D:href>/uploads/' + shared.created_document_id + '</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>' +
// '<lp1:getcontentlength>66</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"20568-42-4e9f88a2ea198"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp1="DAV:" ' +
// 'xmlns:lp2="http://apache.org/dav/props/">' +
// '<D:href>/uploads/b</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-10-30T17:19:46Z</lp1:creationdate>' +
// '<lp1:getcontentlength>25</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Wed, 30 Oct 2013 17:19:46 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"21226-19-4e9f88a305c4e"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '</D:multistatus>'
// ]); // PROPFIND
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": shared.created_document_id,
// "title": "Unique ID"
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "b",
// "title": "Bee"
// })]); // GET
// return jio.check({});
// }
//
// function checkStorageTest(answer) {
// deepEqual(answer, {
// "method": "check",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Check storage state");
// }
//
// function listDocuments() {
// responses.push([
// 207,
// {"Content-Type": "text/xml"},
// '<?xml version="1.0" encoding="utf-8"?>' +
// '<D:multistatus xmlns:D="DAV:">' +
// '<D:response xmlns:lp2="http://apache.' +
// 'org/dav/props/" xmlns:lp1="DAV:">' +
// '<D:href>/uploads/</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"240be-1000-4e6bb383e5fbb"</lp1:getetag>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
// 'xmlns:lp1="DAV:">' +
// '<D:href>/uploads/' + shared.created_document_id + '</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getcontentlength>66</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"20529-42-4e6bb383d0d30"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
// 'xmlns:lp1="DAV:">' +
// '<D:href>/uploads/b</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getcontentlength>25</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"20da3-19-4e6bb383e5fbb"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '</D:multistatus>'
// ]); // PROPFIND
// return jio.allDocs();
// }
//
// function list2DocumentsTest(answer) {
// if (answer && answer.data && Array.isArray(answer.data.rows)) {
// answer.data.rows.sort(function (a) {
// return a.id === "b" ? 1 : 0;
// });
// }
// deepEqual(answer, {
// "data": {
// "total_rows": 2,
// "rows": [{
// "id": shared.created_document_id,
// "value": {}
// }, {
// "id": "b",
// "value": {}
// }]
// },
// "method": "allDocs",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "List 2 documents");
// }
//
// function listDocumentsWithMetadata() {
// responses.push([
// 207,
// {"Content-Type": "text/xml"},
// '<?xml version="1.0" encoding="utf-8"?>' +
// '<D:multistatus xmlns:D="DAV:">' +
// '<D:response xmlns:lp2="http://apache.' +
// 'org/dav/props/" xmlns:lp1="DAV:">' +
// '<D:href>/uploads/</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"240be-1000-4e6bb383e5fbb"</lp1:getetag>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
// 'xmlns:lp1="DAV:">' +
// '<D:href>/uploads/' + shared.created_document_id + '</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getcontentlength>66</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"20529-42-4e6bb383d0d30"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
// 'xmlns:lp1="DAV:">' +
// '<D:href>/uploads/b</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype/>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getcontentlength>25</lp1:getcontentlength>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"20da3-19-4e6bb383e5fbb"</lp1:getetag>' +
// '<lp2:executable>F</lp2:executable>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '</D:multistatus>'
// ]); // PROPFIND
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": shared.created_document_id,
// "title": "Unique ID"
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "b",
// "title": "Bee"
// })]); // GET
// return jio.allDocs({"include_docs": true});
// }
//
// function list2DocumentsWithMetadataTest(answer) {
// if (answer && answer.data && Array.isArray(answer.data.rows)) {
// answer.data.rows.sort(function (a) {
// return a.id === "b" ? 1 : 0;
// });
// }
// deepEqual(answer, {
// "data": {
// "total_rows": 2,
// "rows": [{
// "id": shared.created_document_id,
// "value": {},
// "doc": {
// "_id": shared.created_document_id,
// "title": "Unique ID"
// }
// }, {
// "id": "b",
// "value": {},
// "doc": {
// "_id": "b",
// "title": "Bee"
// }
// }]
// },
// "method": "allDocs",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "List 2 documents with their metadata");
// }
//
// function removeCreatedDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": shared.created_document_id,
// "title": "Unique ID"
// })]); // GET
// responses.push([204, {}, '']); // DELETE
// return jio.remove({"_id": shared.created_document_id});
// }
//
// function removeCreatedDocumentTest(answer) {
// deepEqual(answer, {
// "id": shared.created_document_id,
// "method": "remove",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Remove first document.");
// }
//
// function removeSpecificDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "b",
// "title": "Bee"
// })]); // GET
// responses.push([204, {}, '']); // DELETE
// return jio.remove({"_id": "b"});
// }
//
// function removeSpecificDocumentTest(answer) {
// deepEqual(answer, {
// "id": "b",
// "method": "remove",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Remove second document.");
// }
//
// function listEmptyStorage() {
// responses.push([
// 207,
// {"Content-Type": "text/xml"},
// '<?xml version="1.0" encoding="utf-8"?>' +
// '<D:multistatus xmlns:D="DAV:">' +
// '<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
// 'xmlns:lp1="DAV:">' +
// '<D:href>/uploads/</D:href>' +
// '<D:propstat>' +
// '<D:prop>' +
// '<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
// '<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
// '<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
// '</lp1:getlastmodified>' +
// '<lp1:getetag>"240be-1000-4e6bb3840a9ac"</lp1:getetag>' +
// '<D:supportedlock>' +
// '<D:lockentry>' +
// '<D:lockscope><D:exclusive/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '<D:lockentry>' +
// '<D:lockscope><D:shared/></D:lockscope>' +
// '<D:locktype><D:write/></D:locktype>' +
// '</D:lockentry>' +
// '</D:supportedlock>' +
// '<D:lockdiscovery/>' +
// '<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
// '</D:prop>' +
// '<D:status>HTTP/1.1 200 OK</D:status>' +
// '</D:propstat>' +
// '</D:response>' +
// '</D:multistatus>'
// ]); // PROPFIND
// return jio.allDocs();
// }
//
// function listEmptyStorageTest(answer) {
// deepEqual(answer, {
// "data": {
// "total_rows": 0,
// "rows": []
// },
// "method": "allDocs",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "List empty storage");
// }
//
// function putNewDocument() {
// responses.push([404, {}, '']); // GET
// responses.push([201, {}, '']); // PUT
// return jio.put({"_id": "a", "title": "Hey"});
// }
//
// function putNewDocumentTest(answer) {
// deepEqual(answer, {
// "id": "a",
// "method": "put",
// "result": "success",
// "status": 201,
// "statusText": "Created"
// }, "Put new document");
// }
//
// function getCreatedDocument2() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey"
// })]); // GET
// return jio.get({"_id": "a"});
// }
//
// function getCreatedDocument2Test(answer) {
// deepEqual(answer, {
// "data": {
// "_id": "a",
// "title": "Hey"
// },
// "id": "a",
// "method": "get",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get new document");
// }
//
// function postSameDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey"
// })]); // GET
// return success(jio.post({"_id": "a", "title": "Hoo"}));
// }
//
// function postSameDocumentTest(answer) {
// deepEqual(answer, {
// "error": "conflict",
// "id": "a",
// "message": "DavStorage, cannot overwrite document metadata.",
// "method": "post",
// "reason": "Document exists",
// "result": "error",
// "status": 409,
// "statusText": "Conflict"
// }, "Unable to post the same document (conflict)");
// }
//
// function putAttachmentToNonExistentDocument() {
// responses.push([404, {}, ""]); // GET
// return success(jio.putAttachment({
// "_id": "ahaha",
// "_attachment": "aa",
// "_data": "aaa",
// "_content_type": "text/plain"
// }));
// }
//
// function putAttachmentToNonExistentDocumentTest(answer) {
// deepEqual(answer, {
// "attachment": "aa",
// "error": "not_found",
// "id": "ahaha",
// "message": "DavStorage unable to put attachment",
// "method": "putAttachment",
// "reason": "Not Found",
// "result": "error",
// "status": 404,
// "statusText": "Not Found"
// }, "Put attachment to a non existent document -> 404 Not Found");
// }
//
// function createAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey"
// })]); // GET
// responses.push([201, {}, '']); // PUT (attachment)
// responses.push([204, {}, '']); // PUT (metadata)
// return jio.putAttachment({
// "_id": "a",
// "_attachment": "aa",
// "_data": "aaa",
// "_content_type": "text/plain"
// });
// }
//
// function createAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "aa",
// "digest": "sha256-9834876dcfb05cb167a5c24953eba58c4" +
// "ac89b1adf57f28f2f9d09af107ee8f0",
// "id": "a",
// "method": "putAttachment",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Create new attachment");
// }
//
// function updateAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-9834876dcfb05cb167a5c24953eba58c4" +
// "ac89b1adf57f28f2f9d09af107ee8f0",
// "length": 3
// }
// }
// })]); // GET
// responses.push([204, {}, '']); // PUT (attachment)
// responses.push([204, {}, '']); // PUT (metadata)
// return jio.putAttachment({
// "_id": "a",
// "_attachment": "aa",
// "_data": "aab",
// "_content_type": "text/plain"
// });
// }
//
// function updateAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "aa",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "id": "a",
// "method": "putAttachment",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Update last attachment");
// }
//
// function createAnotherAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// }
// })]); // GET
// responses.push([201, {}, '']); // PUT (attachment)
// responses.push([204, {}, '']); // PUT (metadata)
// return jio.putAttachment({
// "_id": "a",
// "_attachment": "ab",
// "_data": "aba",
// "_content_type": "text/plain"
// });
// }
//
// function createAnotherAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "id": "a",
// "method": "putAttachment",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Create another attachment");
// }
//
// function updateLastDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hey",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([204, {}, '']); // PUT
// return jio.put({"_id": "a", "title": "Hoo"});
// }
//
// function updateLastDocumentTest(answer) {
// deepEqual(answer, {
// "id": "a",
// "method": "put",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Update document metadata");
// }
//
// function getFirstAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aab"]); // GET
// return jio.getAttachment({"_id": "a", "_attachment": "aa"});
// }
//
// function getFirstAttachmentTest(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "aa",
// "data": "<blob>",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "id": "a",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get first attachment");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "aab", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
//
//
//
//
//
//
//
// function getFirstAttachmentRange1() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aab"]); // GET
// return jio.getAttachment({"_id": "a",
// "_attachment": "aa",
// "_start": 0});
// }
//
// function getFirstAttachmentRangeTest1(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "aa",
// "data": "<blob>",
// "id": "a",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get first attachment with range:_start: 0, _end: undefined");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "aab", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
//
//
//
//
//
//
//
// function getFirstAttachmentRange2() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aab"]); // GET
// return jio.getAttachment({"_id": "a",
// "_attachment": "aa",
// "_start": 0,
// "_end": 1});
// }
//
// function getFirstAttachmentRangeTest2(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "aa",
// "data": "<blob>",
// "id": "a",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get first attachment with range: _start:0, _end:1");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "a", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
//
// function getFirstAttachmentRange3() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aab"]); // GET
// return jio.getAttachment({"_id": "a",
// "_attachment": "aa",
// "_start": 1,
// "_end": 3});
// }
//
// function getFirstAttachmentRangeTest3(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "aa",
// "data": "<blob>",
// "id": "a",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get first attachment with range:_start:1, _end:3 ");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "ab", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
//
//
//
// function getSecondAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aba"]); // GET
// return jio.getAttachment({"_id": "a", "_attachment": "ab"});
// }
//
// function getSecondAttachmentTest(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "ab",
// "data": "<blob>",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "id": "a",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get second attachment");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "aba", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
//
// function getSecondAttachmentRange1() {
// return success(jio.getAttachment({"_id": "a",
// "_attachment": "ab",
// "_start": -1}));
// }
// function getSecondAttachmentRangeTest1(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "error": "method_not_allowed",
// "id": "a",
// "message": "_start and _end must be positive",
// "method": "getAttachment",
// "reason": "invalide _start,_end",
// "result": "error",
// "status": 405,
// "statusText": "Method Not Allowed"
// }, "Get second attachment with range: _start: -1");
// }
//
// function getSecondAttachmentRange2() {
// return success(jio.getAttachment({"_id": "a",
// "_attachment": "ab",
// "_start": 1,
// "_end": 0}));
// }
// function getSecondAttachmentRangeTest2(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "error": "method_not_allowed",
// "id": "a",
// "message": "start is great then end",
// "method": "getAttachment",
// "reason": "invalide _start,_end",
// "result": "error",
// "status": 405,
// "statusText": "Method Not Allowed"
// }, "Get second attachment with range: _start: -1");
// }
//
//
//
// function getSecondAttachmentRange3() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, "aab"]); // GET
// return jio.getAttachment({"_id": "a",
// "_attachment": "ab",
// "_start": 1,
// "_end": 2});
// }
//
// function getSecondAttachmentRangeTest3(answer) {
// var blob = answer.data;
// answer.data = "<blob>";
// deepEqual(answer, {
// "attachment": "ab",
// "data": "<blob>",
// "id": "a",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "method": "getAttachment",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get second attachment with range:_start:1, _end:2 ");
// return jIO.util.readBlobAsText(blob).then(function (e) {
// deepEqual(blob.type, "text/plain", "Check blob type");
// deepEqual(e.target.result, "a", "Check blob text content");
// }, function (err) {
// deepEqual(err, "no error", "Check blob text content");
// });
// }
//
// function getLastDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// return jio.get({"_id": "a"});
// }
//
// function getLastDocumentTest(answer) {
// deepEqual(answer, {
// "data": {
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// },
// "id": "a",
// "method": "get",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get last document metadata");
// }
//
// function removeSecondAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// },
// "ab": {
// "content_type": "text/plain",
// "digest": "sha256-e124adcce1fb2f88e1ea799c3d0820845" +
// "ed343e6c739e54131fcb3a56e4bc1bd",
// "length": 3
// }
// }
// })]); // GET
// responses.push([204, {}, '']); // PUT
// responses.push([204, {}, '']); // DELETE
// return jio.removeAttachment({"_id": "a", "_attachment": "ab"});
// }
//
// function removeSecondAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "id": "a",
// "method": "removeAttachment",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Remove second document");
// }
//
// function getInexistentSecondAttachment() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// }
// })]); // GET
// return success(jio.getAttachment({"_id": "a", "_attachment": "ab"}));
// }
//
// function getInexistentSecondAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "error": "not_found",
// "id": "a",
// "message": "DavStorage, unable to get attachment.",
// "method": "getAttachment",
// "reason": "missing attachment",
// "result": "error",
// "status": 404,
// "statusText": "Not Found"
// }, "Get inexistent second attachment");
// }
//
// function getOneAttachmentDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// }
// })]); // GET
// return jio.get({"_id": "a"});
// }
//
// function getOneAttachmentDocumentTest(answer) {
// deepEqual(answer, {
// "data": {
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// },
// "_id": "a",
// "title": "Hoo"
// },
// "id": "a",
// "method": "get",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// }, "Get document metadata");
// }
//
// function removeSecondAttachmentAgain() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// }
// })]); // GET
// return success(jio.removeAttachment({"_id": "a", "_attachment": "ab"}));
// }
//
// function removeSecondAttachmentAgainTest(answer) {
// deepEqual(answer, {
// "attachment": "ab",
// "error": "not_found",
// "id": "a",
// "message": "DavStorage, document attachment not found.",
// "method": "removeAttachment",
// "reason": "missing attachment",
// "result": "error",
// "status": 404,
// "statusText": "Not Found"
// }, "Remove inexistent attachment");
// }
//
// function removeDocument() {
// responses.push([200, {
// "Content-Type": "application/octet-stream"
// }, JSON.stringify({
// "_id": "a",
// "title": "Hoo",
// "_attachments": {
// "aa": {
// "content_type": "text/plain",
// "digest": "sha256-38760eabb666e8e61ee628a17c4090cc5" +
// "0728e095ff24218119d51bd22475363",
// "length": 3
// }
// }
// })]); // GET
// responses.push([204, {}, '']); // DELETE (metadata)
// responses.push([204, {}, '']); // DELETE (attachment aa)
// return jio.remove({"_id": "a"});
// }
//
// function removeDocumentTest(answer) {
// deepEqual(answer, {
// "id": "a",
// "method": "remove",
// "result": "success",
// "status": 204,
// "statusText": "No Content"
// }, "Remove document and its attachments");
// }
//
// function getInexistentFirstAttachment() {
// responses.push([404, {}, '']); // GET
// return success(jio.getAttachment({"_id": "a", "_attachment": "aa"}));
// }
//
// function getInexistentFirstAttachmentTest(answer) {
// deepEqual(answer, {
// "attachment": "aa",
// "error": "not_found",
// "id": "a",
// "message": "DavStorage, unable to get attachment.",
// "method": "getAttachment",
// "reason": "missing document",
// "result": "error",
// "status": 404,
// "statusText": "Not Found"
// }, "Get inexistent first attachment");
// }
//
// function removeInexistentDocument() {
// responses.push([404, {}, '']); // GET
// return success(jio.remove({"_id": "a"}));
// }
//
// function removeInexistentDocumentTest(answer) {
// deepEqual(answer, {
// "error": "not_found",
// "id": "a",
// "message": "DavStorage, unable to get metadata.",
// "method": "remove",
// "reason": "Not Found",
// "result": "error",
// "status": 404,
// "statusText": "Not Found"
// }, "Remove already removed document");
// }
//
// // # Post new documents, list them and remove them
// // post a 201
// postNewDocument().then(postNewDocumentTest).
// // get 200
// then(getCreatedDocument).then(getCreatedDocumentTest).
// // post b 201
// then(postSpecificDocument).then(postSpecificDocumentTest).
// // check b 204
// then(checkDocument).then(checkDocumentTest).
// // check storage 204
// then(checkStorage).then(checkStorageTest).
// // allD 200 2 documents
// then(listDocuments).then(list2DocumentsTest).
// // allD+include_docs 200 2 documents
// then(listDocumentsWithMetadata).then(list2DocumentsWithMetadataTest).
// // remove a 204
// then(removeCreatedDocument).then(removeCreatedDocumentTest).
// // remove b 204
// then(removeSpecificDocument).then(removeSpecificDocumentTest).
// // allD 200 empty storage
// then(listEmptyStorage).then(listEmptyStorageTest).
// // # Create and update documents, and some attachment and remove them
// // put 201
// then(putNewDocument).then(putNewDocumentTest).
// // get 200
// then(getCreatedDocument2).then(getCreatedDocument2Test).
// // post 409
// then(postSameDocument).then(postSameDocumentTest).
// // putA 404
// then(putAttachmentToNonExistentDocument).
// then(putAttachmentToNonExistentDocumentTest).
// // putA a 204
// then(createAttachment).then(createAttachmentTest).
// // putA a 204
// then(updateAttachment).then(updateAttachmentTest).
// // putA b 204
// then(createAnotherAttachment).then(createAnotherAttachmentTest).
// // put 204
// then(updateLastDocument).then(updateLastDocumentTest).
// // getA a 200
// then(getFirstAttachment).then(getFirstAttachmentTest).
// then(getFirstAttachmentRange1).then(getFirstAttachmentRangeTest1).
// then(getFirstAttachmentRange2).then(getFirstAttachmentRangeTest2).
// then(getFirstAttachmentRange3).then(getFirstAttachmentRangeTest3).
// // getA b 200
// then(getSecondAttachment).then(getSecondAttachmentTest).
// then(getSecondAttachmentRange1).then(getSecondAttachmentRangeTest1).
// then(getSecondAttachmentRange2).then(getSecondAttachmentRangeTest2).
// then(getSecondAttachmentRange3).then(getSecondAttachmentRangeTest3).
// // get 200
// then(getLastDocument).then(getLastDocumentTest).
// // removeA b 204
// then(removeSecondAttachment).then(removeSecondAttachmentTest).
// // getA b 404
// then(getInexistentSecondAttachment).
// then(getInexistentSecondAttachmentTest).
// // get 200
// then(getOneAttachmentDocument).then(getOneAttachmentDocumentTest).
// // removeA b 404
// then(removeSecondAttachmentAgain).then(removeSecondAttachmentAgainTest).
// // remove 204
// then(removeDocument).then(removeDocumentTest).
// // getA a 404
// then(getInexistentFirstAttachment).then(getInexistentFirstAttachmentTest).
// // remove 404
// then(removeInexistentDocument).then(removeInexistentDocumentTest).
// // end
// fail(function (error) {
// console.log(error.stack);
// console.log(error);
// ok(false, error);
// }).
// always(function () {
// start();
// server.restore();
// });
//
// });
//
// }));
test/tests.html
View file @
4428686a
...
@@ -29,9 +29,9 @@
...
@@ -29,9 +29,9 @@
<script
src=
"jio.storage/querystorage.tests.js"
></script>
<script
src=
"jio.storage/querystorage.tests.js"
></script>
<script
src=
"jio.storage/localstorage.tests.js"
></script>
<script
src=
"jio.storage/localstorage.tests.js"
></script>
<script
src=
"jio.storage/documentstorage.tests.js"
></script>
<script
src=
"jio.storage/documentstorage.tests.js"
></script>
<script
src=
"jio.storage/davstorage.tests.js"
></script>
<!--script src="jio.storage/davstorage.tests.js"></script>
<!--script src="jio.storage/unionstorage.tests.js"></script-->
<script src="jio.storage/unionstorage.tests.js"></script-->
<!--script src="jio.storage/indexeddbstorage.tests.js"></script-->
<!--script src="jio.storage/indexeddbstorage.tests.js"></script-->
<!--script src="jio.storage/indexstorage.tests.js"></script-->
<!--script src="jio.storage/indexstorage.tests.js"></script-->
...
...
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