Commit dd4259b2 authored by Romain Courteaud's avatar Romain Courteaud

[linshare] Test constructor

parent 69bcde2b
......@@ -56,7 +56,7 @@
// Use cookie based auth
/*
headers : {
"Authorization": "Basic " + storage._credential_token
"Authorization": "Basic " + storage._access_token
}
*/
options.xhrFields.withCredentials = true;
......@@ -77,13 +77,21 @@
* @constructor
*/
function LinshareStorage(spec) {
if (typeof spec.url !== "string" || !spec.url) {
throw new TypeError("Linshare 'url' must be a string " +
"which contains more than one character.");
}
this._url_template = UriTemplate.parse(
spec.url + '/linshare/webservice/rest/user/v2/documents/{uuid}'
);
this._blob_template = UriTemplate.parse(
spec.url + '/linshare/webservice/rest/user/v2/documents/{uuid}/download'
);
// this._credential_token = spec.credential_token;
if (spec.hasOwnProperty('access_token')) {
this._access_token = spec.access_token;
}
}
var capacity_list = ['list', 'include'];
......
......@@ -37,9 +37,41 @@
test("create storage", function () {
var jio = jIO.createJIO({
type: "linshare"
type: "linshare",
url: "https://example.org/foo"
});
equal(jio.__type, "linshare");
deepEqual(
jio.__storage._url_template.templateText,
"https://example.org/foo/linshare/webservice/rest/user/" +
"v2/documents/{uuid}"
);
deepEqual(
jio.__storage._blob_template.templateText,
"https://example.org/foo/linshare/webservice/rest/user/" +
"v2/documents/{uuid}/download"
);
equal(jio.__storage._credential_token, undefined);
});
test("create storage store access token", function () {
var jio = jIO.createJIO({
type: "linshare",
url: "https://example.org/bar",
access_token: "azerty"
});
equal(jio.__type, "linshare");
deepEqual(
jio.__storage._url_template.templateText,
"https://example.org/bar/linshare/webservice/rest/user/" +
"v2/documents/{uuid}"
);
deepEqual(
jio.__storage._blob_template.templateText,
"https://example.org/bar/linshare/webservice/rest/user/" +
"v2/documents/{uuid}/download"
);
equal(jio.__storage._access_token, "azerty");
});
/////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment