Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
bbf74f1f
Commit
bbf74f1f
authored
Aug 14, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DavStorage and Jio tests
parent
27016e9e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
196 additions
and
139 deletions
+196
-139
OfficeJS/src/jio.storage/davstorage.js
OfficeJS/src/jio.storage/davstorage.js
+127
-78
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+62
-54
OfficeJS/test/responsexml/davlist
OfficeJS/test/responsexml/davlist
+3
-3
OfficeJS/test/responsexml/davload
OfficeJS/test/responsexml/davload
+2
-2
OfficeJS/test/responsexml/davsave
OfficeJS/test/responsexml/davsave
+2
-2
No files found.
OfficeJS/src/jio.storage/davstorage.js
View file @
bbf74f1f
var
newDAVStorage
=
function
(
spec
,
my
)
{
var
newDAVStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
),
priv
=
{};
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
),
priv
=
{};
priv
.
secureDocId
=
function
(
string
)
{
var
split
=
string
.
split
(
'
/
'
),
i
;
if
(
split
[
0
]
===
''
)
{
split
=
split
.
slice
(
1
);
}
for
(
i
=
0
;
i
<
split
.
length
;
i
+=
1
)
{
if
(
split
[
i
]
===
''
)
{
return
''
;
}
}
return
split
.
join
(
'
%2F
'
);
};
priv
.
convertSlashes
=
function
(
string
)
{
return
string
.
split
(
'
/
'
).
join
(
'
%2F
'
);
};
priv
.
restoreSlashes
=
function
(
string
)
{
return
string
.
split
(
'
%2F
'
).
join
(
'
/
'
);
};
priv
.
username
=
spec
.
username
||
''
;
priv
.
username
=
spec
.
username
||
''
;
priv
.
secured_username
=
priv
.
convertSlashes
(
priv
.
username
);
priv
.
applicationname
=
spec
.
applicationname
||
'
untitled
'
;
priv
.
applicationname
=
spec
.
applicationname
||
'
untitled
'
;
priv
.
secured_applicationname
=
priv
.
convertSlashes
(
priv
.
applicationname
);
priv
.
url
=
spec
.
url
||
''
;
priv
.
url
=
spec
.
url
||
''
;
priv
.
password
=
spec
.
password
||
''
;
// TODO : is it secured ?
priv
.
password
=
spec
.
password
||
''
;
// TODO : is it secured ?
...
@@ -22,7 +43,7 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -22,7 +43,7 @@ var newDAVStorage = function ( spec, my ) {
* @return {string} '' -> ok, 'message' -> error
* @return {string} '' -> ok, 'message' -> error
*/
*/
that
.
validateState
=
function
()
{
that
.
validateState
=
function
()
{
if
(
priv
.
username
&&
priv
.
url
)
{
if
(
priv
.
secured_
username
&&
priv
.
url
)
{
return
''
;
return
''
;
}
}
return
'
Need at least 2 parameters: "username" and "url".
'
;
return
'
Need at least 2 parameters: "username" and "url".
'
;
...
@@ -54,50 +75,55 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -54,50 +75,55 @@ var newDAVStorage = function ( spec, my ) {
return
async
;
return
async
;
};
};
that
.
post
=
function
(
command
)
{
that
.
put
(
command
);
};
/**
/**
* Saves a document in the distant dav storage.
* Saves a document in the distant dav storage.
* @method
saveDocumen
t
* @method
pu
t
*/
*/
that
.
saveDocument
=
function
(
command
)
{
that
.
put
=
function
(
command
)
{
var
secured_docid
=
priv
.
secureDocId
(
command
.
getDocId
());
// TODO if path of /dav/user/applic does not exists, it won't work!
//// save on dav
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
priv
.
secured_
applicationname
+
'
/
'
+
command
.
getPath
()
,
secured_docid
,
type
:
'
PUT
'
,
type
:
'
PUT
'
,
data
:
command
.
getContent
(),
data
:
command
.
get
Doc
Content
(),
async
:
true
,
async
:
true
,
dataType
:
'
text
'
,
// TODO is it necessary ?
dataType
:
'
text
'
,
// TODO is it necessary ?
headers
:
{
'
Authorization
'
:
'
Basic
'
+
Base64
.
encode
(
headers
:
{
'
Authorization
'
:
'
Basic
'
+
Base64
.
encode
(
priv
.
username
+
'
:
'
+
priv
.
password
)},
priv
.
username
+
'
:
'
+
priv
.
password
)},
// xhrFields: {withCredentials: 'true'}, // cross domain
// xhrFields: {withCredentials: 'true'}, // cross domain
success
:
function
()
{
success
:
function
()
{
that
.
success
();
that
.
success
(
{
ok
:
true
,
id
:
command
.
getDocId
()}
);
},
},
error
:
function
(
type
)
{
error
:
function
(
type
)
{
type
.
message
=
'
Cannot save "
'
+
command
.
getPath
()
+
// TODO : make statusText to lower case and add '_'
'
" into DAVStorage.
'
;
type
.
error
=
type
.
statusText
;
type
.
reason
=
'
Cannot save "
'
+
command
.
getDocId
()
+
'
"
'
;
type
.
message
=
type
.
reason
+
'
.
'
;
that
.
retry
(
type
);
that
.
retry
(
type
);
}
}
}
);
}
);
//// end saving on dav
};
// end put
};
/**
/**
* Loads a document from a distant dav storage.
* Loads a document from a distant dav storage.
* @method
loadDocumen
t
* @method
ge
t
*/
*/
that
.
loadDocumen
t
=
function
(
command
)
{
that
.
ge
t
=
function
(
command
)
{
var
doc
=
{}
,
var
secured_docid
=
priv
.
secureDocId
(
command
.
getDocId
())
,
getContent
=
function
()
{
doc
=
{},
getContent
=
function
()
{
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
priv
.
secured_
applicationname
+
'
/
'
+
command
.
getPath
()
,
secured_docid
,
type
:
"
GET
"
,
type
:
"
GET
"
,
async
:
true
,
async
:
true
,
dataType
:
'
text
'
,
// TODO is it necessary ?
dataType
:
'
text
'
,
// TODO is it necessary ?
...
@@ -109,28 +135,31 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -109,28 +135,31 @@ var newDAVStorage = function ( spec, my ) {
that
.
success
(
doc
);
that
.
success
(
doc
);
},
},
error
:
function
(
type
)
{
error
:
function
(
type
)
{
type
.
error
=
type
.
statusText
;
// TODO : to lower case
if
(
type
.
status
===
404
)
{
if
(
type
.
status
===
404
)
{
type
.
message
=
'
Document "
'
+
type
.
message
=
'
Document "
'
+
command
.
getPath
()
+
command
.
getDocId
()
+
'
" not found in localStorage.
'
;
'
" not found.
'
;
type
.
reason
=
'
missing
'
;
that
.
error
(
type
);
that
.
error
(
type
);
}
else
{
}
else
{
type
.
message
=
type
.
reason
=
'
Cannot load "
'
+
command
.
getPath
()
+
'
An error occured when trying to get "
'
+
'
" from DAVStorage.
'
;
command
.
getDocId
()
+
'
"
'
;
type
.
message
=
type
.
reason
+
'
.
'
;
that
.
retry
(
type
);
that
.
retry
(
type
);
}
}
}
}
}
);
}
);
};
};
doc
.
name
=
command
.
getPath
();
// TODO : basename
doc
.
_id
=
command
.
getDocId
();
// NOTE : if (command.getOption('content_only') { return getContent(); }
// NOTE : if (command.getOption('content_only') { return getContent(); }
// Get properties
// Get properties
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
priv
.
secured_
applicationname
+
'
/
'
+
command
.
getPath
()
,
secured_docid
,
type
:
"
PROPFIND
"
,
type
:
"
PROPFIND
"
,
async
:
true
,
async
:
true
,
dataType
:
'
xml
'
,
dataType
:
'
xml
'
,
...
@@ -141,12 +170,14 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -141,12 +170,14 @@ var newDAVStorage = function ( spec, my ) {
$
(
xmlData
).
find
(
$
(
xmlData
).
find
(
'
lp1
\\
:getlastmodified, getlastmodified
'
'
lp1
\\
:getlastmodified, getlastmodified
'
).
each
(
function
()
{
).
each
(
function
()
{
doc
.
last_modified
=
$
(
this
).
text
();
doc
.
_last_modified
=
new
Date
(
$
(
this
).
text
()).
getTime
();
});
});
$
(
xmlData
).
find
(
$
(
xmlData
).
find
(
'
lp1
\\
:creationdate, creationdate
'
'
lp1
\\
:creationdate, creationdate
'
).
each
(
function
()
{
).
each
(
function
()
{
doc
.
creation_date
=
$
(
this
).
text
();
doc
.
_creation_date
=
new
Date
(
$
(
this
).
text
()).
getTime
();
});
});
if
(
!
command
.
getOption
(
'
metadata_only
'
))
{
if
(
!
command
.
getOption
(
'
metadata_only
'
))
{
getContent
();
getContent
();
...
@@ -155,11 +186,15 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -155,11 +186,15 @@ var newDAVStorage = function ( spec, my ) {
}
}
},
},
error
:
function
(
type
)
{
error
:
function
(
type
)
{
type
.
message
=
'
Cannot load "
'
+
command
.
getPath
()
+
'
" informations from DAVStorage.
'
;
if
(
type
.
status
===
404
)
{
if
(
type
.
status
===
404
)
{
type
.
message
=
'
Cannot find "
'
+
command
.
getDocId
()
+
'
" informations.
'
;
type
.
reason
=
'
missing
'
;
that
.
error
(
type
);
that
.
error
(
type
);
}
else
{
}
else
{
type
.
reason
=
'
Cannot get "
'
+
command
.
getDocId
()
+
'
" informations
'
;
type
.
message
=
type
.
reason
+
'
.
'
;
that
.
retry
(
type
);
that
.
retry
(
type
);
}
}
}
}
...
@@ -168,18 +203,18 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -168,18 +203,18 @@ var newDAVStorage = function ( spec, my ) {
/**
/**
* Gets a document list from a distant dav storage.
* Gets a document list from a distant dav storage.
* @method
getDocumentList
* @method
allDocs
*/
*/
that
.
getDocumentList
=
function
(
command
)
{
that
.
allDocs
=
function
(
command
)
{
var
document_array
=
[],
file
=
{},
path_array
=
[],
var
rows
=
[],
am
=
priv
.
newAsyncModule
(),
o
=
{};
am
=
priv
.
newAsyncModule
(),
o
=
{};
o
.
getContent
=
function
(
file
)
{
o
.
getContent
=
function
(
file
)
{
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
priv
.
secured_
applicationname
+
'
/
'
+
file
.
name
,
priv
.
secureDocId
(
file
.
id
)
,
type
:
"
GET
"
,
type
:
"
GET
"
,
async
:
true
,
async
:
true
,
dataType
:
'
text
'
,
// TODO : is it necessary ?
dataType
:
'
text
'
,
// TODO : is it necessary ?
...
@@ -187,24 +222,26 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -187,24 +222,26 @@ var newDAVStorage = function ( spec, my ) {
Base64
.
encode
(
priv
.
username
+
'
:
'
+
Base64
.
encode
(
priv
.
username
+
'
:
'
+
priv
.
password
)},
priv
.
password
)},
success
:
function
(
content
)
{
success
:
function
(
content
)
{
file
.
content
=
content
;
file
.
value
.
content
=
content
;
// WARNING : files can be disordered because
// WARNING : files can be disordered because
// of asynchronous action
// of asynchronous action
document_array
.
push
(
file
);
rows
.
push
(
file
);
am
.
call
(
o
,
'
success
'
);
am
.
call
(
o
,
'
success
'
);
},
},
error
:
function
(
type
)
{
error
:
function
(
type
)
{
type
.
message
=
'
Cannot get a document
'
+
type
.
error
=
type
.
statusText
;
// TODO : to lower case
'
content from DAVStorage.
'
;
type
.
reason
=
'
Cannot get a document
'
+
'
content from DAVStorage
'
;
type
.
message
=
type
.
message
+
'
.
'
;
am
.
call
(
o
,
'
error
'
,[
type
]);
am
.
call
(
o
,
'
error
'
,[
type
]);
}
}
});
});
};
};
o
.
getDocumentList
=
function
()
{
o
.
getDocumentList
=
function
()
{
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
,
priv
.
secured_
applicationname
+
'
/
'
,
async
:
true
,
async
:
true
,
type
:
'
PROPFIND
'
,
type
:
'
PROPFIND
'
,
dataType
:
'
xml
'
,
dataType
:
'
xml
'
,
...
@@ -222,41 +259,46 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -222,41 +259,46 @@ var newDAVStorage = function ( spec, my ) {
}
}
response
.
each
(
function
(
i
,
data
){
response
.
each
(
function
(
i
,
data
){
if
(
i
>
0
)
{
// exclude parent folder
if
(
i
>
0
)
{
// exclude parent folder
file
=
{
};
var
file
=
{
value
:{}
};
$
(
data
).
find
(
'
D
\\
:href, href
'
).
each
(
function
(){
$
(
data
).
find
(
'
D
\\
:href, href
'
).
each
(
function
(){
path_array
=
$
(
this
).
text
().
split
(
'
/
'
);
var
split
=
$
(
this
).
text
().
split
(
'
/
'
);
file
.
name
=
file
.
id
=
split
[
split
.
length
-
1
];
(
path_array
[
path_array
.
length
-
1
]
?
file
.
id
=
priv
.
restoreSlashes
(
file
.
id
);
path_array
[
path_array
.
length
-
1
]
:
file
.
key
=
file
.
id
;
path_array
[
path_array
.
length
-
2
]
+
'
/
'
);
});
});
if
(
file
.
name
===
'
.htaccess
'
||
if
(
file
.
id
===
'
.htaccess
'
||
file
.
name
===
'
.htpasswd
'
)
{
return
;
}
file
.
id
===
'
.htpasswd
'
)
{
return
;
}
$
(
data
).
find
(
$
(
data
).
find
(
'
lp1
\\
:getlastmodified, getlastmodified
'
'
lp1
\\
:getlastmodified, getlastmodified
'
).
each
(
function
()
{
).
each
(
function
()
{
file
.
last_modified
=
$
(
this
).
text
();
file
.
value
.
_last_modified
=
new
Date
(
$
(
this
).
text
()).
getTime
();
});
});
$
(
data
).
find
(
$
(
data
).
find
(
'
lp1
\\
:creationdate, creationdate
'
'
lp1
\\
:creationdate, creationdate
'
).
each
(
function
()
{
).
each
(
function
()
{
file
.
creation_date
=
$
(
this
).
text
();
file
.
value
.
_creation_date
=
new
Date
(
$
(
this
).
text
()).
getTime
();
});
});
if
(
!
command
.
getOption
(
'
metadata_only
'
))
{
if
(
!
command
.
getOption
(
'
metadata_only
'
))
{
am
.
call
(
o
,
'
getContent
'
,[
file
]);
am
.
call
(
o
,
'
getContent
'
,[
file
]);
}
else
{
}
else
{
document_array
.
push
(
file
);
rows
.
push
(
file
);
am
.
call
(
o
,
'
success
'
);
am
.
call
(
o
,
'
success
'
);
}
}
}
}
});
});
},
},
error
:
function
(
type
)
{
error
:
function
(
type
)
{
type
.
message
=
'
Cannot get a document list from DAVStorage.
'
;
if
(
type
.
status
===
404
)
{
if
(
type
.
status
===
404
)
{
type
.
error
=
'
not_found
'
;
type
.
reason
=
'
missing
'
;
am
.
call
(
o
,
'
error
'
,[
type
]);
am
.
call
(
o
,
'
error
'
,[
type
]);
}
else
{
}
else
{
type
.
error
=
type
.
statusText
;
// TODO : to lower case
type
.
reason
=
'
Cannot get a document list from DAVStorage
'
;
type
.
message
=
type
.
reason
+
'
.
'
;
am
.
call
(
o
,
'
retry
'
,[
type
]);
am
.
call
(
o
,
'
retry
'
,[
type
]);
}
}
}
}
...
@@ -278,36 +320,43 @@ var newDAVStorage = function ( spec, my ) {
...
@@ -278,36 +320,43 @@ var newDAVStorage = function ( spec, my ) {
am
.
neverCall
(
o
,
'
retry
'
);
am
.
neverCall
(
o
,
'
retry
'
);
am
.
neverCall
(
o
,
'
success
'
);
am
.
neverCall
(
o
,
'
success
'
);
am
.
neverCall
(
o
,
'
error
'
);
am
.
neverCall
(
o
,
'
error
'
);
that
.
success
(
document_array
);
that
.
success
({
total_rows
:
rows
.
length
,
rows
:
rows
});
};
};
am
.
call
(
o
,
'
getDocumentList
'
);
am
.
call
(
o
,
'
getDocumentList
'
);
};
};
// end allDocs
/**
/**
* Removes a document from a distant dav storage.
* Removes a document from a distant dav storage.
* @method remove
Document
* @method remove
*/
*/
that
.
removeDocument
=
function
(
command
)
{
that
.
remove
=
function
(
command
)
{
var
secured_docid
=
priv
.
secureDocId
(
command
.
getDocId
());
$
.
ajax
(
{
$
.
ajax
(
{
url
:
priv
.
url
+
'
/
dav/
'
+
url
:
priv
.
url
+
'
/
'
+
priv
.
username
+
'
/
'
+
priv
.
secured_
username
+
'
/
'
+
priv
.
applicationname
+
'
/
'
+
priv
.
secured_
applicationname
+
'
/
'
+
command
.
getPath
()
,
secured_docid
,
type
:
"
DELETE
"
,
type
:
"
DELETE
"
,
async
:
true
,
async
:
true
,
headers
:
{
'
Authorization
'
:
'
Basic
'
+
Base64
.
encode
(
headers
:
{
'
Authorization
'
:
'
Basic
'
+
Base64
.
encode
(
priv
.
username
+
'
:
'
+
priv
.
password
)},
priv
.
username
+
'
:
'
+
priv
.
password
)},
// xhrFields: {withCredentials: 'true'}, // cross domain
// xhrFields: {withCredentials: 'true'}, // cross domain
success
:
function
()
{
success
:
function
(
data
,
state
,
type
)
{
that
.
success
();
that
.
success
(
{
ok
:
true
,
id
:
command
.
getDocId
()}
);
},
},
error
:
function
(
type
)
{
error
:
function
(
type
,
state
,
statusText
)
{
if
(
type
.
status
===
404
)
{
if
(
type
.
status
===
404
)
{
that
.
success
();
//that.success({ok:true,id:command.getDocId()});
type
.
error
=
'
not_found
'
;
type
.
reason
=
'
missing
'
;
type
.
message
=
'
Cannot remove missing file.
'
;
that
.
error
(
type
);
}
else
{
}
else
{
type
.
message
=
'
Cannot remove "
'
+
that
.
getFileName
()
+
type
.
reason
=
'
Cannot remove "
'
+
that
.
getDocId
()
+
'
"
'
;
'
" from DAVStorage
.
'
;
type
.
message
=
type
.
reason
+
'
.
'
;
that
.
retry
(
type
);
that
.
retry
(
type
);
}
}
}
}
...
...
OfficeJS/test/jiotests.js
View file @
bbf74f1f
...
@@ -640,20 +640,20 @@ test ('Document load', function () {
...
@@ -640,20 +640,20 @@ test ('Document load', function () {
o
.
mytest
=
function
(
message
,
doc
,
errprop
,
errget
)
{
o
.
mytest
=
function
(
message
,
doc
,
errprop
,
errget
)
{
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
server
.
respondWith
(
server
.
respondWith
(
"
PROPFIND
"
,
"
https://ca-davstorage:8080/dav
/dav
load/jiotests/file
"
,
"
PROPFIND
"
,
"
https://ca-davstorage:8080/davload/jiotests/file
"
,
[
errprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
[
errprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
o
.
davload
]);
o
.
davload
]);
server
.
respondWith
(
server
.
respondWith
(
"
GET
"
,
"
https://ca-davstorage:8080/dav
/dav
load/jiotests/file
"
,
"
GET
"
,
"
https://ca-davstorage:8080/davload/jiotests/file
"
,
[
errget
,{},
'
content
'
]);
[
errget
,{},
'
content
'
]);
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
result
&&
result
.
status
)
{
if
(
err
)
{
result
=
undefined
;
err
=
err
.
status
;
}
}
deepEqual
(
result
,
doc
,
message
);
deepEqual
(
err
||
val
,
doc
,
message
);
};
};
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
jio
.
loadDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
,
max_retry
:
1
}
);
o
.
jio
.
get
(
'
file
'
,{
max_retry
:
1
},
o
.
f
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
server
.
respond
();
server
.
respond
();
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
...
@@ -676,11 +676,11 @@ test ('Document load', function () {
...
@@ -676,11 +676,11 @@ test ('Document load', function () {
// 403 Forbidden
// 403 Forbidden
// 404 Not Found
// 404 Not Found
// load an inexistant document.
// load an inexistant document.
o
.
mytest
(
'
load inexistant document
'
,
undefined
,
404
,
404
);
o
.
mytest
(
'
load inexistant document
'
,
404
,
404
,
404
);
// load a document.
// load a document.
o
.
mytest
(
'
load document
'
,{
name
:
'
file
'
,
content
:
'
content
'
,
o
.
mytest
(
'
load document
'
,{
_id
:
'
file
'
,
content
:
'
content
'
,
last_modified
:
1335953199000
,
_
last_modified
:
1335953199000
,
creation_date
:
1335953202000
},
207
,
200
);
_
creation_date
:
1335953202000
},
207
,
200
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -696,16 +696,16 @@ test ('Document save', function () {
...
@@ -696,16 +696,16 @@ test ('Document save', function () {
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
server
.
respondWith
(
server
.
respondWith
(
// lastmodified = 7000, creationdate = 5000
// lastmodified = 7000, creationdate = 5000
"
PROPFIND
"
,
"
https://ca-davstorage:8080/dav
/dav
save/jiotests/file
"
,
"
PROPFIND
"
,
"
https://ca-davstorage:8080/davsave/jiotests/file
"
,
[
errnoprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
[
errnoprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
o
.
davsave
]);
o
.
davsave
]);
server
.
respondWith
(
server
.
respondWith
(
"
PUT
"
,
"
PUT
"
,
"
https://ca-davstorage:8080/dav
/dav
save/jiotests/file
"
,
"
https://ca-davstorage:8080/davsave/jiotests/file
"
,
[
errnoput
,
{
'
Content-Type
'
:
'
x-www-form-urlencoded
'
},
[
errnoput
,
{
'
Content-Type
'
:
'
x-www-form-urlencoded
'
},
'
content
'
]);
'
content
'
]);
server
.
respondWith
(
server
.
respondWith
(
"
GET
"
,
"
https://ca-davstorage:8080/dav
/dav
save/jiotests/file
"
,
"
GET
"
,
"
https://ca-davstorage:8080/davsave/jiotests/file
"
,
[
errnoprop
===
207
?
200
:
errnoprop
,{},
'
content
'
]);
[
errnoprop
===
207
?
200
:
errnoprop
,{},
'
content
'
]);
// server.respondWith ("MKCOL","https://ca-davstorage:8080/dav",
// server.respondWith ("MKCOL","https://ca-davstorage:8080/dav",
// [200,{},'']);
// [200,{},'']);
...
@@ -714,16 +714,9 @@ test ('Document save', function () {
...
@@ -714,16 +714,9 @@ test ('Document save', function () {
// server.respondWith ("MKCOL",
// server.respondWith ("MKCOL",
// "https://ca-davstorage:8080/dav/davsave/jiotests",
// "https://ca-davstorage:8080/dav/davsave/jiotests",
// [200,{},'']);
// [200,{},'']);
o
.
f
=
function
(
result
)
{
o
.
f
=
basic_test_function_generator
(
o
,
'
value
'
,
value
,
message
);
if
(
result
&&
result
.
status
)
{
result
=
'
fail
'
;
}
else
{
result
=
'
done
'
;
}
deepEqual
(
result
,
value
,
message
);
};
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
server
.
respond
();
server
.
respond
();
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
...
@@ -749,10 +742,10 @@ test ('Document save', function () {
...
@@ -749,10 +742,10 @@ test ('Document save', function () {
// mytest('create path if not exists, and create document',
// mytest('create path if not exists, and create document',
// true,201,404);
// true,201,404);
// the document does not exist, we want to create it
// the document does not exist, we want to create it
o
.
mytest
(
'
create document
'
,
'
done
'
,
201
,
404
);
o
.
mytest
(
'
create document
'
,
{
ok
:
true
,
id
:
'
file
'
}
,
201
,
404
);
o
.
clock
.
tick
(
8000
);
o
.
clock
.
tick
(
8000
);
// the document already exists, we want to overwrite it
// the document already exists, we want to overwrite it
o
.
mytest
(
'
overwrite document
'
,
'
done
'
,
204
,
207
);
o
.
mytest
(
'
overwrite document
'
,
{
ok
:
true
,
id
:
'
file
'
}
,
204
,
207
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -767,28 +760,27 @@ test ('Get Document List', function () {
...
@@ -767,28 +760,27 @@ test ('Get Document List', function () {
o
.
mytest
=
function
(
message
,
metadata_only
,
value
,
errnoprop
)
{
o
.
mytest
=
function
(
message
,
metadata_only
,
value
,
errnoprop
)
{
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
server
.
respondWith
(
server
.
respondWith
(
"
PROPFIND
"
,
'
https://ca-davstorage:8080/dav
/dav
list/jiotests/
'
,
"
PROPFIND
"
,
'
https://ca-davstorage:8080/davlist/jiotests/
'
,
[
errnoprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
[
errnoprop
,{
'
Content-Type
'
:
'
text/xml; charset="utf-8"
'
},
o
.
davlist
]);
o
.
davlist
]);
server
.
respondWith
(
server
.
respondWith
(
"
GET
"
,
"
https://ca-davstorage:8080/dav
/dav
list/jiotests/file
"
,
"
GET
"
,
"
https://ca-davstorage:8080/davlist/jiotests/file
"
,
[
200
,{},
'
content
'
]);
[
200
,{},
'
content
'
]);
server
.
respondWith
(
server
.
respondWith
(
"
GET
"
,
"
https://ca-davstorage:8080/dav
/dav
list/jiotests/memo
"
,
"
GET
"
,
"
https://ca-davstorage:8080/davlist/jiotests/memo
"
,
[
200
,{},
'
content2
'
]);
[
200
,{},
'
content2
'
]);
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
result
&&
result
.
status
)
{
if
(
err
)
{
result
=
undefined
;
result
=
undefined
;
}
else
{
}
else
{
deepEqual
(
objectifyDocumentArray
(
result
),
deepEqual
(
objectifyDocumentArray
(
val
.
rows
),
objectifyDocumentArray
(
value
),
message
);
objectifyDocumentArray
(
value
),
message
);
return
;
return
;
}
}
deepEqual
(
result
,
value
,
message
);
deepEqual
(
result
,
value
,
message
);
};
};
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
,
o
.
jio
.
allDocs
({
metadata_only
:
metadata_only
},
o
.
f
);
metadata_only
:
metadata_only
});
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
server
.
respond
();
server
.
respond
();
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
...
@@ -804,16 +796,34 @@ test ('Get Document List', function () {
...
@@ -804,16 +796,34 @@ test ('Get Document List', function () {
url
:
'
https://ca-davstorage:8080
'
,
url
:
'
https://ca-davstorage:8080
'
,
applicationname
:
'
jiotests
'
});
applicationname
:
'
jiotests
'
});
o
.
mytest
(
'
fail to get list
'
,
true
,
undefined
,
404
);
o
.
mytest
(
'
fail to get list
'
,
true
,
undefined
,
404
);
o
.
mytest
(
'
getting list
'
,
true
,[{
name
:
'
file
'
,
creation_date
:
1335962911000
,
o
.
mytest
(
'
getting list
'
,
true
,[{
last_modified
:
1335962907000
},
id
:
'
file
'
,
key
:
'
file
'
,
{
name
:
'
memo
'
,
creation_date
:
1335894073000
,
value
:{
last_modified
:
1335955713000
}],
207
);
_creation_date
:
1335962911000
,
o
.
mytest
(
'
getting list
'
,
false
,[{
name
:
'
file
'
,
content
:
'
content
'
,
_last_modified
:
1335962907000
creation_date
:
1335962911000
,
}
last_modified
:
1335962907000
},
},{
{
name
:
'
memo
'
,
content
:
'
content2
'
,
id
:
'
memo
'
,
key
:
'
memo
'
,
creation_date
:
1335894073000
,
value
:{
last_modified
:
1335955713000
}],
207
);
_creation_date
:
1335894073000
,
_last_modified
:
1335955713000
}
}],
207
);
o
.
mytest
(
'
getting list
'
,
false
,[{
id
:
'
file
'
,
key
:
'
file
'
,
value
:{
content
:
'
content
'
,
_creation_date
:
1335962911000
,
_last_modified
:
1335962907000
}
},{
id
:
'
memo
'
,
key
:
'
memo
'
,
value
:{
content
:
'
content2
'
,
_creation_date
:
1335894073000
,
_last_modified
:
1335955713000
}
}],
207
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -825,18 +835,16 @@ test ('Remove document', function () {
...
@@ -825,18 +835,16 @@ test ('Remove document', function () {
o
.
mytest
=
function
(
message
,
value
,
errnodel
)
{
o
.
mytest
=
function
(
message
,
value
,
errnodel
)
{
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
var
server
=
o
.
t
.
sandbox
.
useFakeServer
();
server
.
respondWith
(
server
.
respondWith
(
"
DELETE
"
,
"
https://ca-davstorage:8080/dav
/dav
remove/jiotests/file
"
,
"
DELETE
"
,
"
https://ca-davstorage:8080/davremove/jiotests/file
"
,
[
errnodel
,{},
''
]);
[
errnodel
,{},
''
]);
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
result
&&
result
.
status
)
{
if
(
err
)
{
result
=
'
fail
'
;
err
=
err
.
status
;
}
else
{
result
=
'
done
'
;
}
}
deepEqual
(
result
,
value
,
message
);
deepEqual
(
err
||
val
,
value
,
message
);
};
};
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
t
.
spy
(
o
,
'
f
'
);
o
.
jio
.
remove
Document
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},
o
.
f
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
server
.
respond
();
server
.
respond
();
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
...
@@ -850,10 +858,10 @@ test ('Remove document', function () {
...
@@ -850,10 +858,10 @@ test ('Remove document', function () {
o
.
jio
=
JIO
.
newJio
({
type
:
'
dav
'
,
username
:
'
davremove
'
,
o
.
jio
=
JIO
.
newJio
({
type
:
'
dav
'
,
username
:
'
davremove
'
,
password
:
'
checkpwd
'
,
password
:
'
checkpwd
'
,
url
:
'
https://ca-davstorage:8080
'
,
url
:
'
https://ca-davstorage:8080
'
,
appli
ac
tionname
:
'
jiotests
'
});
appli
ca
tionname
:
'
jiotests
'
});
o
.
mytest
(
'
remove document
'
,
'
done
'
,
204
);
o
.
mytest
(
'
remove document
'
,
{
ok
:
true
,
id
:
'
file
'
}
,
204
);
o
.
mytest
(
'
remove an already removed document
'
,
'
done
'
,
404
);
o
.
mytest
(
'
remove an already removed document
'
,
404
,
404
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
...
OfficeJS/test/responsexml/davlist
View file @
bbf74f1f
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:href>
/dav
/dav
getlist/jiotests/
</D:href>
<D:href>
/davgetlist/jiotests/
</D:href>
<D:propstat>
<D:propstat>
<D:prop>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
</D:propstat>
</D:propstat>
</D:response>
</D:response>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:href>
/dav
/dav
getlist/jiotests/file
</D:href>
<D:href>
/davgetlist/jiotests/file
</D:href>
<D:propstat>
<D:propstat>
<D:prop>
<D:prop>
<lp1:resourcetype/>
<lp1:resourcetype/>
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</D:propstat>
</D:propstat>
</D:response>
</D:response>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:href>
/dav
/dav
getlist/jiotests/memo
</D:href>
<D:href>
/davgetlist/jiotests/memo
</D:href>
<D:propstat>
<D:propstat>
<D:prop>
<D:prop>
<lp1:resourcetype/>
<lp1:resourcetype/>
...
...
OfficeJS/test/responsexml/davload
View file @
bbf74f1f
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:href>
/dav
/dav
load/jiotests/file
</D:href>
<D:href>
/davload/jiotests/file
</D:href>
<D:propstat>
<D:propstat>
<D:prop>
<D:prop>
<lp1:resourcetype/>
<lp1:resourcetype/>
...
...
OfficeJS/test/responsexml/davsave
View file @
bbf74f1f
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:multistatus
xmlns:D=
"DAV:"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:response
xmlns:lp1=
"DAV:"
xmlns:lp2=
"http://apache.org/dav/props/"
>
<D:href>
/dav
/dav
save/jiotests/file
</D:href>
<D:href>
/davsave/jiotests/file
</D:href>
<D:propstat>
<D:propstat>
<D:prop>
<D:prop>
<lp1:resourcetype/>
<lp1:resourcetype/>
...
...
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