mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 10:24:03 +00:00
Combined subdomain/domain identification
This commit is contained in:
parent
8ea4940f34
commit
f328fc9c08
4 changed files with 141 additions and 4 deletions
|
|
@ -15,6 +15,9 @@ class SubdomainTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
// Global state cleanup after some tests
|
||||
InitializeTenancyBySubdomain::$onInvalidSubdomain = null;
|
||||
|
||||
Route::group([
|
||||
'middleware' => InitializeTenancyBySubdomain::class,
|
||||
], function () {
|
||||
|
|
@ -93,6 +96,29 @@ class SubdomainTest extends TestCase
|
|||
->get('http://127.0.0.1/foo/abc/xyz')
|
||||
->assertSee('foo custom invalid subdomain handler');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function we_cant_use_a_subdomain_that_doesnt_belong_to_our_central_domains()
|
||||
{
|
||||
config(['tenancy.central_domains' => [
|
||||
'127.0.0.1',
|
||||
// not 'localhost'
|
||||
]]);
|
||||
|
||||
$tenant = Tenant::create([
|
||||
'id' => 'acme',
|
||||
]);
|
||||
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'foo',
|
||||
]);
|
||||
|
||||
$this->expectException(NotASubdomainException::class);
|
||||
|
||||
$this
|
||||
->withoutExceptionHandling()
|
||||
->get('http://foo.localhost/foo/abc/xyz');
|
||||
}
|
||||
}
|
||||
|
||||
class Tenant extends Models\Tenant
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue