mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Merge weave to weave-0.5-api w/ conflicts.
This commit is contained in:
commit
9be9fdd6c3
@ -8,11 +8,11 @@ fennec.login.error.detail = Login error: %S
|
||||
fennec.default.client.type = Mobile
|
||||
|
||||
fennec.sync.start = Syncing Now...
|
||||
fennec.sync.complete.time = Sync completed at %S, %S
|
||||
fennec.sync.complete.time = Sync completed at %1$S, %2$S
|
||||
fennec.sync.error.detail = Error: %S
|
||||
fennec.sync.error.generic = Weave had an error when trying to sync.
|
||||
fennec.sync.status = Syncing %S...
|
||||
fennec.sync.status.detail = Syncing (%S %S)...
|
||||
fennec.sync.status.detail = Syncing (%1$S %1$S)...
|
||||
|
||||
fennec.turn.weave.off = Turn Weave Off
|
||||
fennec.turn.weave.on = Turn Weave On
|
||||
|
@ -1,18 +0,0 @@
|
||||
<!ENTITY oauth.title "3rd Party Authorization">
|
||||
|
||||
<!ENTITY intro.title "3rd Party Authorization Wizard">
|
||||
<!ENTITY intro.msg "A third party has requested access to your Weave data. Before you can authorize the party, we must first authenticate you.">
|
||||
<!ENTITY intro.uid "Username:">
|
||||
<!ENTITY intro.pwd "Password:">
|
||||
<!ENTITY intro.pas "Verify Passphrase:">
|
||||
<!ENTITY intro.loading "Please Wait...">
|
||||
<!ENTITY intro.success "Your account has been verified! Please click Continue to proceed.">
|
||||
<!ENTITY intro.error "Your account could not be verified, please try again!">
|
||||
|
||||
<!ENTITY conf.title "Authorization">
|
||||
<!ENTITY conf.loading "Please wait while we verify the third party's request...">
|
||||
<!ENTITY conf.proceed "By clicking the Continue button, you automatically authorize the third party. If you do not wish to grant access, you may click the Cancel button.">
|
||||
|
||||
<!ENTITY final.title "Granting Access to third party">
|
||||
<!ENTITY final.processing "Please wait while your data is re-encrypted to enable access by the authorized third party...">
|
||||
<!ENTITY final.manual "Please notify the consumer that their request token was successfully authorized!">
|
@ -1,10 +0,0 @@
|
||||
intro.uidmsg = You are logged in as %S
|
||||
conf.conmsg = A third party identifying itself as %S is requesting access to your Weave Data.
|
||||
conf.error = Sorry, but the third party's request was invalid: %S
|
||||
conf.error1 = a request token was not issued.
|
||||
conf.error2 = the third party is unregistered.
|
||||
conf.error3 = the request token has expired.
|
||||
conf.error4 = your account details could not be verified.
|
||||
final.step1 = Unwrapping symmetric key...
|
||||
final.step2 = Adding third party to your keyring...
|
||||
final.step3 = Done!
|
9
services/sync/locales/en-US/pick-sync.dtd
Normal file
9
services/sync/locales/en-US/pick-sync.dtd
Normal file
@ -0,0 +1,9 @@
|
||||
<!ENTITY dialog.title "Sync with Weave">
|
||||
<!ENTITY dialog.accept "Sync">
|
||||
|
||||
<!ENTITY dir.caption "Direction to sync">
|
||||
<!ENTITY myComputer.label "[my computer]">
|
||||
<!ENTITY weaveCloud.label "[weave cloud]">
|
||||
<!ENTITY dir.resetClient.label "Do a fresh, full sync with the server">
|
||||
<!ENTITY dir.wipeClient.label "Erase local data and restart with server data">
|
||||
<!ENTITY dir.wipeRemote.label "Erase remote data and restart with local data">
|
@ -1,6 +0,0 @@
|
||||
<!ENTITY dialog.title "Weave Sharing">
|
||||
<!ENTITY close.button.label "Close">
|
||||
<!ENTITY share.button.label "Share">
|
||||
<!ENTITY description.top "Enter the Weave ID of the user you wish to share your bookmarks with:">
|
||||
<!ENTITY username.label "Weave ID:">
|
||||
<!ENTITY status.waiting "Waiting...">
|
@ -1,4 +0,0 @@
|
||||
status.ok = Weave sharing complete!
|
||||
status.error = Error. Please check the Weave ID and try again.
|
||||
status.working = Working...
|
||||
folder.message = You have chosen to share the bookmark folder "%S".
|
@ -131,12 +131,13 @@ RecordManager.prototype = {
|
||||
import: function RecordMgr_import(url) {
|
||||
this._log.trace("Importing record: " + (url.spec ? url.spec : url));
|
||||
try {
|
||||
this.lastResource = new Resource(url);
|
||||
this.lastResource.get();
|
||||
// Clear out the last response with empty object if GET fails
|
||||
this.response = {};
|
||||
this.response = new Resource(url).get();
|
||||
|
||||
let record = new this._recordType();
|
||||
record.deserialize(this.lastResource.data);
|
||||
record.uri = url; // NOTE: may override id in this.lastResource.data
|
||||
record.deserialize(this.response);
|
||||
record.uri = url;
|
||||
|
||||
return this.set(url, record);
|
||||
}
|
||||
|
@ -285,7 +285,9 @@ SyncEngine.prototype = {
|
||||
meta.generateIV();
|
||||
meta.addUnwrappedKey(pubkey, symkey);
|
||||
let res = new Resource(meta.uri);
|
||||
res.put(meta.serialize());
|
||||
let resp = res.put(meta.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
// Cache the cryto meta that we just put on the server
|
||||
CryptoMetas.set(meta.uri, meta);
|
||||
@ -343,7 +345,9 @@ SyncEngine.prototype = {
|
||||
Sync.sleep(0);
|
||||
});
|
||||
|
||||
newitems.get();
|
||||
let resp = newitems.get();
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
if (this.lastSync < this._lastSyncTmp)
|
||||
this.lastSync = this._lastSyncTmp;
|
||||
@ -464,13 +468,24 @@ SyncEngine.prototype = {
|
||||
// Upload what we've got so far in the collection
|
||||
let doUpload = Utils.bind2(this, function(desc) {
|
||||
this._log.info("Uploading " + desc + " of " + outnum + " records");
|
||||
<<<<<<< local
|
||||
up.post();
|
||||
=======
|
||||
let resp = up.post();
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
>>>>>>> other
|
||||
|
||||
<<<<<<< local
|
||||
// Record the modified time of the upload
|
||||
let modified = up._lastChannel.getResponseHeader("X-Weave-Timestamp");
|
||||
if (modified > this.lastSync)
|
||||
this.lastSync = modified;
|
||||
|
||||
=======
|
||||
if (up.data.modified > this.lastSync)
|
||||
this.lastSync = up.data.modified;
|
||||
>>>>>>> other
|
||||
up.clearRecords();
|
||||
});
|
||||
|
||||
|
@ -365,9 +365,12 @@ BookmarksStore.prototype = {
|
||||
record._insertPos, "as", record.title].join(" "));
|
||||
break;
|
||||
case "livemark":
|
||||
newId = this._ls.createLivemark(record._parent, record.title,
|
||||
Utils.makeURI(record.siteUri), Utils.makeURI(record.feedUri),
|
||||
record._insertPos);
|
||||
let siteURI = null;
|
||||
if (record.siteUri != null)
|
||||
siteURI = Utils.makeURI(record.siteUri);
|
||||
|
||||
newId = this._ls.createLivemark(record._parent, record.title, siteURI,
|
||||
Utils.makeURI(record.feedUri), record._insertPos);
|
||||
this._log.debug(["created livemark", newId, "under", record._parent, "at",
|
||||
record._insertPos, "as", record.title, record.siteUri, record.feedUri].
|
||||
join(" "));
|
||||
@ -621,7 +624,10 @@ BookmarksStore.prototype = {
|
||||
case this._bms.TYPE_FOLDER:
|
||||
if (this._ls.isLivemark(placeId)) {
|
||||
record = new Livemark();
|
||||
record.siteUri = this._ls.getSiteURI(placeId).spec;
|
||||
|
||||
let siteURI = this._ls.getSiteURI(placeId);
|
||||
if (siteURI != null)
|
||||
record.siteUri = siteURI.spec;
|
||||
record.feedUri = this._ls.getFeedURI(placeId).spec;
|
||||
|
||||
} else {
|
||||
|
@ -50,27 +50,6 @@ Cu.import("resource://weave/constants.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/auth.js");
|
||||
|
||||
// = RequestException =
|
||||
//
|
||||
// This function raises an exception through the call
|
||||
// stack for a failed network request.
|
||||
function RequestException(resource, action, request) {
|
||||
this._resource = resource;
|
||||
this._action = action;
|
||||
this._request = request;
|
||||
this.location = Components.stack.caller;
|
||||
}
|
||||
RequestException.prototype = {
|
||||
get resource() { return this._resource; },
|
||||
get action() { return this._action; },
|
||||
get request() { return this._request; },
|
||||
get status() { return this._request.status; },
|
||||
toString: function ReqEx_toString() {
|
||||
return "Could not " + this._action + " resource " + this._resource.spec +
|
||||
" (" + this._request.responseStatus + ")";
|
||||
}
|
||||
};
|
||||
|
||||
// = Resource =
|
||||
//
|
||||
// Represents a remote network resource, identified by a URI.
|
||||
@ -122,8 +101,6 @@ Resource.prototype = {
|
||||
return this._uri;
|
||||
},
|
||||
set uri(value) {
|
||||
this._dirty = true;
|
||||
this._downloaded = false;
|
||||
if (typeof value == 'string')
|
||||
this._uri = Utils.makeURI(value);
|
||||
else
|
||||
@ -145,17 +122,9 @@ Resource.prototype = {
|
||||
_data: null,
|
||||
get data() this._data,
|
||||
set data(value) {
|
||||
this._dirty = true;
|
||||
this._data = value;
|
||||
},
|
||||
|
||||
_lastChannel: null,
|
||||
_downloaded: false,
|
||||
_dirty: false,
|
||||
get lastChannel() this._lastChannel,
|
||||
get downloaded() this._downloaded,
|
||||
get dirty() this._dirty,
|
||||
|
||||
// ** {{{ Resource.filters }}} **
|
||||
//
|
||||
// Filters are used to perform pre and post processing on
|
||||
@ -188,18 +157,15 @@ Resource.prototype = {
|
||||
// to obtain a request channel.
|
||||
//
|
||||
_createRequest: function Res__createRequest() {
|
||||
this._lastChannel = Svc.IO.newChannel(this.spec, null, null).
|
||||
QueryInterface(Ci.nsIRequest);
|
||||
let channel = Svc.IO.newChannel(this.spec, null, null).
|
||||
QueryInterface(Ci.nsIRequest).QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
// Always validate the cache:
|
||||
let loadFlags = this._lastChannel.loadFlags;
|
||||
loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
|
||||
this._lastChannel.loadFlags = loadFlags;
|
||||
this._lastChannel = this._lastChannel.QueryInterface(Ci.nsIHttpChannel);
|
||||
channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
|
||||
|
||||
// Setup a callback to handle bad HTTPS certificates.
|
||||
this._lastChannel.notificationCallbacks = new badCertListener();
|
||||
channel.notificationCallbacks = new badCertListener();
|
||||
|
||||
// Avoid calling the authorizer more than once
|
||||
let headers = this.headers;
|
||||
@ -208,9 +174,9 @@ Resource.prototype = {
|
||||
this._log.trace("HTTP Header " + key + ": ***** (suppressed)");
|
||||
else
|
||||
this._log.trace("HTTP Header " + key + ": " + headers[key]);
|
||||
this._lastChannel.setRequestHeader(key, headers[key], false);
|
||||
channel.setRequestHeader(key, headers[key], false);
|
||||
}
|
||||
return this._lastChannel;
|
||||
return channel;
|
||||
},
|
||||
|
||||
_onProgress: function Res__onProgress(channel) {},
|
||||
@ -289,31 +255,44 @@ Resource.prototype = {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!channel.requestSucceeded) {
|
||||
this._log.debug(action + " request failed (" + channel.responseStatus + ")");
|
||||
if (this._data)
|
||||
this._log.debug("Error response: " + this._data);
|
||||
throw new RequestException(this, action, channel);
|
||||
|
||||
} else {
|
||||
this._log.debug(action + " request successful (" + channel.responseStatus + ")");
|
||||
|
||||
switch (action) {
|
||||
case "DELETE":
|
||||
if (Utils.checkStatus(channel.responseStatus, null, [[200,300],404])){
|
||||
this._dirty = false;
|
||||
this._data = null;
|
||||
// Set some default values in-case there's no response header
|
||||
let headers = {};
|
||||
let status = 0;
|
||||
let success = true;
|
||||
try {
|
||||
// Read out the response headers if available
|
||||
channel.visitResponseHeaders({
|
||||
visitHeader: function visitHeader(header, value) {
|
||||
headers[header] = value;
|
||||
}
|
||||
});
|
||||
status = channel.responseStatus;
|
||||
success = channel.requestSucceeded;
|
||||
|
||||
if (success) {
|
||||
this._log.debug(action + " success: " + status);
|
||||
switch (action) {
|
||||
case "GET":
|
||||
case "POST":
|
||||
if (this._log.level <= Log4Moz.Level.Trace)
|
||||
this._log.trace(action + " Body: " + this._data);
|
||||
this.filterDownload();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "GET":
|
||||
case "POST":
|
||||
this._log.trace(action + " Body: " + this._data);
|
||||
this.filterDownload();
|
||||
break;
|
||||
}
|
||||
else
|
||||
this._log.debug(action + " fail: " + status + " " + this._data);
|
||||
}
|
||||
// Got a response but no header; must be cached (use default values)
|
||||
catch(ex) {
|
||||
this._log.debug(action + " cached: " + status);
|
||||
}
|
||||
|
||||
return this._data;
|
||||
let ret = new String(this._data);
|
||||
ret.headers = headers;
|
||||
ret.status = status;
|
||||
ret.success = success;
|
||||
return ret;
|
||||
},
|
||||
|
||||
// ** {{{ Resource.get }}} **
|
||||
|
@ -459,18 +459,32 @@ WeaveSvc.prototype = {
|
||||
|
||||
let res = new Resource(this.baseURL + "1/" + username + "/node/weave");
|
||||
try {
|
||||
<<<<<<< local
|
||||
res.get();
|
||||
} catch(ex) {}
|
||||
|
||||
try {
|
||||
switch (res.lastChannel.responseStatus) {
|
||||
=======
|
||||
let node = res.get();
|
||||
switch (node.status) {
|
||||
>>>>>>> other
|
||||
case 404:
|
||||
this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)");
|
||||
<<<<<<< local
|
||||
return this.baseURL;
|
||||
=======
|
||||
return Svc.Prefs.get("serverURL");
|
||||
case 0:
|
||||
>>>>>>> other
|
||||
case 200:
|
||||
<<<<<<< local
|
||||
return res.data;
|
||||
=======
|
||||
return "https://" + node + "/";
|
||||
>>>>>>> other
|
||||
default:
|
||||
this._log.debug("Unexpected response code trying to find cluster: " + res.lastChannel.responseStatus);
|
||||
this._log.debug("Unexpected response code: " + node.status);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
@ -528,11 +542,8 @@ WeaveSvc.prototype = {
|
||||
|
||||
// login may fail because of cluster change
|
||||
try {
|
||||
res.get();
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
switch (res.lastChannel.responseStatus) {
|
||||
let test = res.get();
|
||||
switch (test.status) {
|
||||
case 200:
|
||||
if (passphrase && !this.verifyPassphrase(username, password, passphrase)) {
|
||||
this._setSyncFailure(LOGIN_FAILED_INVALID_PASSPHRASE);
|
||||
@ -547,7 +558,7 @@ WeaveSvc.prototype = {
|
||||
this._log.debug("verifyLogin failed: login failed")
|
||||
return false;
|
||||
default:
|
||||
throw "unexpected HTTP response: " + res.lastChannel.responseStatus;
|
||||
throw "unexpected HTTP response: " + test.status;
|
||||
}
|
||||
} catch (e) {
|
||||
// if we get here, we have either a busted channel or a network error
|
||||
@ -590,7 +601,10 @@ WeaveSvc.prototype = {
|
||||
privkey.payload.iv, newphrase);
|
||||
privkey.payload.keyData = newkey;
|
||||
|
||||
new Resource(privkey.uri).put(privkey.serialize());
|
||||
let resp = new Resource(privkey.uri).put(privkey.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
this.passphrase = newphrase;
|
||||
|
||||
return true;
|
||||
@ -602,8 +616,13 @@ WeaveSvc.prototype = {
|
||||
let res = new Weave.Resource(url);
|
||||
res.authenticator = new Weave.NoOpAuthenticator();
|
||||
|
||||
<<<<<<< local
|
||||
let resp = res.post(newpass);
|
||||
if (res.lastChannel.responseStatus != 200) {
|
||||
=======
|
||||
let resp = res.post(message);
|
||||
if (resp.status != 200) {
|
||||
>>>>>>> other
|
||||
this._log.info("Password change failed: " + resp);
|
||||
throw "Could not change password";
|
||||
}
|
||||
@ -730,7 +749,7 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
_errorStr: function WeaveSvc__errorStr(code) {
|
||||
switch (code) {
|
||||
switch (code.toString()) {
|
||||
case "0":
|
||||
return "uid-in-use";
|
||||
case "-1":
|
||||
@ -770,7 +789,7 @@ WeaveSvc.prototype = {
|
||||
let data = "";
|
||||
try {
|
||||
data = res.get();
|
||||
if (res.lastChannel.responseStatus == 200 && data == "0")
|
||||
if (data.status == 200 && data == "0")
|
||||
return "available";
|
||||
}
|
||||
catch(ex) {}
|
||||
@ -792,30 +811,41 @@ WeaveSvc.prototype = {
|
||||
let res = new Resource(url);
|
||||
res.authenticator = new Weave.NoOpAuthenticator();
|
||||
|
||||
let ret = {};
|
||||
let error = "generic-server-error";
|
||||
try {
|
||||
<<<<<<< local
|
||||
ret.response = res.put(payload);
|
||||
ret.status = res.lastChannel.responseStatus;
|
||||
=======
|
||||
let register = res.post(message);
|
||||
if (register.success) {
|
||||
this._log.info("Account created: " + register);
|
||||
return;
|
||||
}
|
||||
>>>>>>> other
|
||||
|
||||
<<<<<<< local
|
||||
// No exceptions must have meant it was successful
|
||||
this._log.info("Account created: " + ret.response);
|
||||
return ret;
|
||||
} catch(ex) {
|
||||
this._log.warn("Failed to create account: " + ex);
|
||||
let status = ex.request.responseStatus;
|
||||
switch (status) {
|
||||
=======
|
||||
// Must have failed, so figure out the reason
|
||||
switch (register.status) {
|
||||
case 400:
|
||||
ret.error = this._errorStr(status);
|
||||
error = this._errorStr(register);
|
||||
break;
|
||||
case 417:
|
||||
ret.error = "captcha-incorrect";
|
||||
break;
|
||||
default:
|
||||
ret.error = "generic-server-error";
|
||||
error = "captcha-incorrect";
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
catch(ex) {
|
||||
>>>>>>> other
|
||||
this._log.warn("Failed to create account: " + ex);
|
||||
}
|
||||
|
||||
return error;
|
||||
},
|
||||
|
||||
// stuff we need to to after login, before we can really do
|
||||
@ -836,7 +866,7 @@ WeaveSvc.prototype = {
|
||||
Svc.Version.compare(COMPATIBLE_VERSION, remoteVersion) > 0) {
|
||||
|
||||
// abort the server wipe if the GET status was anything other than 404 or 200
|
||||
let status = Records.lastResource.lastChannel.responseStatus;
|
||||
let status = Records.response.status;
|
||||
if (status != 200 && status != 404) {
|
||||
this._setSyncFailure(METARECORD_DOWNLOAD_FAIL);
|
||||
this._log.warn("Unknown error while downloading metadata record. " +
|
||||
@ -905,14 +935,10 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
|
||||
if (needKeys) {
|
||||
if (PubKeys.lastResource != null && PrivKeys.lastResource != null &&
|
||||
PubKeys.lastResource.lastChannel.responseStatus != 404 &&
|
||||
PrivKeys.lastResource.lastChannel.responseStatus != 404) {
|
||||
if (PubKeys.response.status != 404 && PrivKeys.response.status != 404) {
|
||||
this._log.warn("Couldn't download keys from server, aborting sync");
|
||||
this._log.debug("PubKey HTTP response status: " +
|
||||
PubKeys.lastResource.lastChannel.responseStatus);
|
||||
this._log.debug("PrivKey HTTP response status: " +
|
||||
PrivKeys.lastResource.lastChannel.responseStatus);
|
||||
this._log.debug("PubKey HTTP status: " + PubKeys.response.status);
|
||||
this._log.debug("PrivKey HTTP status: " + PrivKeys.response.status);
|
||||
this._setSyncFailure(KEYS_DOWNLOAD_FAIL);
|
||||
return false;
|
||||
}
|
||||
@ -943,8 +969,6 @@ WeaveSvc.prototype = {
|
||||
} catch (e) {
|
||||
this._setSyncFailure(KEYS_UPLOAD_FAIL);
|
||||
this._log.error("Could not upload keys: " + Utils.exceptionStr(e));
|
||||
// FIXME no lastRequest anymore
|
||||
//this._log.error(keys.pubkey.lastRequest.responseText);
|
||||
}
|
||||
} else {
|
||||
this._setSyncFailure(SETUP_FAILED_NO_PASSPHRASE);
|
||||
@ -1060,7 +1084,8 @@ WeaveSvc.prototype = {
|
||||
// this is sort of pseudocode, need a way to get at the
|
||||
if (!shouldBackoff) {
|
||||
try {
|
||||
shouldBackoff = Utils.checkStatus(Records.lastResource.lastChannel.responseStatus, null, [500,[502,504]]);
|
||||
shouldBackoff = Utils.checkStatus(Records.response.status, null,
|
||||
[500, [502, 504]]);
|
||||
}
|
||||
catch (e) {
|
||||
// if responseStatus throws, we have a network issue in play
|
||||
@ -1213,10 +1238,9 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
catch(e) {
|
||||
// maybe a 401, cluster update needed?
|
||||
if (e.constructor.name == "RequestException" && e.status == 401) {
|
||||
if (this.updateCluster(this.username))
|
||||
return this._syncEngine(engine);
|
||||
}
|
||||
if (e.status == 401 && this.updateCluster(this.username))
|
||||
return this._syncEngine(engine);
|
||||
|
||||
this._syncError = true;
|
||||
this._weaveStatusCode = WEAVE_STATUS_PARTIAL;
|
||||
this._detailedStatus.setEngineStatus(engine.name, e);
|
||||
@ -1247,8 +1271,9 @@ WeaveSvc.prototype = {
|
||||
|
||||
this._log.debug("Setting meta payload storage version to " + WEAVE_VERSION);
|
||||
meta.payload.storageVersion = WEAVE_VERSION;
|
||||
let res = new Resource(meta.uri);
|
||||
res.put(meta.serialize());
|
||||
let resp = new Resource(meta.uri).put(meta.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ function run_test() {
|
||||
let res = new Resource("http://localhost:8080/foo");
|
||||
let content = res.get();
|
||||
do_check_eq(content, "This path exists and is protected");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
|
||||
server.stop();
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ function run_test() {
|
||||
|
||||
let pubkey = PubKeys.get("http://localhost:8080/pubkey");
|
||||
do_check_eq(pubkey.data.payload.type, "pubkey");
|
||||
do_check_eq(PubKeys.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(PubKeys.response.status, 200);
|
||||
|
||||
log.info("Getting matching private key");
|
||||
|
||||
let privkey = PrivKeys.get(pubkey.privateKeyUri);
|
||||
do_check_eq(privkey.data.payload.type, "privkey");
|
||||
do_check_eq(PrivKeys.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(PrivKeys.response.status, 200);
|
||||
|
||||
log.info("Done!");
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ function run_test() {
|
||||
log.info("Getting a WBO record");
|
||||
|
||||
let res = new Resource("http://localhost:8080/record");
|
||||
res.get();
|
||||
let resp = res.get();
|
||||
|
||||
let rec = new WBORecord();
|
||||
rec.deserialize(res.data);
|
||||
@ -60,7 +60,7 @@ function run_test() {
|
||||
do_check_eq(rec.modified, 2454725.98283);
|
||||
do_check_eq(typeof(rec.payload), "object");
|
||||
do_check_eq(rec.payload.cheese, "roquefort");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(resp.status, 200);
|
||||
|
||||
log.info("Getting a WBO record using the record manager");
|
||||
|
||||
@ -69,7 +69,7 @@ function run_test() {
|
||||
do_check_eq(rec2.modified, 2454725.98284);
|
||||
do_check_eq(typeof(rec2.payload), "object");
|
||||
do_check_eq(rec2.payload.cheese, "gruyere");
|
||||
do_check_eq(Records.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(Records.response.status, 200);
|
||||
|
||||
log.info("Done!");
|
||||
}
|
||||
|
@ -56,14 +56,15 @@ function run_test() {
|
||||
let res = new Resource("http://localhost:8080/open");
|
||||
let content = res.get();
|
||||
do_check_eq(content, "This path exists");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
do_check_true(content.success);
|
||||
|
||||
// 2. A password protected resource (test that it'll fail w/o pass)
|
||||
// 2. A password protected resource (test that it'll fail w/o pass, no throw)
|
||||
let res2 = new Resource("http://localhost:8080/protected");
|
||||
try {
|
||||
content = res2.get();
|
||||
do_check_true(false); // unreachable, get() above must fail
|
||||
} catch (e) {}
|
||||
content = res2.get();
|
||||
do_check_eq(content, "This path exists and is protected - failed")
|
||||
do_check_eq(content.status, 401);
|
||||
do_check_false(content.success);
|
||||
|
||||
// 3. A password protected resource
|
||||
|
||||
@ -72,17 +73,21 @@ function run_test() {
|
||||
res3.authenticator = auth;
|
||||
content = res3.get();
|
||||
do_check_eq(content, "This path exists and is protected");
|
||||
do_check_eq(res3.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
do_check_true(content.success);
|
||||
|
||||
// 4. A non-existent resource (test that it'll fail)
|
||||
// 4. A non-existent resource (test that it'll fail, but not throw)
|
||||
|
||||
let res4 = new Resource("http://localhost:8080/404");
|
||||
try {
|
||||
let content = res4.get();
|
||||
do_check_true(false); // unreachable, get() above must fail
|
||||
} catch (e) {}
|
||||
do_check_eq(res4.lastChannel.responseStatusText, "Not Found");
|
||||
do_check_eq(res4.lastChannel.responseStatus, 404);
|
||||
content = res4.get();
|
||||
do_check_eq(content, "File not found");
|
||||
do_check_eq(content.status, 404);
|
||||
do_check_false(content.success);
|
||||
|
||||
_("5. Check some headers of the 404 response");
|
||||
do_check_eq(content.headers.Connection, "close");
|
||||
do_check_eq(content.headers.Server, "httpd.js");
|
||||
do_check_eq(content.headers["Content-Length"], 14);
|
||||
|
||||
// FIXME: additional coverage needed:
|
||||
// * PUT requests
|
||||
|
Loading…
x
Reference in New Issue
Block a user