Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(simcard): add subscriber_id as legitimate data and keep data #120

Merged
merged 8 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/phone_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
"country": "fr",
"operator_code": "20815",
"operator_name": "Free",
"imsi": "8933150319050352521",
"serial": "8933150319050352521",
"state": "SIM_STATE_READY",
"phone_number": "+33632331095"
}
Expand Down
5 changes: 4 additions & 1 deletion inventory.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@
"items": {
"type": "object",
"properties": {
"imsi": {
"serial": {
"type": "string"
},
"phone_number": {
Expand All @@ -2225,6 +2225,9 @@
},
"operator_name": {
"type": "string"
},
"subscriber_id": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
4 changes: 0 additions & 4 deletions lib/php/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,6 @@ private function convertTo01(array $data)
'health',
'status'
],
'simcards' => [
'serial',
'subscriber_id'
],
'network_components' => [
'ip',
'mac'
Expand Down
6 changes: 3 additions & 3 deletions original.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,10 @@ Original XML specification
-->
<!ELEMENT TYPE (#PCDATA)>

<!ELEMENT SIMCARDS (IMSI, PHONE_NUMBER, ICCID, STATE, COUNTRY, OPERATOR_CODE,
<!ELEMENT SIMCARDS (SERIAL, PHONE_NUMBER, ICCID, STATE, COUNTRY, OPERATOR_CODE,
stonebuzz marked this conversation as resolved.
Show resolved Hide resolved
OPERATOR_NAME)>
<!-- IMSI -->
<!ELEMENT IMSI (#PCDATA)>
<!-- SERIAL -->
<!ELEMENT SERIAL (#PCDATA)>
<!-- Phone number -->
<!ELEMENT PHONE_NUMBER (#PCDATA)>
<!-- ICCID (serial number) -->
Expand Down
41 changes: 41 additions & 0 deletions tests/Glpi/Inventory/tests/units/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,47 @@ public function testFrBootTimeDateConvert()
$this->assertSame($expected, $json->content->operatingsystem->boot_time);
}

/**
* Test a full conversion and check simcard
*
* @return void
*/
public function testSimCard()
{
$xml_path = realpath(TU_DIR . '/data/18.xml');
$this->assertNotEmpty($xml_path);

$instance = new \Glpi\Inventory\Converter();
$json_str = $instance->convert(file_get_contents($xml_path));
$this->assertNotEmpty($json_str);

$json = json_decode($json_str);
$this->assertIsObject($json);
$this->assertSame('android-5a30d8711bbadc9d-2023-09-06-10-28-47', $json->deviceid);
$this->assertSame('Computer', $json->itemtype);


$expected = [
'country' => 'fr',
'operator_code' => '20810',
'operator_name' => 'F SFR',
'state' => 'SIM_STATE_READY',
'subscriber_id' => '1'

];
$this->assertSame($expected, (array)$json->content->simcards[0]);

$expected = [
'country' => 'fr',
'operator_code' => '20810',
'operator_name' => 'F SFR',
'state' => 'SIM_STATE_READY',
'subscriber_id' => '2'

];
$this->assertSame($expected, (array)$json->content->simcards[1]);
}

/**
* Test a full conversion and check boot time
*
Expand Down
Loading