Automated merge with http://hg.mozilla.org/labs/weave
authorAtul Varma <varmaa@toolness.com>
Mon, 30 Jun 2008 23:36:06 -0700
changeset 44863 a861ed0bfdff8bb6327973a9061e48747088c13a
parent 44861 16d47211c135e2bf0e8441062d4ed9c576f09937 (current diff)
parent 44862 0587eb06d2906f087672ab7791f0f264f30a1293 (diff)
child 44865 36412fe43dcefc2cf87494f96396ce338d9be2ee
push id14033
push useredward.lee@engineering.uiuc.edu
push dateWed, 23 Jun 2010 22:21:35 +0000
treeherderautoland@227db4ad8cdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Automated merge with http://hg.mozilla.org/labs/weave
--- a/services/sync/modules/sharing.js
+++ b/services/sync/modules/sharing.js
@@ -36,16 +36,17 @@
 
 EXPORTED_SYMBOLS = ["Sharing"];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://weave/async.js");
+Cu.import("resource://weave/identity.js");
 
 Function.prototype.async = Async.sugar;
 
 function Api(dav) {
   this._dav = dav;
 }
 
 Api.prototype = {
@@ -53,26 +54,31 @@ Api.prototype = {
     this._shareGenerator.async(this,
                                onComplete,
                                path,
                                users);
   },
 
   _shareGenerator: function Api__shareGenerator(path, users) {
     let self = yield;
+    let id = ID.get(this._dav.identity);
 
     this._dav.defaultPrefix = "";
 
     let cmd = {"version" : 1,
                "directory" : path,
                "share_to_users" : users};
     let jsonSvc = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
     let json = jsonSvc.encode(cmd);
 
-    this._dav.POST("share/", "cmd=" + escape(json), self.cb);
+    this._dav.POST("share/",
+                   ("cmd=" + escape(json) +
+                    "&uid=" + escape(id.username) +
+                    "&password=" + escape(id.password)),
+                   self.cb);
     let xhr = yield;
 
     let retval;
 
     if (xhr.status == 200) {
       if (xhr.responseText == "OK") {
         retval = {wasSuccessful: true};
       } else {
--- a/services/sync/tests/unit/test_sharing.js
+++ b/services/sync/tests/unit/test_sharing.js
@@ -1,16 +1,23 @@
 Cu.import("resource://weave/sharing.js");
 Cu.import("resource://weave/util.js");
+Cu.import("resource://weave/identity.js");
 
 function runTestGenerator() {
   let self = yield;
 
+  ID.set("blarg", new Identity("realm", "myusername", "mypass"));
   let fakeDav = {
+    identity: "blarg",
     POST: function fakeDav_POST(url, data, callback) {
+      do_check_true(data.indexOf("uid=myusername") != -1);
+      do_check_true(data.indexOf("password=mypass") != -1);
+      do_check_true(data.indexOf("/fake/dir") != -1);
+      do_check_true(data.indexOf("johndoe") != -1);
       let result = {status: 200, responseText: "OK"};
       Utils.makeTimerForCall(function() { callback(result); });
     }
   };
 
   let api = new Sharing.Api(fakeDav);
   api.shareWithUsers("/fake/dir", ["johndoe"], self.cb);
   let result = yield;