Skip to content

A free open source IT asset/license management system

Rename from SyncHostFromAdaptert to SyncAdapter for flattening

snipebe116088ab60
diff --git a/app/Console/Commands/PullInventory.php b/app/Console/Commands/PullInventory.php
index 0d7a179168..390aaa538a 100644
--- a/app/Console/Commands/PullInventory.php
+++ b/app/Console/Commands/PullInventory.php
@@ -3,7 +3,7 @@
namespace App\Console\Commands;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Console\Command;
use Throwable;
@@ -108,7 +108,7 @@ class PullInventory extends Command
try {
foreach ($adapter->pull() as $record) {
try {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
$seen++;
} catch (Throwable $e) {
// A single bad record shouldn't take down the run.
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index 5f33209971..6a56a8456d 100644
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -1106,7 +1106,7 @@ class SettingsController extends Controller
try {
foreach ($adapter->pull() as $record) {
try {
- \App\SyncAdapters\SyncHostFromAdapter::run($record);
+ \App\SyncAdapters\SyncAdapter::syncFromRecord($record);
$seen++;
} catch (\Throwable $e) {
$errors++;
diff --git a/app/Models/AssetExternalSource.php b/app/Models/AssetExternalSource.php
index 327233137c..ab03813a84 100644
--- a/app/Models/AssetExternalSource.php
+++ b/app/Models/AssetExternalSource.php
@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* the last-known network / OS inventory the vendor reported
* (primary_mac / primary_ip / os / os_version / last_seen).
*
- * One row per asset today. SyncHostFromAdapter upserts on the
+ * One row per asset today. SyncAdapter upserts on the
* (source, external_id) unique index and updates the inventory
* columns on every sync run.
*/
diff --git a/app/Rules/AssetTagPatternRule.php b/app/Rules/AssetTagPatternRule.php
index 7684e749fc..6c40276d69 100644
--- a/app/Rules/AssetTagPatternRule.php
+++ b/app/Rules/AssetTagPatternRule.php
@@ -2,7 +2,7 @@
namespace App\Rules;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
@@ -21,18 +21,18 @@ class AssetTagPatternRule implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
- if (!is_string($value) || $value === '') {
+ if (! is_string($value) || $value === '') {
return;
}
- foreach (SyncHostFromAdapter::ASSET_TAG_PATTERN_PLACEHOLDERS as $placeholder) {
+ foreach (SyncAdapter::ASSET_TAG_PATTERN_PLACEHOLDERS as $placeholder) {
if (str_contains($value, $placeholder)) {
return;
}
}
$fail(trans('validation.asset_tag_pattern_placeholder', [
- 'placeholders' => implode(', ', SyncHostFromAdapter::ASSET_TAG_PATTERN_PLACEHOLDERS),
+ 'placeholders' => implode(', ', SyncAdapter::ASSET_TAG_PATTERN_PLACEHOLDERS),
]));
}
}
diff --git a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
index 03836852a7..dda32d7ed5 100644
--- a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
+++ b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerAdapter.php
@@ -424,7 +424,7 @@ class AppleBusinessManagerAdapter extends SyncAdapter
if ($existing === null) {
// First-pass timing: the framework hasn't created the
- // AssetModel row yet (SyncHostFromAdapter builds it after
+ // AssetModel row yet (SyncAdapter builds it after
// pull() yields), so there's nothing to update. The image
// is already downloaded and cached under public/uploads/
// models/ by the fetcher, so the next sync will find the
diff --git a/app/SyncAdapters/MappingTargets.php b/app/SyncAdapters/MappingTargets.php
index 23121337c4..dcd7ab58aa 100644
--- a/app/SyncAdapters/MappingTargets.php
+++ b/app/SyncAdapters/MappingTargets.php
@@ -8,7 +8,7 @@ use App\Models\CustomField;
* Enumerates the target options each normalized host-inventory field can
* be mapped to. Every adapter reads the same normalized shape (hostname,
* serial, model, mac, ip, os, os_version, last_seen) and hands it to
- * SyncHostFromAdapter. per-instance overrides let admins redirect each
+ * SyncAdapter. per-instance overrides let admins redirect each
* field to a different Snipe-IT destination (native column, side table,
* custom field, or skip).
*
@@ -40,7 +40,7 @@ class MappingTargets
/**
* The shipped default target for a field (before any per-instance
- * override). Used by SyncHostFromAdapter as the fallback.
+ * override). Used by SyncAdapter as the fallback.
*/
public static function defaultTarget(string $field): string
{
diff --git a/app/SyncAdapters/SyncAdapter.php b/app/SyncAdapters/SyncAdapter.php
index 34734db648..0e6f271afe 100644
--- a/app/SyncAdapters/SyncAdapter.php
+++ b/app/SyncAdapters/SyncAdapter.php
@@ -40,6 +40,13 @@ use Illuminate\Support\Facades\Crypt;
*/
abstract class SyncAdapter
{
+ // Asset-side upsert path. Exposes SyncAdapter::syncFromRecord($record) as
+ // the public entry point every caller hits. Kept in its own trait
+ // rather than inlined so this file stays focused on the adapter
+ // contract (settings, credentials, mapping, direction, group
+ // scoping, push helpers).
+ use SyncsHostFromRecord;
+
public function __construct(protected readonly SyncAdapterInstance $instance) {}
/** Display label for the adapter TYPE (not the instance). Shown in the "Add adapter" dropdown. */
@@ -897,7 +904,7 @@ abstract class SyncAdapter
/**
* Custom asset-tag pattern the admin configured for auto-created
- * assets. Null when unset (SyncHostFromAdapter falls back to
+ * assets. Null when unset (SyncAdapter falls back to
* Asset::autoincrement_asset() in that case). Placeholders like
* `{serial}` / `{external_id}` / `{hostname}` get substituted at
* create time from HostInventoryRecord fields.
@@ -912,7 +919,7 @@ abstract class SyncAdapter
/**
* Default category id for auto-created AssetModels from this
* adapter. Vendors don't send Snipe-IT's category concept, but
- * every AssetModel needs one. When null, SyncHostFromAdapter
+ * every AssetModel needs one. When null, SyncAdapter
* falls back to a get-or-create "Discovered Hardware" category.
*/
public function defaultCategoryId(): ?int
@@ -929,7 +936,7 @@ abstract class SyncAdapter
* more specific category than the instance-wide default.
*
* Return null to fall through to defaultCategoryId(). The
- * framework calls this from SyncHostFromAdapter when creating a
+ * framework calls this from SyncAdapter when creating a
* new AssetModel row, so a null return is equivalent to today's
* one-category-per-instance behavior.
*
@@ -942,7 +949,7 @@ abstract class SyncAdapter
/**
* Default status label id for auto-created assets from this
- * adapter. When null, SyncHostFromAdapter falls back to the
+ * adapter. When null, SyncAdapter falls back to the
* first deployable status label (or, absent that, any status
* label). Admins pick a specific status to route synced devices
* into a curated workflow bucket ("Awaiting Assignment", "In
@@ -1080,7 +1087,7 @@ abstract class SyncAdapter
/**
* Snipe-IT company id for a vendor group id, or null when the
- * group has no mapping. Callers (SyncHostFromAdapter) fall back
+ * group has no mapping. Callers (SyncAdapter) fall back
* to the instance's own company_id in that case.
*/
public function companyForVendorGroup(string $vendorGroupId): ?int
diff --git a/app/SyncAdapters/SyncHostFromAdapter.php b/app/SyncAdapters/SyncsHostFromRecord.php
similarity index 98%
rename from app/SyncAdapters/SyncHostFromAdapter.php
rename to app/SyncAdapters/SyncsHostFromRecord.php
index 64cd7d0c6f..996ffc142a 100644
--- a/app/SyncAdapters/SyncHostFromAdapter.php
+++ b/app/SyncAdapters/SyncsHostFromRecord.php
@@ -16,22 +16,23 @@ use Illuminate\Support\Facades\Log;
use RuntimeException;
/**
- * Shared asset-side upsert path for every host-inventory adapter.
- * Accepts a normalized HostInventoryRecord and either creates a new
- * asset or updates an existing one keyed on (source, external_id) in
+ * Shared asset-side upsert path for every host-inventory adapter,
+ * folded onto SyncAdapter via `use SyncsHostFromRecord;` so the entry
+ * point sits on the base class. Accepts a normalized
+ * HostInventoryRecord and either creates a new asset or updates an
+ * existing one keyed on (source, external_id) in
* asset_external_sources.
*
- * The write path is deliberately dumb about vendors: no adapter-specific
- * logic lives here. Adapters do their own normalization and hand a
- * clean record over. Per-instance target mappings (configured via
- * MappingTargets on the settings page) let admins redirect each
- * normalized field to a custom field or skip it entirely.
- * SyncHostFromAdapter reads those overrides and dispatches values
- * accordingly.
+ * The write path is deliberately dumb about vendors: no adapter-
+ * specific logic lives here. Adapters do their own normalization and
+ * hand a clean record over. Per-instance target mappings (configured
+ * via MappingTargets on the settings page) let admins redirect each
+ * normalized field to a custom field or skip it entirely. This trait
+ * reads those overrides and dispatches values accordingly.
*/
-class SyncHostFromAdapter
+trait SyncsHostFromRecord
{
- public static function run(HostInventoryRecord $record): Asset
+ public static function syncFromRecord(HostInventoryRecord $record): Asset
{
return DB::transaction(function () use ($record) {
$instance = SyncAdapterInstance::query()->where('slug', $record->sourceKey)->first();
diff --git a/app/SyncAdapters/Unifi/UnifiAdapter.php b/app/SyncAdapters/Unifi/UnifiAdapter.php
index 140d10768f..492e2faaa2 100644
--- a/app/SyncAdapters/Unifi/UnifiAdapter.php
+++ b/app/SyncAdapters/Unifi/UnifiAdapter.php
@@ -90,7 +90,7 @@ class UnifiAdapter extends SyncAdapter
* UniFi's `id` (UUID) is stable per adopted device and is what we
* key asset_external_sources on. Serial is populated on most
* device types but occasionally null on virtual or legacy devices.
- * SyncHostFromAdapter treats null serials as acceptable so the
+ * SyncAdapter treats null serials as acceptable so the
* asset still lands even when the controller doesn't report one.
*
* @param array<string, mixed> $device
diff --git a/tests/Feature/SyncAdapters/Addigy/AddigyAdapterTest.php b/tests/Feature/SyncAdapters/Addigy/AddigyAdapterTest.php
index 91ca153786..bd416c8c46 100644
--- a/tests/Feature/SyncAdapters/Addigy/AddigyAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Addigy/AddigyAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Addigy\AddigyAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Addigy adapter through
- * SyncHostFromAdapter. Mocks the Addigy API, asserts assets +
+ * SyncAdapter. Mocks the Addigy API, asserts assets +
* external ids land correctly, and that the client-id / client-secret
* header pair (not bearer) goes out on the request.
*/
@@ -38,7 +38,7 @@ class AddigyAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/AppleBusinessManager/ModelImageEnrichmentTest.php b/tests/Feature/SyncAdapters/AppleBusinessManager/ModelImageEnrichmentTest.php
index f6f6e09426..0948e63d6f 100644
--- a/tests/Feature/SyncAdapters/AppleBusinessManager/ModelImageEnrichmentTest.php
+++ b/tests/Feature/SyncAdapters/AppleBusinessManager/ModelImageEnrichmentTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\AppleBusinessManager\AppleBusinessManagerAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
@@ -53,7 +53,7 @@ class ModelImageEnrichmentTest extends TestCase
$this->fakeAppleDbAndAbm();
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model->refresh();
@@ -72,7 +72,7 @@ class ModelImageEnrichmentTest extends TestCase
$this->fakeAppleDbAndAbm();
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model->refresh();
@@ -98,7 +98,7 @@ class ModelImageEnrichmentTest extends TestCase
$this->fakeAppleDbAndAbm();
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model->refresh();
@@ -112,7 +112,7 @@ class ModelImageEnrichmentTest extends TestCase
$this->fakeAppleDbAndAbm();
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
Http::assertNotSent(fn ($request) => str_contains($request->url(), 'appledb.dev'));
@@ -121,7 +121,7 @@ class ModelImageEnrichmentTest extends TestCase
public function test_first_sync_stages_image_to_disk_even_when_model_row_does_not_exist_yet()
{
// Timing gap: ensureModelImage runs inside pull(), before
- // SyncHostFromAdapter has created the AssetModel row. First
+ // SyncAdapter has created the AssetModel row. First
// sync must still hit appledb.dev and cache the PNG so the
// second sync only needs to assign existing->image (no
// re-download) once the framework creates the row.
@@ -146,7 +146,7 @@ class ModelImageEnrichmentTest extends TestCase
'img.appledb.dev/*' => Http::response(str_repeat("\x89PNG\r\n\x1a\n", 4)),
]);
- // Consume records without running SyncHostFromAdapter so no
+ // Consume records without running SyncAdapter so no
// AssetModel gets created. Simulates "framework hasn't built
// the row yet" at the point ensureModelImage runs.
iterator_to_array($adapter->pull());
@@ -179,7 +179,7 @@ class ModelImageEnrichmentTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model->refresh();
@@ -212,7 +212,7 @@ class ModelImageEnrichmentTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
// Even with 5 devices sharing the same hardwareModel, we hit
diff --git a/tests/Feature/SyncAdapters/AppleBusinessManager/PerFamilyCategoryRoutingTest.php b/tests/Feature/SyncAdapters/AppleBusinessManager/PerFamilyCategoryRoutingTest.php
index 8dd8e7639a..e8286e88d0 100644
--- a/tests/Feature/SyncAdapters/AppleBusinessManager/PerFamilyCategoryRoutingTest.php
+++ b/tests/Feature/SyncAdapters/AppleBusinessManager/PerFamilyCategoryRoutingTest.php
@@ -8,7 +8,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\AppleBusinessManager\AppleBusinessManagerAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -58,7 +58,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model = AssetModel::where('name', 'IPD1')->firstOrFail();
@@ -89,7 +89,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model = AssetModel::where('name', 'MBP1')->firstOrFail();
@@ -120,7 +120,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model = AssetModel::where('name', 'MINI1')->firstOrFail();
@@ -157,7 +157,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model = AssetModel::where('name', 'MYST1')->firstOrFail();
@@ -193,7 +193,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$existingModel->refresh();
@@ -230,7 +230,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$existingModel->refresh();
@@ -260,7 +260,7 @@ class PerFamilyCategoryRoutingTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$model = AssetModel::where('name', 'IPD1')->firstOrFail();
diff --git a/tests/Feature/SyncAdapters/AssetTagPatternTest.php b/tests/Feature/SyncAdapters/AssetTagPatternTest.php
index 72d8b0024b..3d6ffc7d12 100644
--- a/tests/Feature/SyncAdapters/AssetTagPatternTest.php
+++ b/tests/Feature/SyncAdapters/AssetTagPatternTest.php
@@ -8,14 +8,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Tests\TestCase;
/**
* Coverage for the per-adapter asset-tag pattern feature. Admins
* configure a pattern like `KANDJI-{serial}` on the adapter's
- * settings tab. SyncHostFromAdapter substitutes placeholders from
+ * settings tab. SyncAdapter substitutes placeholders from
* the HostInventoryRecord when creating new assets. Existing assets
* keep their tags. the pattern is create-only.
*/
@@ -33,7 +33,7 @@ class AssetTagPatternTest extends TestCase
$fleet = $this->configuredFleet();
SyncAdapterConfig::put($fleet->id, 'asset_tag_pattern', 'FLEET-{serial}');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: '1',
hostname: 'wksn-01',
@@ -52,7 +52,7 @@ class AssetTagPatternTest extends TestCase
$fleet = $this->configuredFleet();
SyncAdapterConfig::put($fleet->id, 'asset_tag_pattern', '{source}-{external_id}');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'host-99',
hostname: 'wksn-02',
@@ -73,7 +73,7 @@ class AssetTagPatternTest extends TestCase
$fleet = $this->configuredFleet();
SyncAdapterConfig::put($fleet->id, 'asset_tag_pattern', 'FLEET-{external_id}-{serial}');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'h1',
hostname: 'wksn-03',
@@ -94,7 +94,7 @@ class AssetTagPatternTest extends TestCase
$this->configuredFleet();
// No asset_tag_pattern stored.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'h42',
hostname: 'wksn-04',
@@ -117,7 +117,7 @@ class AssetTagPatternTest extends TestCase
SyncAdapterConfig::put($fleet->id, 'asset_tag_pattern', 'FLEET-{serial}');
// First sync creates the asset.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'stable-1',
hostname: 'wksn-05',
@@ -136,7 +136,7 @@ class AssetTagPatternTest extends TestCase
// not touch asset_tag.
SyncAdapterConfig::put($fleet->id, 'asset_tag_pattern', 'DIFFERENT-{serial}');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'stable-1',
hostname: 'wksn-05',
@@ -154,7 +154,7 @@ class AssetTagPatternTest extends TestCase
$category = \App\Models\Category::factory()->assetLaptopCategory()->create();
SyncAdapterConfig::put($fleet->id, 'default_category_id', (string) $category->id);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'cat-1',
hostname: 'wksn-cat',
@@ -171,7 +171,7 @@ class AssetTagPatternTest extends TestCase
$this->configuredFleet();
// No default_category_id stored.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'cat-2',
hostname: 'wksn-discovered',
diff --git a/tests/Feature/SyncAdapters/ExternalInventorySurfaceTest.php b/tests/Feature/SyncAdapters/ExternalInventorySurfaceTest.php
index e5f58214ad..cd9369e4ac 100644
--- a/tests/Feature/SyncAdapters/ExternalInventorySurfaceTest.php
+++ b/tests/Feature/SyncAdapters/ExternalInventorySurfaceTest.php
@@ -14,7 +14,7 @@ use Tests\TestCase;
* and via the assets API transformer.
*
* The write path is already covered by the per-adapter tests +
- * SyncHostFromAdapter integration tests. This file is the read path.
+ * SyncAdapter integration tests. This file is the read path.
*/
class ExternalInventorySurfaceTest extends TestCase
{
diff --git a/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php b/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php
index e638b111f8..76794a0a5b 100644
--- a/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php
+++ b/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php
@@ -8,7 +8,7 @@ use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Fleet\FleetAdapter;
use App\SyncAdapters\MappingTargets;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -16,7 +16,7 @@ use Tests\TestCase;
/**
* Coverage for the extra-field mapping flow: adapters declare
* vendor-specific extra keys via extraFields(), admin maps each to a
- * custom field, and SyncHostFromAdapter writes the (stringified) value
+ * custom field, and SyncAdapter writes the (stringified) value
* onto the asset's dynamic column.
*
* Fleet is the workhorse here because its normalize() emits a mix of
@@ -50,7 +50,7 @@ class ExtraFieldMappingTest extends TestCase
$adapter = new FleetAdapter($fleet);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseHas('assets', [
@@ -82,7 +82,7 @@ class ExtraFieldMappingTest extends TestCase
$adapter = new FleetAdapter($fleet);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseHas('assets', [
@@ -107,7 +107,7 @@ class ExtraFieldMappingTest extends TestCase
$adapter = new FleetAdapter($fleet);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
// Asset created, but the custom-field column stays null since
@@ -178,7 +178,7 @@ class ExtraFieldMappingTest extends TestCase
assetTag: 'VENDOR-TAG-001',
);
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
$this->assertDatabaseHas('assets', [
'name' => 'host-with-tag',
@@ -203,7 +203,7 @@ class ExtraFieldMappingTest extends TestCase
assetTag: 'VENDOR-TAG-002',
);
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
$this->assertDatabaseHas('assets', [
'name' => 'host-default-mapping',
@@ -228,7 +228,7 @@ class ExtraFieldMappingTest extends TestCase
assetTag: 'VENDOR-TAG-003',
);
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
$created = \App\Models\Asset::where('name', 'host-skipped-mapping')->firstOrFail();
$this->assertNotSame('VENDOR-TAG-003', $created->asset_tag);
diff --git a/tests/Feature/SyncAdapters/Fleet/FleetAdapterTest.php b/tests/Feature/SyncAdapters/Fleet/FleetAdapterTest.php
index db625fd584..b72ebdbf21 100644
--- a/tests/Feature/SyncAdapters/Fleet/FleetAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Fleet/FleetAdapterTest.php
@@ -7,14 +7,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Fleet\FleetAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
- * End-to-end coverage for the Fleet adapter through SyncHostFromAdapter.
+ * End-to-end coverage for the Fleet adapter through SyncAdapter.
* Mocks Fleet's REST API, asserts assets + asset_external_sources + side-
* table rows land correctly, and that a re-run updates instead of
* duplicating.
@@ -29,7 +29,7 @@ class FleetAdapterTest extends TestCase
{
parent::setUp();
- // SyncHostFromAdapter picks a deployable status label or falls
+ // SyncAdapter picks a deployable status label or falls
// back to any status label. Seed at least one so create doesn't
// blow up.
Statuslabel::factory()->rtd()->create();
@@ -52,7 +52,7 @@ class FleetAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
@@ -83,7 +83,7 @@ class FleetAdapterTest extends TestCase
// First pull.
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 1);
@@ -92,7 +92,7 @@ class FleetAdapterTest extends TestCase
// Second pull.
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
// No new rows: same host, same identity link.
@@ -234,7 +234,7 @@ class FleetAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$asset = \App\Models\Asset::where('name', 'personal-phone')->firstOrFail();
@@ -261,7 +261,7 @@ class FleetAdapterTest extends TestCase
$adapter = new FleetAdapter($instance);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseHas('assets', ['name' => 'scoped-host', 'company_id' => $company->id]);
diff --git a/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php b/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php
index e0ff8a1e71..204f8d6090 100644
--- a/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php
+++ b/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php
@@ -9,7 +9,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Tests\TestCase;
@@ -36,7 +36,7 @@ class GroupCompanyMappingTest extends TestCase
$fleet = $this->configuredFleet();
SyncAdapterConfig::put($fleet->id, 'group_mapping.42', (string) $customerA->id);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'gc-1',
hostname: 'customer-a-laptop',
@@ -54,7 +54,7 @@ class GroupCompanyMappingTest extends TestCase
$customerA = Company::factory()->create();
$this->configuredFleet($customerA->id);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'gc-2',
hostname: 'unmapped-group-laptop',
@@ -73,7 +73,7 @@ class GroupCompanyMappingTest extends TestCase
$fleet = $this->configuredFleet($customerA->id);
SyncAdapterConfig::put($fleet->id, 'group_mapping.42', '999');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'gc-3',
hostname: 'no-group-laptop',
@@ -94,7 +94,7 @@ class GroupCompanyMappingTest extends TestCase
SyncAdapterConfig::put($fleet->id, 'group_mapping.10', (string) $customerA->id);
SyncAdapterConfig::put($fleet->id, 'group_mapping.20', (string) $customerB->id);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'gc-4',
hostname: 'moving-laptop',
@@ -106,7 +106,7 @@ class GroupCompanyMappingTest extends TestCase
$asset = Asset::where('name', 'moving-laptop')->firstOrFail();
$this->assertSame($customerA->id, (int) $asset->company_id);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'gc-4',
hostname: 'moving-laptop',
diff --git a/tests/Feature/SyncAdapters/Intune/IntuneAdapterTest.php b/tests/Feature/SyncAdapters/Intune/IntuneAdapterTest.php
index ef315ad9c8..f2fe19bb64 100644
--- a/tests/Feature/SyncAdapters/Intune/IntuneAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Intune/IntuneAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Intune\IntuneAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Microsoft Intune adapter through
- * SyncHostFromAdapter. Fakes the OAuth token exchange and the
+ * SyncAdapter. Fakes the OAuth token exchange and the
* Graph managedDevices endpoint.
*/
class IntuneAdapterTest extends TestCase
@@ -39,7 +39,7 @@ class IntuneAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Jamf/JamfAdapterTest.php b/tests/Feature/SyncAdapters/Jamf/JamfAdapterTest.php
index 7fefd2b126..59b9aac585 100644
--- a/tests/Feature/SyncAdapters/Jamf/JamfAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Jamf/JamfAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Jamf\JamfAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Jamf Pro adapter through
- * SyncHostFromAdapter. Mocks the Jamf Pro API, asserts assets +
+ * SyncAdapter. Mocks the Jamf Pro API, asserts assets +
* asset_external_sources land correctly, and that the totalCount /
* pagination termination works.
*/
@@ -41,7 +41,7 @@ class JamfAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php b/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
index a627292b94..33885207f5 100644
--- a/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
+++ b/tests/Feature/SyncAdapters/JamfSchool/JamfSchoolAdapterTest.php
@@ -6,7 +6,7 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\JamfSchool\JamfSchoolAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -41,7 +41,7 @@ class JamfSchoolAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/JumpCloud/JumpCloudAdapterTest.php b/tests/Feature/SyncAdapters/JumpCloud/JumpCloudAdapterTest.php
index 2cad8c46e7..67dc014fd5 100644
--- a/tests/Feature/SyncAdapters/JumpCloud/JumpCloudAdapterTest.php
+++ b/tests/Feature/SyncAdapters/JumpCloud/JumpCloudAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\JumpCloud\JumpCloudAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the JumpCloud adapter through
- * SyncHostFromAdapter. Mocks the JumpCloud Systems API, asserts assets
+ * SyncAdapter. Mocks the JumpCloud Systems API, asserts assets
* + asset_external_sources land correctly, and that the x-api-key header
* shape (not bearer) actually goes out on the request.
*/
@@ -41,7 +41,7 @@ class JumpCloudAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Kandji/KandjiAdapterTest.php b/tests/Feature/SyncAdapters/Kandji/KandjiAdapterTest.php
index 91a06e1a94..9b15907eb1 100644
--- a/tests/Feature/SyncAdapters/Kandji/KandjiAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Kandji/KandjiAdapterTest.php
@@ -6,13 +6,13 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Kandji\KandjiAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
- * End-to-end coverage for the Kandji adapter through SyncHostFromAdapter.
+ * End-to-end coverage for the Kandji adapter through SyncAdapter.
* Mocks Kandji's REST API, asserts assets + asset_external_sources land
* correctly, and that pagination termination on a short page works.
*/
@@ -40,7 +40,7 @@ class KandjiAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php b/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
index 8d0de9f8c6..5dbd0b2ee1 100644
--- a/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
+++ b/tests/Feature/SyncAdapters/Kandji/KandjiPushTest.php
@@ -8,7 +8,7 @@ use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Kandji\KandjiAdapter;
use App\SyncAdapters\PushableAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -48,7 +48,7 @@ class KandjiPushTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$asset = \App\Models\Asset::where('name', 'test-host')->firstOrFail();
@@ -109,7 +109,7 @@ class KandjiPushTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$asset = \App\Models\Asset::where('name', 'flip-host')->firstOrFail();
diff --git a/tests/Feature/SyncAdapters/KaseyaVsa10/KaseyaVsa10AdapterTest.php b/tests/Feature/SyncAdapters/KaseyaVsa10/KaseyaVsa10AdapterTest.php
index 1772093356..8bf293a0d0 100644
--- a/tests/Feature/SyncAdapters/KaseyaVsa10/KaseyaVsa10AdapterTest.php
+++ b/tests/Feature/SyncAdapters/KaseyaVsa10/KaseyaVsa10AdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\KaseyaVsa10\KaseyaVsa10Adapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Kaseya VSA 10 adapter through
- * SyncHostFromAdapter. Fakes the Basic-auth /api/v3/assets endpoint
+ * SyncAdapter. Fakes the Basic-auth /api/v3/assets endpoint
* and asserts extraction from the nested AssetInfo[] category shape.
*/
class KaseyaVsa10AdapterTest extends TestCase
@@ -39,7 +39,7 @@ class KaseyaVsa10AdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapterTest.php b/tests/Feature/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapterTest.php
index 040fe4a681..aa0a070af1 100644
--- a/tests/Feature/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapterTest.php
+++ b/tests/Feature/SyncAdapters/MerakiSystemsManager/MerakiSystemsManagerAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\MerakiSystemsManager\MerakiSystemsManagerAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Meraki Systems Manager adapter through
- * SyncHostFromAdapter. Fakes the org->networks list and per-network
+ * SyncAdapter. Fakes the org->networks list and per-network
* SM devices call.
*/
class MerakiSystemsManagerAdapterTest extends TestCase
@@ -40,7 +40,7 @@ class MerakiSystemsManagerAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Mosyle/MosyleAdapterTest.php b/tests/Feature/SyncAdapters/Mosyle/MosyleAdapterTest.php
index a0931c7800..01efdacbdd 100644
--- a/tests/Feature/SyncAdapters/Mosyle/MosyleAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Mosyle/MosyleAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Mosyle\MosyleAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the Mosyle adapter through
- * SyncHostFromAdapter. Mocks the Mosyle Manager v2 response shape (the
+ * SyncAdapter. Mocks the Mosyle Manager v2 response shape (the
* nested response[0].response.rows form), asserts assets + external
* ids land correctly, and that the client sends POST (not GET) since
* Mosyle's reads use POST bodies.
@@ -50,7 +50,7 @@ class MosyleAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/NinjaOne/NinjaOneAdapterTest.php b/tests/Feature/SyncAdapters/NinjaOne/NinjaOneAdapterTest.php
index 5d6b9234a2..eb63b4b532 100644
--- a/tests/Feature/SyncAdapters/NinjaOne/NinjaOneAdapterTest.php
+++ b/tests/Feature/SyncAdapters/NinjaOne/NinjaOneAdapterTest.php
@@ -6,13 +6,13 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\NinjaOne\NinjaOneAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
- * End-to-end coverage for the NinjaOne adapter through SyncHostFromAdapter.
+ * End-to-end coverage for the NinjaOne adapter through SyncAdapter.
* Fakes the OAuth token exchange and the /v2/devices-detailed endpoint.
*/
class NinjaOneAdapterTest extends TestCase
@@ -36,7 +36,7 @@ class NinjaOneAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php b/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
index 1f0935a6a6..9eb43afc62 100644
--- a/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Osctrl/OsctrlAdapterTest.php
@@ -6,14 +6,14 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\SyncAdapters\Osctrl\OsctrlAdapter;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* End-to-end coverage for the osctrl adapter through
- * SyncHostFromAdapter. Mocks the osctrl nodes response, asserts assets
+ * SyncAdapter. Mocks the osctrl nodes response, asserts assets
* + external ids land correctly, and that the environment schema
* field flows into the request URL path (osctrl's API is environment-
* scoped).
@@ -39,7 +39,7 @@ class OsctrlAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Unifi/UnifiAdapterTest.php b/tests/Feature/SyncAdapters/Unifi/UnifiAdapterTest.php
index b4db94f98e..e67c4a2c10 100644
--- a/tests/Feature/SyncAdapters/Unifi/UnifiAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Unifi/UnifiAdapterTest.php
@@ -5,7 +5,7 @@ namespace Tests\Feature\SyncAdapters\Unifi;
use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use App\SyncAdapters\Unifi\UnifiAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
@@ -13,7 +13,7 @@ use Tests\TestCase;
/**
* End-to-end coverage for the UniFi adapter through
- * SyncHostFromAdapter. Mocks the UniFi Network Integration API,
+ * SyncAdapter. Mocks the UniFi Network Integration API,
* asserts assets + asset_external_sources land correctly, and that
* the X-API-KEY header (not bearer, not session cookies) goes out on
* the request.
@@ -45,7 +45,7 @@ class UnifiAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/UserAssignmentTest.php b/tests/Feature/SyncAdapters/UserAssignmentTest.php
index ab2f7c97d5..2d9279ab18 100644
--- a/tests/Feature/SyncAdapters/UserAssignmentTest.php
+++ b/tests/Feature/SyncAdapters/UserAssignmentTest.php
@@ -10,7 +10,7 @@ use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\Models\User;
use App\SyncAdapters\HostInventoryRecord;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
@@ -39,7 +39,7 @@ class UserAssignmentTest extends TestCase
$user = User::factory()->create(['email' => '[email protected]']);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-1',
hostname: 'alices-laptop',
@@ -60,7 +60,7 @@ class UserAssignmentTest extends TestCase
$user = User::factory()->create(['username' => 'alice.smith']);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-2',
hostname: 'alices-laptop',
@@ -79,7 +79,7 @@ class UserAssignmentTest extends TestCase
// Default strategy is 'none' when nothing is stored.
User::factory()->create(['email' => '[email protected]']);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-3',
hostname: 'no-assignment',
@@ -97,7 +97,7 @@ class UserAssignmentTest extends TestCase
$fleet = $this->configuredFleet();
SyncAdapterConfig::put($fleet->id, 'user_match_strategy', 'email');
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-4',
hostname: 'unmatched-host',
@@ -118,7 +118,7 @@ class UserAssignmentTest extends TestCase
$user = User::factory()->create(['email' => '[email protected]']);
// First sync: assigns to alice.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-5',
hostname: 'alices-laptop',
@@ -128,7 +128,7 @@ class UserAssignmentTest extends TestCase
));
// Second sync of the same asset with no user email.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-5',
hostname: 'alices-laptop',
@@ -152,7 +152,7 @@ class UserAssignmentTest extends TestCase
User::factory()->create(['email' => '[email protected]']);
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-6',
hostname: 'silent-assign',
@@ -191,7 +191,7 @@ class UserAssignmentTest extends TestCase
// has no user. Suppress-off would otherwise crash the
// CheckoutableCheckedOut event (requires User admin), so the
// sync path silently degrades to direct assignment.
- SyncHostFromAdapter::run(new HostInventoryRecord(
+ SyncAdapter::syncFromRecord(new HostInventoryRecord(
sourceKey: 'fleet',
sourceId: 'ua-8',
hostname: 'cli-assign',
diff --git a/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOneAdapterTest.php b/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOneAdapterTest.php
index 60be4deed1..4fe2d91076 100644
--- a/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOneAdapterTest.php
+++ b/tests/Feature/SyncAdapters/WorkspaceOne/WorkspaceOneAdapterTest.php
@@ -5,7 +5,7 @@ namespace Tests\Feature\SyncAdapters\WorkspaceOne;
use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use App\SyncAdapters\WorkspaceOne\WorkspaceOneAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
@@ -13,7 +13,7 @@ use Tests\TestCase;
/**
* End-to-end coverage for the Omnissa Workspace ONE adapter through
- * SyncHostFromAdapter. Fakes the OAuth token exchange and the
+ * SyncAdapter. Fakes the OAuth token exchange and the
* /api/mdm/devices/search endpoint.
*/
class WorkspaceOneAdapterTest extends TestCase
@@ -42,7 +42,7 @@ class WorkspaceOneAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);
diff --git a/tests/Feature/SyncAdapters/Zentral/ZentralAdapterTest.php b/tests/Feature/SyncAdapters/Zentral/ZentralAdapterTest.php
index b1c84f14b8..680f2e3537 100644
--- a/tests/Feature/SyncAdapters/Zentral/ZentralAdapterTest.php
+++ b/tests/Feature/SyncAdapters/Zentral/ZentralAdapterTest.php
@@ -5,14 +5,14 @@ namespace Tests\Feature\SyncAdapters\Zentral;
use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
-use App\SyncAdapters\SyncHostFromAdapter;
+use App\SyncAdapters\SyncAdapter;
use App\SyncAdapters\Zentral\ZentralAdapter;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
- * End-to-end coverage for the Zentral adapter through SyncHostFromAdapter.
+ * End-to-end coverage for the Zentral adapter through SyncAdapter.
* Fakes Zentral's /api/inventory/machines/ endpoint, asserts assets +
* asset_external_sources rows land correctly.
*/
@@ -37,7 +37,7 @@ class ZentralAdapterTest extends TestCase
]);
foreach ($adapter->pull() as $record) {
- SyncHostFromAdapter::run($record);
+ SyncAdapter::syncFromRecord($record);
}
$this->assertDatabaseCount('asset_external_sources', 2);