Skip to content

A free open source IT asset/license management system

Possible fix for #11779 - Jamf school wifi/IP address

snipeb34adca7750d
diff --git a/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php b/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
index 8edba1c89d..32bb1eec22 100644
--- a/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
+++ b/app/SyncAdapters/JamfSchool/JamfSchoolAdapter.php
@@ -119,8 +119,14 @@ class JamfSchoolAdapter extends SyncAdapter
hardwareSerial: Arr::get($device, 'serialNumber'),
hardwareModel: Arr::get($device, 'model.name'),
manufacturer: 'Apple',
- primaryMac: Arr::get($device, 'wifiMacAddress'),
- primaryIp: null,
+ // Jamf School nests network info under `networkInformation`
+ // on every device class (confirmed on iPhone, iPad, and
+ // Mac payloads via issue #19856). The top-level
+ // `wifiMacAddress` key the earlier version read is never
+ // present, so the field always landed null regardless of
+ // device class.
+ primaryMac: Arr::get($device, 'networkInformation.WiFiMAC'),
+ primaryIp: Arr::get($device, 'networkInformation.IPAddress'),
os: Arr::get($device, 'os.prefix'),
osVersion: Arr::get($device, 'os.version'),
lastSeen: $this->parseTimestamp(Arr::get($device, 'lastCheckin')),
diff --git a/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php b/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
index 51c0549903..158e8dac39 100644
--- a/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
+++ b/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
@@ -108,6 +108,35 @@ class JamfSchoolAdapterTest extends TestCase
$this->assertNotNull($record->lastSeen);
}
+ public function test_network_information_surfaces_mac_and_ip(): void
+ {
+ // Regression test for issue #19856. Jamf School nests
+ // Wi-Fi MAC and IP under `networkInformation` on every
+ // device class. The earlier adapter read a top-level
+ // `wifiMacAddress` key that is never present in a Jamf
+ // School payload, so primaryMac + primaryIp both landed
+ // null across every synced device.
+ $adapter = $this->configuredJamfSchoolAdapter();
+
+ Http::fake([
+ '*/devices*' => Http::response([
+ 'count' => 1,
+ 'devices' => [
+ $this->jamfSchoolDevice(
+ udid: 'edu-udid-net',
+ wifiMac: '02:5c:a1:72:8d:30',
+ ipAddress: '192.0.2.42',
+ ),
+ ],
+ ]),
+ ]);
+
+ $records = iterator_to_array($adapter->pull());
+
+ $this->assertSame('02:5c:a1:72:8d:30', $records[0]->primaryMac);
+ $this->assertSame('192.0.2.42', $records[0]->primaryIp);
+ }
+
public function test_owner_block_populates_assigned_user_fields()
{
// Regression test for issue #19856. Jamf School carries the
@@ -180,6 +209,7 @@ class JamfSchoolAdapterTest extends TestCase
string $modelName = 'iPad',
?string $serial = null,
?string $wifiMac = null,
+ ?string $ipAddress = null,
?string $os = 'iPadOS',
?string $osVersion = null,
?string $lastCheckin = null,
@@ -197,7 +227,12 @@ class JamfSchoolAdapterTest extends TestCase
'prefix' => $os,
'version' => $osVersion,
],
- 'wifiMacAddress' => $wifiMac,
+ // Jamf School nests network info under this key on every
+ // device class (iPhone / iPad / Mac).
+ 'networkInformation' => [
+ 'WiFiMAC' => $wifiMac,
+ 'IPAddress' => $ipAddress,
+ ],
'lastCheckin' => $lastCheckin,
'isSupervised' => true,
'assetTag' => null,