From 4d2e27ecd1c6297157e85d371a93bf1125650b02 Mon Sep 17 00:00:00 2001 From: Fernando Jimenez Date: Fri, 24 Oct 2014 11:03:30 +0200 Subject: [PATCH] Bug 1086880 - Mobile ID is broken with v188 RIL. r=spenrose --- services/mobileid/MobileIdentityManager.jsm | 8 +- .../tests/xpcshell/test_mobileid_manager.js | 107 ++++++++++++++++++ 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/services/mobileid/MobileIdentityManager.jsm b/services/mobileid/MobileIdentityManager.jsm index ec46a38d178..cefb6a4a10a 100644 --- a/services/mobileid/MobileIdentityManager.jsm +++ b/services/mobileid/MobileIdentityManager.jsm @@ -163,7 +163,7 @@ this.MobileIdentityManager = { }; // _iccInfo is a local cache containing the information about the SIM cards - // that it is interesting for the Mobile ID flow. + // that is interesting for the Mobile ID flow. // The index of this array does not necesarily need to match the real // identifier of the SIM card ("clientId" or "serviceId" in RIL language). this._iccInfo = []; @@ -176,8 +176,10 @@ this.MobileIdentityManager = { } let info = rilContext.iccInfo; - if (!info) { - log.warn("No ICC info"); + if (!info || !info.iccid || + !info.mcc || !info.mcc.length || + !info.mnc || !info.mnc.length) { + log.warn("Absent or invalid ICC info"); continue; } diff --git a/services/mobileid/tests/xpcshell/test_mobileid_manager.js b/services/mobileid/tests/xpcshell/test_mobileid_manager.js index 6e7d84f6953..e778e93ab56 100644 --- a/services/mobileid/tests/xpcshell/test_mobileid_manager.js +++ b/services/mobileid/tests/xpcshell/test_mobileid_manager.js @@ -81,6 +81,29 @@ const ANOTHER_RADIO_INTERFACE = { } }; +const INVALID_RADIO_INTERFACE = { + rilContext: { + iccInfo: { + iccid: null, + mcc: "", + mnc: "", + msisdn: "", + operator: "" + } + }, + voice: { + network: { + shortName: "" + }, + roaming: undefined + }, + data: { + network: { + shortName: "" + } + } +}; + const CERTIFICATE = "eyJhbGciOiJEUzI1NiJ9.eyJsYXN0QXV0aEF0IjoxNDA0NDY5NzkyODc3LCJ2ZXJpZmllZE1TSVNETiI6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IxN2M3YTAzMjU5MzI5ZTQ4MjliMGQwM2JiYzc4OTZiMTViNGFkZTUzZTEzMDg1OGNjMzRkOTYyNjlhYTg5MDQxZjQwOTEzNmM3MjQyYTM4ODk1YzlkNWJjY2FkNGYzODlhZjFkN2E0YmQxMzk4YmQwNzJkZmZhODk2MjMzMzk3YSJ9LCJwcmluY2lwYWwiOiIwMzgxOTgyYS0xZTgzLTI1NjYtNjgzZS05MDRmNDA0NGM1MGRAbXNpc2RuLWRldi5zdGFnZS5tb3phd3MubmV0IiwiaWF0IjoxNDA0NDY5NzgyODc3LCJleHAiOjE0MDQ0OTEzOTI4NzcsImlzcyI6Im1zaXNkbi1kZXYuc3RhZ2UubW96YXdzLm5ldCJ9." // === Helpers === @@ -1460,6 +1483,90 @@ add_test(function() { }); }); +add_test(function() { + do_print("= Invalid ICC Info ="); + + do_register_cleanup(cleanup); + + do_test_pending(); + + let _sessionToken = Date.now(); + + MobileIdentityManager._iccInfo = null; + MobileIdentityManager._iccIds = null; + + MobileIdentityManager._ril = { + _interfaces: [INVALID_RADIO_INTERFACE], + get numRadioInterfaces() { + return this._interfaces.length; + }, + + getRadioInterface: function(aIndex) { + return this._interfaces[aIndex]; + } + }; + + MobileIdentityManager._mobileConnectionService = { + _interfaces: [INVALID_RADIO_INTERFACE], + getItemByServiceId: function(aIndex) { + return this._interfaces[aIndex]; + } + }; + + MobileIdentityManager._iccProvider = { + _listeners: [], + registerIccMsg: function(aClientId, aIccListener) { + this._listeners.push(aIccListener); + }, + unregisterIccMsg: function() { + this._listeners.pop(); + } + }; + + let ui = new MockUi(); + ui.startFlow = function() { + // At this point we've already built the ICC cache. + do_check_eq(MobileIdentityManager._iccInfo.length, 0); + do_check_eq(MobileIdentityManager._iccIds.length, 0); + + // We should have listeners for each valid icc. + do_check_eq(MobileIdentityManager._iccProvider._listeners.length, 0); + + do_test_finished(); + run_next_test(); + }; + MobileIdentityManager.ui = ui; + + let credStore = new MockCredStore(); + credStore.getByOrigin = function() { + // Initially the ICC caches should be null. + do_check_null(MobileIdentityManager._iccInfo); + do_check_null(MobileIdentityManager._iccIds); + return Promise.resolve(null); + }; + MobileIdentityManager.credStore = credStore; + + let client = new MockClient(); + MobileIdentityManager.client = client; + + let promiseId = Date.now(); + let mm = { + sendAsyncMessage: function() {} + }; + + addPermission(Ci.nsIPermissionManager.ALLOW_ACTION); + + MobileIdentityManager.receiveMessage({ + name: GET_ASSERTION_IPC_MSG, + principal: PRINCIPAL, + target: mm, + json: { + promiseId: promiseId, + options: {} + } + }); +}); + add_test(function() { do_print("= Cancel verification flow =");