1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 19:24:02 +00:00

Test that tenant permmissions are scoped only to the tenant schema

This commit is contained in:
lukinovec 2023-06-27 17:48:47 +02:00
parent 08b4216d69
commit d005e7b06d

View file

@ -228,6 +228,22 @@ test('users created by CreatePostgresUserForTenant are only granted the permissi
->not()->toContain('DELETE');
});
test('postgres user permissions are only scoped to the tenant app', function() {
$tenant = Tenant::create();
// ALL grants'
CreatePostgresUserForTenant::dispatchSync($tenant);
tenancy()->initialize($tenant);
// Tenant cannot access central data due to insufficient permissions
expect(fn () => Tenant::all())->toThrow(Exception::class);
tenancy()->end();
// Central data can be accessed from the central context
expect(Tenant::all())->not()->toBeEmpty();
})->group('access');
test('model discovery gets the models correctly', function() {
// 'tenancy.rls.model_directories' is set to [__DIR__ . '/Etc'] in beforeEach
// Check that the Post and ScopedComment models are found in the directory