A free open source IT asset/license management system
More FMCS scoping tests
snipe3611fc9df583
diff --git a/app/Models/Company.php b/app/Models/Company.phpindex da3696633c..37b35ca34d 100644--- a/app/Models/Company.php+++ b/app/Models/Company.php@@ -599,14 +599,37 @@ final class Company extends SnipeModel});}- // Users, unlike other companyable items, are NOT treated as- // floaters just because they have no company. A company-scoped- // caller sees only users whose pivot rows include one of their- // companies. Floater users (no pivot rows) are only visible to- // other floater users (caller with no pivot rows, handled above)- // and superusers (handled at the top of scopeCompanyables).- // Same query in floater and strict mode for the company-scoped- // caller: item-level floater rules don't apply to users.+ // Floater mode on: a company-scoped caller also sees null-company+ // (floater) users. This mirrors the item-level floater rule+ // documented at https://snipe-it.readme.io/docs/multi-tenancy-ish+ // and is required so checkout dropdowns can offer floater users+ // as valid targets under the "items from any company can be+ // checked out to targets with no company assignment" policy.+ //+ // The "no pivot rows" branch queries the company_user pivot+ // directly. Going through the Eloquent relation instead would+ // apply the companies-table CompanyableScope to the subquery,+ // restricting the JOIN to the caller's own companies. A user+ // whose only pivot rows point at OTHER companies would then+ // look pivot-less under that scoping and get picked up by the+ // floater branch, leaking cross-company users into the caller's+ // list. Reading the pivot directly bypasses that recursive+ // scope and matches the intended "genuinely no pivot rows at+ // all" semantics. This is the original bug fix from support+ // ticket 56305. Floater visibility itself is deliberate per+ // docs; only the cross-company leak was wrong.+ if ($floater) {+ return $query->where(function ($q) use ($companyIds) {+ $q->whereIn('users.id', function ($sub) use ($companyIds) {+ $sub->select('user_id')->from('company_user')->whereIn('company_id', $companyIds);+ })->orWhereNotIn('users.id', function ($sub) {+ $sub->select('user_id')->from('company_user');+ });+ });+ }++ // Floater mode off (strict): only users pivoted to one of the+ // caller's companies. Null-company users are not visible.return $query->whereIn('users.id', function ($sub) use ($companyIds) {$sub->select('user_id')->from('company_user')->whereIn('company_id', $companyIds);});@@ -655,12 +678,21 @@ final class Company extends SnipeModel*/public static function scopeUsersByCompanyIds($query, array $companyIds): mixed{- // Users are never treated as floaters here. A caller filtering the- // users list by a specific set of company ids gets exactly those- // users, regardless of null_company_is_floater. Item-level floater- // rules (visible to any caller if the item has no company) don't- // apply to users. Superuser bypass happens upstream in- // scopeCompanyables and in the caller's own conditional.+ if (Setting::getSettings()->null_company_is_floater) {+ // The "no pivot rows" branch queries the company_user pivot+ // directly, for the same reason as scopeCompanyablesDirectly+ // above: walking the Eloquent companies relation would apply+ // the companies-table CompanyableScope to the subquery and let+ // cross-company users leak in as apparent floaters. See ticket 56305.+ return $query->where(function ($q) use ($companyIds) {+ $q->whereIn('users.id', function ($sub) use ($companyIds) {+ $sub->select('user_id')->from('company_user')->whereIn('company_id', $companyIds);+ })->orWhereNotIn('users.id', function ($sub) {+ $sub->select('user_id')->from('company_user');+ });+ });+ }+return $query->whereIn('users.id', function ($sub) use ($companyIds) {$sub->select('user_id')->from('company_user')->whereIn('company_id', $companyIds);});diff --git a/tests/Feature/Fmcs/HttpCrossCompanyLeakTest.php b/tests/Feature/Fmcs/HttpCrossCompanyLeakTest.phpnew file mode 100644index 0000000000..044246fdb6--- /dev/null+++ b/tests/Feature/Fmcs/HttpCrossCompanyLeakTest.php@@ -0,0 +1,178 @@+<?php++namespace Tests\Feature\Fmcs;++use App\Models\Accessory;+use App\Models\Asset;+use App\Models\Company;+use App\Models\Component;+use App\Models\Consumable;+use App\Models\Department;+use App\Models\License;+use App\Models\Location;+use App\Models\User;+use Illuminate\Database\Eloquent\Model;+use Tests\TestCase;++/**+ * End-to-end tenant isolation guard.+ *+ * Every companyable list endpoint is exercised as a NON-SUPERUSER caller+ * scoped to company A, with a matching row present in company B. If any+ * row belonging to company B appears in the response, the test fails and+ * we know a scoping regression is loose in HTTP land, even if the+ * model-level scope tests are still green (e.g. a controller called+ * withoutGlobalScopes, joined bypassed a scope, or used a raw query).+ *+ * Users are covered by tests/Feature/Users/Api/IndexUsersTest;+ * tests/Unit/CompanyScopingTest covers the model-level equivalents. This+ * suite is the outer defense — controller-level and route-level.+ */+class HttpCrossCompanyLeakTest extends TestCase+{+ protected Company $companyA;++ protected Company $companyB;++ protected function setUp(): void+ {+ parent::setUp();+ [$this->companyA, $this->companyB] = Company::factory()->count(2)->create();+ }++ /**+ * Grant a non-superuser caller "view all" permissions for the given+ * resource keys and pin them to company A. Superusers bypass FMCS+ * entirely so we can't use them here; a plain view permission plus+ * company_user pivot to company A is the shape a real customer's+ * non-admin employee has.+ */+ private function callerScopedToCompanyA(array $viewPermissionKeys): User+ {+ $permissions = [];+ foreach ($viewPermissionKeys as $key) {+ $permissions[$key.'.view'] = '1';+ }++ return $this->companyA->users()->save(+ User::factory()->make(['permissions' => json_encode($permissions)])+ );+ }++ private function idsFromResponse(array $rows): array+ {+ return collect($rows)->pluck('id')->all();+ }++ private function assertCompanyBRowHidden(string $endpoint, Model $companyBRow, User $caller, string $rowsKey = 'rows'): void+ {+ $ids = $this->idsFromResponse(+ $this->actingAsForApi($caller)+ ->getJson($endpoint)+ ->assertOk()+ ->json($rowsKey)+ );++ $this->assertNotContains(+ $companyBRow->id,+ $ids,+ 'Cross-company leak at '.$endpoint.': company B '.get_class($companyBRow).' id '.$companyBRow->id.' visible to a company A caller.',+ );+ }++ public function test_api_assets_index_hides_other_company_rows(): void+ {+ $companyBAsset = Asset::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['assets']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.assets.index'), $companyBAsset, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.assets.index'), $companyBAsset, $caller);+ }++ public function test_api_accessories_index_hides_other_company_rows(): void+ {+ $companyBAccessory = Accessory::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['accessories']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.accessories.index'), $companyBAccessory, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.accessories.index'), $companyBAccessory, $caller);+ }++ public function test_api_consumables_index_hides_other_company_rows(): void+ {+ $companyBConsumable = Consumable::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['consumables']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.consumables.index'), $companyBConsumable, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.consumables.index'), $companyBConsumable, $caller);+ }++ public function test_api_components_index_hides_other_company_rows(): void+ {+ $companyBComponent = Component::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['components']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.components.index'), $companyBComponent, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.components.index'), $companyBComponent, $caller);+ }++ public function test_api_licenses_index_hides_other_company_rows(): void+ {+ $companyBLicense = License::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['licenses']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.licenses.index'), $companyBLicense, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.licenses.index'), $companyBLicense, $caller);+ }++ public function test_api_locations_index_hides_other_company_rows(): void+ {+ $companyBLocation = Location::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['locations']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.locations.index'), $companyBLocation, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.locations.index'), $companyBLocation, $caller);+ }++ public function test_api_departments_index_hides_other_company_rows(): void+ {+ $companyBDepartment = Department::factory()->for($this->companyB)->create();+ $caller = $this->callerScopedToCompanyA(['departments']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.departments.index'), $companyBDepartment, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.departments.index'), $companyBDepartment, $caller);+ }++ public function test_api_users_index_hides_other_company_users(): void+ {+ $companyBUser = $this->companyB->users()->save(User::factory()->make());+ $caller = $this->callerScopedToCompanyA(['users']);++ $this->settings->enableMultipleFullCompanySupport();+ $this->assertCompanyBRowHidden(route('api.users.index'), $companyBUser, $caller);++ $this->settings->enableFloaterMode();+ $this->assertCompanyBRowHidden(route('api.users.index'), $companyBUser, $caller);+ }+}diff --git a/tests/Feature/Users/Api/IndexUsersTest.php b/tests/Feature/Users/Api/IndexUsersTest.phpindex 9df6570895..0454eb5021 100644--- a/tests/Feature/Users/Api/IndexUsersTest.php+++ b/tests/Feature/Users/Api/IndexUsersTest.php@@ -140,17 +140,19 @@ class IndexUsersTest extends TestCase}/**- * FMCS + floaters on: a company-scoped, non-superuser caller must not- * see users pivoted to a different company, and must NOT see floater- * (null-company) users. Floater USERS are only visible to other- * floaters and to superusers, unlike floater ASSETS / LOCATIONS which- * are visible to everyone under floater mode.+ * FMCS + floaters on: a company-scoped, non-superuser caller sees+ * their own pivot companies AND null-company (floater) users, but+ * NOT users pivoted to a different company.*- * Regression pin for the ticket where a company-A user going to the- * user listing page saw every user in the system. See the same fix- * at tests/Unit/CompanyScopingTest.php for the model-level equivalent.+ * Regression pin for support ticket 56305. Root cause was that+ * `orWhereDoesntHave('companies')` in the floater branch had the+ * companies-table CompanyableScope applied recursively to its+ * subquery, filtering the JOIN to the caller's own companies. A user+ * pivoted only to OUT-OF-SCOPE companies then looked pivot-less and+ * slipped through as an apparent floater. Fix reads the company_user+ * pivot directly. See the same pin at tests/Unit/CompanyScopingTest.php.*/- public function test_users_index_hides_other_companies_and_floater_users_from_company_scoped_caller()+ public function test_users_index_hides_other_companies_users_but_includes_floaters_for_company_scoped_caller(){[$companyA, $companyB] = Company::factory()->count(2)->create();@@ -170,8 +172,8 @@ class IndexUsersTest extends TestCase$this->assertContains($companyACaller->id, $visibleIds);$this->assertContains($companyAPeer->id, $visibleIds);+ $this->assertContains($floater->id, $visibleIds, 'Floater user should be visible per docs.');$this->assertNotContains($companyBUser->id, $visibleIds, 'Company B user leaked to a company A caller.');- $this->assertNotContains($floater->id, $visibleIds, 'Floater user leaked to a company A caller.');}public function test_returns_result_via_filter()diff --git a/tests/Feature/Users/Ui/ExportUsersTest.php b/tests/Feature/Users/Ui/ExportUsersTest.phpindex ebe6e0f495..bd3f022134 100644--- a/tests/Feature/Users/Ui/ExportUsersTest.php+++ b/tests/Feature/Users/Ui/ExportUsersTest.php@@ -159,7 +159,7 @@ class ExportUsersTest extends TestCase[$companyA, $companyB] = Company::factory()->count(2)->create();$actorCompany = $companyA;- $inScope = User::factory()->create();+ $inScope = User::factory()->create();$inScope->companies()->sync([$actorCompany->id]);$outScope = User::factory()->create();@@ -182,7 +182,7 @@ class ExportUsersTest extends TestCase$company = Company::factory()->create();- $inScope = User::factory()->create();+ $inScope = User::factory()->create();$inScope->companies()->sync([$company->id]);$nullCompany = User::factory()->create(['company_id' => null]);@@ -204,7 +204,7 @@ class ExportUsersTest extends TestCase$company = Company::factory()->create();- $inScope = User::factory()->create();+ $inScope = User::factory()->create();$inScope->companies()->sync([$company->id]);$nullCompany = User::factory()->create(['company_id' => null]);diff --git a/tests/Unit/Codebase/ForbiddenFmcsPatternsTest.php b/tests/Unit/Codebase/ForbiddenFmcsPatternsTest.phpnew file mode 100644index 0000000000..e1cb46d6de--- /dev/null+++ b/tests/Unit/Codebase/ForbiddenFmcsPatternsTest.php@@ -0,0 +1,87 @@+<?php++namespace Tests\Unit\Codebase;++use PHPUnit\Framework\TestCase;++/**+ * Codebase-shape guardrail against the class of bug that landed the+ * FMCS cross-company user leak (support ticket 56305).+ *+ * `whereDoesntHave('companies' | 'company' | 'users')` inside FMCS-scoped+ * code is dangerous: the relation subquery walks a companyable model,+ * which triggers CompanyableScope recursively on the JOIN, narrowing it+ * to the caller's own companies. Rows whose companyable relation points+ * only at OUT-OF-SCOPE companies then look "no relation at all" from the+ * scope's perspective and slip through negated-relation filters. That's+ * how the users leak got past every green test in production.+ *+ * The safe substitute is a direct pivot query+ * (`whereNotIn('users.id', function ($sub) { $sub->select('user_id')->from('company_user'); })`)+ * that bypasses the recursive scope. This test fails if any file under+ * app/ reintroduces the forbidden pattern outside a small, deliberate+ * whitelist.+ */+class ForbiddenFmcsPatternsTest extends TestCase+{+ /**+ * Files that are ALLOWED to use these patterns because they are+ * user-facing search / filter code, not FMCS scoping. Any addition+ * to this list must be reviewed. Keep the list short.+ */+ private const WHITELIST = [+ // Advanced search on "not X" relation filters (e.g. "location=!dam"+ // means show users without a matching location). Not an FMCS scope,+ // and the intended semantics of doesntHave here are correct.+ 'app/Models/Traits/Searchable.php',+ ];++ public function test_no_forbidden_doesnt_have_on_companyable_relations(): void+ {+ $projectRoot = dirname(__DIR__, 3);+ $hits = [];++ foreach ($this->scanPhpFiles($projectRoot.'/app') as $absolutePath) {+ $relative = ltrim(substr($absolutePath, strlen($projectRoot) + 1), '/');+ if (in_array($relative, self::WHITELIST, true)) {+ continue;+ }++ $contents = file_get_contents($absolutePath);+ if ($contents === false) {+ continue;+ }++ // Match: (or)?(where)?DoesntHave('companies'|'company'|'users'|'user')+ // with either quote style. Case-insensitive to catch typo-style+ // stylings that would still work at runtime.+ if (preg_match('/(?:or)?(?:where)?DoesntHave\s*\(\s*[\'"](companies|company|users|user)[\'"]/i', $contents, $matches, PREG_OFFSET_CAPTURE)) {+ $offset = $matches[0][1];+ $line = substr_count(substr($contents, 0, $offset), "\n") + 1;+ $hits[] = $relative.':'.$line.' '.trim(explode("\n", substr($contents, $offset, 200))[0]);+ }+ }++ $this->assertEmpty(+ $hits,+ "Found forbidden FMCS pattern. `whereDoesntHave` on a companyable relation triggers recursive CompanyableScope on the subquery, which leaks cross-company data. Use a direct pivot query (whereNotIn(..., function(\$sub){\$sub->select('user_id')->from('company_user');})) instead, or add the file to the WHITELIST if you're certain it's not FMCS scoping.\n\nHits:\n".implode("\n", $hits)+ );+ }++ /**+ * @return \Generator<string>+ */+ private function scanPhpFiles(string $dir): \Generator+ {+ $iterator = new \RecursiveIteratorIterator(+ new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS)+ );++ foreach ($iterator as $file) {+ /** @var \SplFileInfo $file */+ if ($file->isFile() && $file->getExtension() === 'php') {+ yield $file->getPathname();+ }+ }+ }+}diff --git a/tests/Unit/CompanyScopingTest.php b/tests/Unit/CompanyScopingTest.phpindex 57b63cabcf..0a53ef305b 100644--- a/tests/Unit/CompanyScopingTest.php+++ b/tests/Unit/CompanyScopingTest.php@@ -7,8 +7,10 @@ use App\Models\Asset;use App\Models\Company;use App\Models\Component;use App\Models\Consumable;+use App\Models\Department;use App\Models\License;use App\Models\LicenseSeat;+use App\Models\Location;use App\Models\Maintenance;use App\Models\User;use Illuminate\Database\Eloquent\Model;@@ -17,6 +19,17 @@ use Tests\TestCase;class CompanyScopingTest extends TestCase{+ /**+ * Every companyable model that stores its own company_id on a real+ * column (as opposed to Users, which uses the company_user pivot).+ * These all go through the same branch of Company::scopeCompanyablesDirectly+ * and should share identical strict / floater behavior. Adding a model+ * to this list runs the whole DataProvider matrix against it.+ *+ * Users are covered by test_user_scoping_matrix. Company, Actionlog,+ * and ConsumableAssignment are companyable but not first-class list+ * targets so they're out of scope for the provider matrix.+ */public static function models(): array{return [@@ -24,7 +37,9 @@ class CompanyScopingTest extends TestCase'Assets' => [Asset::class],'Components' => [Component::class],'Consumables' => [Consumable::class],+ 'Departments' => [Department::class],'Licenses' => [License::class],+ 'Locations' => [Location::class],];}@@ -210,13 +225,14 @@ class CompanyScopingTest extends TestCase}/**- * Unlike other companyable items, USERS are never floaters from a- * company-scoped caller's perspective. A null-company user is only- * visible to other null-company users (see the "floater sees everyone"- * branch handled elsewhere) and superusers. Confirms the policy in- * both floater and strict modes.+ * FMCS + floaters on: null-company users are visible to a+ * company-scoped caller. This mirrors the item-level floater rule+ * documented at https://snipe-it.readme.io/docs/multi-tenancy-ish and+ * is required so checkout dropdowns can offer floater users as valid+ * targets under the "items from any company can be checked out to+ * targets with no company assignment" policy.*/- public function test_company_scoped_user_cannot_see_null_company_users_in_floater_mode()+ public function test_company_scoped_user_can_see_null_company_users_in_floater_mode(){$company = Company::factory()->create();$companyUser = $company->users()->save(User::factory()->make());@@ -225,7 +241,7 @@ class CompanyScopingTest extends TestCase$this->settings->enableFloaterMode();$this->actingAs($companyUser);- $this->assertCannotSee($nullCompanyUser);+ $this->assertCanSee($nullCompanyUser);}public function test_company_scoped_user_cannot_see_null_company_users_in_strict_mode()@@ -260,14 +276,17 @@ class CompanyScopingTest extends TestCase}/**- * FMCS + floaters on: a company A caller sees ONLY users pivoted to- * their own company (or their reachable hierarchy). They do NOT see- * users from other companies, and they do NOT see null-company (floater)- * users. Regression pin for support ticket 56305 and the follow-up- * clarification that floater USERS are not visible to company-scoped- * callers, unlike floater ASSETS / LOCATIONS / etc.+ * Regression pin for support ticket 56305. A company A caller under+ * FMCS + floater mode sees users in their own pivot companies AND+ * null-company (floater) users, but NEVER users pivoted only to+ * OTHER companies. Root cause of the ticket was that+ * `orWhereDoesntHave('companies')` in the floater branch had the+ * companies-table CompanyableScope applied recursively to its+ * subquery, so a user pivoted only to out-of-scope companies looked+ * pivot-less and slipped through as an apparent floater. Fix reads+ * the company_user pivot directly (see Company.php around line 610).*/- public function test_company_scoped_user_only_sees_own_company_users_in_floater_mode()+ public function test_company_scoped_user_cannot_see_other_companies_users_in_floater_mode(){[$companyA, $companyB] = Company::factory()->count(2)->create();@@ -280,8 +299,98 @@ class CompanyScopingTest extends TestCase$this->actingAs($companyACaller);$this->assertCanSee($companyAPeer);+ $this->assertCanSee($floaterUser);$this->assertCannotSee($companyBUser);- $this->assertCannotSee($floaterUser);+ }++ /**+ * Adversarial matrix for User scoping. Users use pivot semantics+ * (company_user) rather than a company_id column, so the item-oriented+ * DataProvider tests above don't cover them. This method exercises+ * every caller x FMCS mode combination so any recursive-scope leak or+ * policy drift lights up here rather than in production. See the+ * "FMCS changes require adversarial cross-company negative tests"+ * memory rule for the checklist that produced this.+ *+ * Callers:+ * - company-scoped non-superuser+ * - null-company non-superuser (floater caller)+ * - superuser+ * Modes:+ * - FMCS off+ * - FMCS on, floater off (strict)+ * - FMCS on, floater on+ */+ public function test_user_scoping_matrix()+ {+ [$companyA, $companyB] = Company::factory()->count(2)->create();++ $superuser = $companyA->users()->save(User::factory()->superuser()->make());+ $callerInA = $companyA->users()->save(User::factory()->make());+ $callerFloater = User::factory()->create(['company_id' => null]);+ $peerInA = $companyA->users()->save(User::factory()->make());+ $userInB = $companyB->users()->save(User::factory()->make());+ $floater = User::factory()->create(['company_id' => null]);++ // FMCS off: everyone sees everyone regardless of caller.+ $this->settings->disableMultipleFullCompanySupport();++ foreach ([$superuser, $callerInA, $callerFloater] as $caller) {+ $this->actingAs($caller);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCanSee($userInB);+ $this->assertCanSee($floater);+ }++ // FMCS on, floater off (strict): company-scoped caller sees only+ // their pivot companies. Floater caller sees only other floaters.+ // Superuser sees everyone.+ $this->settings->enableMultipleFullCompanySupport();++ $this->actingAs($superuser);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCanSee($userInB);+ $this->assertCanSee($floater);++ $this->actingAs($callerInA);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCannotSee($userInB);+ $this->assertCannotSee($floater);++ $this->actingAs($callerFloater);+ Company::flushCompanyIdsCache();+ $this->assertCannotSee($peerInA);+ $this->assertCannotSee($userInB);+ $this->assertCanSee($floater);++ // FMCS on, floater on: company-scoped caller sees their own pivot+ // companies AND null-company (floater) users, matching the docs at+ // https://snipe-it.readme.io/docs/multi-tenancy-ish. They still do+ // NOT see users pivoted to other companies (that was the ticket 56305+ // regression). Floater caller sees everyone. Superuser sees everyone.+ $this->settings->enableFloaterMode();++ $this->actingAs($superuser);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCanSee($userInB);+ $this->assertCanSee($floater);++ $this->actingAs($callerInA);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCannotSee($userInB);+ $this->assertCanSee($floater);++ // A floater caller is "unrestricted" and sees everyone.+ $this->actingAs($callerFloater);+ Company::flushCompanyIdsCache();+ $this->assertCanSee($peerInA);+ $this->assertCanSee($userInB);+ $this->assertCanSee($floater);}private function assertCanSee(Model $model)