Skip to content

Commit 1e581fa

Browse files
committed
Handle test ICCIDs. Do not error if test ICCIDs are present
1 parent a47850b commit 1e581fa

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/cmd/esim.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const PROVISIONING_FAILURE = 3;
1818
const CTRL_REQUEST_APP_CUSTOM = 10;
1919
const GET_AT_COMMAND_STATUS = 4;
2020

21+
const TEST_ICCIDs = ['89000123456789012341', '89000123456789012358'];
22+
2123
module.exports = class ESimCommands extends CLICommandBase {
2224
constructor() { // TODO: Bring ui class
2325
super();
@@ -155,11 +157,22 @@ module.exports = class ESimCommands extends CLICommandBase {
155157
await processOutput();
156158
return;
157159
}
158-
if (profileCmdResp.details.existingProfiles.length > 0) {
159-
success = false;
160-
provisionOutputLogs.push('Profiles already exist on the device');
161-
await processOutput();
162-
return;
160+
const existingProfiles = profileCmdResp.details.existingProfiles;
161+
if (existingProfiles.length > 0) {
162+
// remove profiles with test ICCID from existingProfiles to verify
163+
existingProfiles.forEach((profile, index) => {
164+
const iccid = profile.split('[')[1].split(',')[0].trim();
165+
if (TEST_ICCIDs.includes(iccid)) {
166+
existingProfiles.splice(index, 1);
167+
}
168+
});
169+
170+
if (existingProfiles.length > 0) {
171+
success = false;
172+
provisionOutputLogs.push('Profiles already exist on the device');
173+
await processOutput();
174+
return;
175+
}
163176
}
164177

165178
// Get the next available profile list from availableProvisioningData
@@ -244,7 +257,11 @@ module.exports = class ESimCommands extends CLICommandBase {
244257
};
245258
const profilesOnDeviceAfterDownload = await this._listProfiles(port);
246259
const iccidsOnDeviceAfterDownload = profilesOnDeviceAfterDownload.map((line) => line.split('[')[1].split(',')[0].trim());
247-
const equal = _.isEqual(_.sortBy(iccidsOnDeviceAfterDownload), _.sortBy(expectedIccids));
260+
261+
// remove test ICCIDs from iccidsOnDeviceAfterDownload
262+
const iccidsOnDeviceAfterDownloadFiltered = iccidsOnDeviceAfterDownload.filter((iccid) => !TEST_ICCIDs.includes(iccid));
263+
264+
const equal = _.isEqual(_.sortBy(iccidsOnDeviceAfterDownload), _.sortBy(iccidsOnDeviceAfterDownloadFiltered));
248265

249266
res.details.iccidsOnDevice = iccidsOnDeviceAfterDownload;
250267
res.details.rawLogs.push(equal ? ['Profiles on device match the expected profiles'] :

0 commit comments

Comments
 (0)