зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1153806 - Enable encryption of Loop room context data. r=mikedeboer
This commit is contained in:
Родитель
770f6907dd
Коммит
887d95a4a7
|
@ -232,11 +232,6 @@ let LoopRoomsInternal = {
|
|||
};
|
||||
}
|
||||
|
||||
// For now, disable encryption/context if context is disabled
|
||||
if (!MozLoopService.getLoopPref("contextInConverations.enabled")) {
|
||||
return getUnencryptedData();
|
||||
}
|
||||
|
||||
var newRoomData = extend({}, roomData);
|
||||
|
||||
if (!newRoomData.context) {
|
||||
|
@ -745,7 +740,8 @@ let LoopRoomsInternal = {
|
|||
};
|
||||
|
||||
// If we're not encrypting currently, then only send the roomName.
|
||||
if (!Services.prefs.getBoolPref("loop.contextInConverations.enabled")) {
|
||||
// XXX This should go away once bug 1153788 is fixed.
|
||||
if (!sendData.context) {
|
||||
sendData = {
|
||||
roomName: newRoomName
|
||||
};
|
||||
|
|
|
@ -11,8 +11,6 @@ Cu.import("resource://gre/modules/Promise.jsm");
|
|||
|
||||
let openChatOrig = Chat.open;
|
||||
|
||||
const kContextEnabledPref = "loop.contextInConverations.enabled";
|
||||
|
||||
const kGuestKey = "uGIs-kGbYt1hBBwjyW7MLQ";
|
||||
|
||||
// Rooms details as responded by the server.
|
||||
|
@ -292,14 +290,10 @@ add_task(function* setup_server() {
|
|||
let body = CommonUtils.readBytesFromInputStream(req.bodyInputStream);
|
||||
let data = JSON.parse(body);
|
||||
|
||||
if (Services.prefs.getBoolPref(kContextEnabledPref)) {
|
||||
Assert.equal(data.roomOwner, kCreateRoomProps.roomOwner);
|
||||
Assert.equal(data.maxSize, kCreateRoomProps.maxSize);
|
||||
Assert.ok(!("decryptedContext" in data), "should not have any decrypted data");
|
||||
Assert.ok("context" in data, "should have context");
|
||||
} else {
|
||||
Assert.deepEqual(data, kCreateRoomUnencryptedProps);
|
||||
}
|
||||
Assert.equal(data.roomOwner, kCreateRoomProps.roomOwner);
|
||||
Assert.equal(data.maxSize, kCreateRoomProps.maxSize);
|
||||
Assert.ok(!("decryptedContext" in data), "should not have any decrypted data");
|
||||
Assert.ok("context" in data, "should have context");
|
||||
|
||||
res.write(JSON.stringify(kCreateRoomData));
|
||||
} else {
|
||||
|
@ -346,15 +340,11 @@ add_task(function* setup_server() {
|
|||
res.finish();
|
||||
} else if (req.method == "PATCH") {
|
||||
let data = getJSONData(req.bodyInputStream);
|
||||
if (Services.prefs.getBoolPref(kContextEnabledPref)) {
|
||||
Assert.ok("context" in data, "should have encrypted context");
|
||||
// We return a fake encrypted name here as the context is
|
||||
// encrypted.
|
||||
returnRoomDetails(res, "fakeEncrypted");
|
||||
} else {
|
||||
Assert.ok(!("context" in data), "should not have encrypted context");
|
||||
returnRoomDetails(res, data.roomName);
|
||||
}
|
||||
|
||||
Assert.ok("context" in data, "should have encrypted context");
|
||||
// We return a fake encrypted name here as the context is
|
||||
// encrypted.
|
||||
returnRoomDetails(res, "fakeEncrypted");
|
||||
} else {
|
||||
roomDetail.context = room.context;
|
||||
res.setStatusLine(null, 200, "OK");
|
||||
|
@ -408,20 +398,6 @@ add_task(function* test_errorStates() {
|
|||
|
||||
// Test if creating a new room works as expected.
|
||||
add_task(function* test_createRoom() {
|
||||
Services.prefs.setBoolPref(kContextEnabledPref, true);
|
||||
|
||||
var expectedRoom = extend({}, kCreateRoomProps);
|
||||
expectedRoom.roomToken = kCreateRoomData.roomToken;
|
||||
|
||||
gExpectedAdds.push(expectedRoom);
|
||||
let room = yield LoopRooms.promise("create", kCreateRoomProps);
|
||||
compareRooms(room, expectedRoom);
|
||||
});
|
||||
|
||||
// XXX Test unencrypted rooms. This will go away once we switch encryption on.
|
||||
add_task(function* test_createRoom_unencrypted() {
|
||||
Services.prefs.setBoolPref(kContextEnabledPref, false);
|
||||
|
||||
var expectedRoom = extend({}, kCreateRoomProps);
|
||||
expectedRoom.roomToken = kCreateRoomData.roomToken;
|
||||
|
||||
|
@ -594,19 +570,11 @@ add_task(function* test_sendConnectionStatus() {
|
|||
|
||||
// Test if renaming a room works as expected.
|
||||
add_task(function* test_renameRoom() {
|
||||
Services.prefs.setBoolPref(kContextEnabledPref, true);
|
||||
let roomToken = "_nxD4V4FflQ";
|
||||
let renameData = yield LoopRooms.promise("rename", roomToken, "fakeName");
|
||||
Assert.equal(renameData.roomName, "fakeEncrypted", "should have set the new name");
|
||||
});
|
||||
|
||||
add_task(function* test_renameRoom_unencrpyted() {
|
||||
Services.prefs.setBoolPref(kContextEnabledPref, false);
|
||||
let roomToken = "_nxD4V4FflQ";
|
||||
let renameData = yield LoopRooms.promise("rename", roomToken, "fakeName");
|
||||
Assert.equal(renameData.roomName, "fakeName", "should have set the new name");
|
||||
});
|
||||
|
||||
add_task(function* test_roomDeleteNotifications() {
|
||||
gExpectedDeletes.push("_nxD4V4FflQ");
|
||||
roomsPushNotification("5", kChannelGuest);
|
||||
|
@ -650,7 +618,6 @@ function run_test() {
|
|||
do_register_cleanup(function () {
|
||||
// Revert original Chat.open implementation
|
||||
Chat.open = openChatOrig;
|
||||
Services.prefs.clearUserPref(kContextEnabledPref);
|
||||
Services.prefs.clearUserPref("loop.key");
|
||||
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = null;
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
Cu.import("resource://services-common/utils.js");
|
||||
const { LOOP_ROOMS_CACHE_FILENAME } = Cu.import("resource:///modules/loop/LoopRoomsCache.jsm", {});
|
||||
|
||||
const kContextEnabledPref = "loop.contextInConverations.enabled";
|
||||
|
||||
const kFxAKey = "uGIs-kGbYt1hBBwjyW7MLQ";
|
||||
|
||||
// Rooms details as responded by the server.
|
||||
|
@ -251,14 +249,12 @@ function run_test() {
|
|||
setupFakeLoopServer();
|
||||
|
||||
Services.prefs.setCharPref("loop.key.fxa", kFxAKey);
|
||||
Services.prefs.setBoolPref(kContextEnabledPref, true);
|
||||
|
||||
// Pretend we're signed into FxA.
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = { token_type: "bearer" };
|
||||
MozLoopServiceInternal.fxAOAuthProfile = { email: "fake@invalid.com" };
|
||||
|
||||
do_register_cleanup(function () {
|
||||
Services.prefs.clearUserPref(kContextEnabledPref);
|
||||
Services.prefs.clearUserPref("loop.key.fxa");
|
||||
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче