Skip to content

Commit

Permalink
Bug 1086880 - Mobile ID is broken with v188 RIL. r=spenrose
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm committed Oct 24, 2014
1 parent 906cad4 commit 81d1515
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 3 deletions.
8 changes: 5 additions & 3 deletions services/mobileid/MobileIdentityManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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;
}

Expand Down
107 changes: 107 additions & 0 deletions services/mobileid/tests/xpcshell/test_mobileid_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.eyJsYXN0QXV0aEF0IjoxNDA0NDY5NzkyODc3LCJ2ZXJpZmllZE1TSVNETiI6IiszMTYxNzgxNTc1OCIsInB1YmxpYy1rZXkiOnsiYWxnb3JpdGhtIjoiRFMiLCJ5IjoiNGE5YzkzNDY3MWZhNzQ3YmM2ZjMyNjE0YTg1MzUyZjY5NDcwMDdhNTRkMDAxMDY4OWU5ZjJjZjc0ZGUwYTEwZTRlYjlmNDk1ZGFmZTA0NGVjZmVlNDlkN2YwOGU4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OTgyYS0xZTgzLTI1NjYtNjgzZS05MDRmNDA0NGM1MGRAbXNpc2RuLWRldi5zdGFnZS5tb3phd3MubmV0IiwiaWF0IjoxNDA0NDY5NzgyODc3LCJleHAiOjE0MDQ0OTEzOTI4NzcsImlzcyI6Im1zaXNkbi1kZXYuc3RhZ2UubW96YXdzLm5ldCJ9."

// === Helpers ===
Expand Down Expand Up @@ -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 =");

Expand Down

0 comments on commit 81d1515

Please sign in to comment.