diff --git a/src/.env.example b/src/.env.example --- a/src/.env.example +++ b/src/.env.example @@ -15,6 +15,7 @@ APP_WITH_ADMIN=1 APP_WITH_RESELLER=1 APP_WITH_SERVICES=1 +APP_WITH_FILES=1 APP_HEADER_CSP="connect-src 'self'; child-src 'self'; font-src 'self'; form-action 'self' data:; frame-ancestors 'self'; img-src blob: data: 'self' *; media-src 'self'; object-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; default-src 'self';" APP_HEADER_XFO=sameorigin diff --git a/src/app/Handlers/Beta/Base.php b/src/app/Handlers/Beta/Base.php deleted file mode 100644 --- a/src/app/Handlers/Beta/Base.php +++ /dev/null @@ -1,91 +0,0 @@ -active) { - return $object->hasSku('beta'); - } else { - if ($object->entitlements()->where('sku_id', $sku->id)->first()) { - return true; - } - } - - return false; - } - - /** - * SKU handler metadata. - * - * @param \App\Sku $sku The SKU object - * - * @return array - */ - public static function metadata(\App\Sku $sku): array - { - $data = parent::metadata($sku); - - $data['required'] = ['Beta']; - - return $data; - } - - /** - * Prerequisites for the Entitlement to be applied to the object. - * - * @param \App\Entitlement $entitlement - * @param mixed $object - * - * @return bool - */ - public static function preReq($entitlement, $object): bool - { - if (!parent::preReq($entitlement, $object)) { - return false; - } - - // TODO: User has to have the "beta" entitlement - - return true; - } - - /** - * The priority that specifies the order of SKUs in UI. - * Higher number means higher on the list. - * - * @return int - */ - public static function priority(): int - { - return 10; - } -} diff --git a/src/app/Handlers/Beta/Distlists.php b/src/app/Handlers/Beta/Distlists.php deleted file mode 100644 --- a/src/app/Handlers/Beta/Distlists.php +++ /dev/null @@ -1,28 +0,0 @@ -wallet()->entitlements() - ->where('entitleable_type', \App\Domain::class)->count() > 0; - } - - return false; - } -} diff --git a/src/app/Handlers/Beta/Resources.php b/src/app/Handlers/Beta/Resources.php deleted file mode 100644 --- a/src/app/Handlers/Beta/Resources.php +++ /dev/null @@ -1,28 +0,0 @@ -wallet()->entitlements() - ->where('entitleable_type', \App\Domain::class)->count() > 0; - } - - return false; - } -} diff --git a/src/app/Handlers/Beta/SharedFolders.php b/src/app/Handlers/Beta/SharedFolders.php deleted file mode 100644 --- a/src/app/Handlers/Beta/SharedFolders.php +++ /dev/null @@ -1,28 +0,0 @@ -wallet()->entitlements() - ->where('entitleable_type', \App\Domain::class)->count() > 0; - } - - return false; - } -} diff --git a/src/app/Handlers/Files.php b/src/app/Handlers/Files.php deleted file mode 100644 --- a/src/app/Handlers/Files.php +++ /dev/null @@ -1,7 +0,0 @@ -values() ->all(); + $hasBeta = in_array('beta', $skus); + $result = [ 'skus' => $skus, // TODO: This will change when we enable all users to create domains 'enableDomains' => $isController && $hasCustomDomain, // TODO: Make 'enableDistlists' working for wallet controllers that aren't account owners - 'enableDistlists' => $isController && $hasCustomDomain && in_array('beta-distlists', $skus), - 'enableFiles' => in_array('files', $skus), + 'enableDistlists' => $isController && $hasCustomDomain && $hasBeta, + 'enableFiles' => !$isDegraded && $hasBeta && \config('app.with_files'), // TODO: Make 'enableFolders' working for wallet controllers that aren't account owners - 'enableFolders' => $isController && $hasCustomDomain && in_array('beta-shared-folders', $skus), + 'enableFolders' => $isController && $hasCustomDomain && $hasBeta, // TODO: Make 'enableResources' working for wallet controllers that aren't account owners - 'enableResources' => $isController && $hasCustomDomain && in_array('beta-resources', $skus), + 'enableResources' => $isController && $hasCustomDomain && $hasBeta, + 'enableRooms' => !$isDegraded, 'enableSettings' => $isController, 'enableUsers' => $isController, 'enableWallets' => $isController, - 'enableCompanionapps' => $isController && in_array('beta', $skus), + 'enableCompanionapps' => $hasBeta, ]; return array_merge($process, $result); diff --git a/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php b/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php --- a/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php +++ b/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php @@ -82,9 +82,7 @@ */ public function down(): void { - if (\App\Sku::where('title', 'files')->first()) { - \App\Sku::where('title', 'files')->delete(); - } + \App\Sku::where('title', 'files')->delete(); Schema::dropIfExists('fs_properties'); Schema::dropIfExists('fs_chunks'); diff --git a/src/database/migrations/2022_06_03_100000_drop_beta_skus.php b/src/database/migrations/2022_06_03_100000_drop_beta_skus.php new file mode 100644 --- /dev/null +++ b/src/database/migrations/2022_06_03_100000_drop_beta_skus.php @@ -0,0 +1,67 @@ +delete(); + + \App\Sku::where('title', 'beta')->update(['description' => 'Access to the private beta program features']); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + \App\Sku::create([ + 'title' => 'beta-distlists', + 'name' => 'Distribution lists', + 'description' => 'Access to mail distribution lists', + 'cost' => 0, + 'units_free' => 0, + 'period' => 'monthly', + 'handler_class' => 'App\Handlers\Beta\Distlists', + 'active' => true, + ]); + \App\Sku::create([ + 'title' => 'beta-resources', + 'name' => 'Calendaring resources', + 'description' => 'Access to calendaring resources', + 'cost' => 0, + 'units_free' => 0, + 'period' => 'monthly', + 'handler_class' => 'App\Handlers\Beta\Resources', + 'active' => true, + ]); + \App\Sku::create([ + 'title' => 'beta-shared-folders', + 'name' => 'Shared folders', + 'description' => 'Access to shared folders', + 'cost' => 0, + 'units_free' => 0, + 'period' => 'monthly', + 'handler_class' => 'App\Handlers\Beta\SharedFolders', + 'active' => true, + ]); + \App\Sku::create([ + 'title' => 'files', + 'name' => 'File storage', + 'description' => 'Access to file storage', + 'cost' => 0, + 'units_free' => 0, + 'period' => 'monthly', + 'handler_class' => 'App\Handlers\Files', + 'active' => true, + ]); + } +}; diff --git a/src/database/seeds/local/SkuSeeder.php b/src/database/seeds/local/SkuSeeder.php --- a/src/database/seeds/local/SkuSeeder.php +++ b/src/database/seeds/local/SkuSeeder.php @@ -160,7 +160,7 @@ [ 'title' => 'beta', 'name' => 'Private Beta (invitation only)', - 'description' => 'Access to the private beta program subscriptions', + 'description' => 'Access to the private beta program features', 'cost' => 0, 'units_free' => 0, 'period' => 'monthly', @@ -206,72 +206,6 @@ ); } - // Check existence because migration might have added this already - $sku = Sku::where(['title' => 'beta-distlists', 'tenant_id' => \config('app.tenant_id')])->first(); - - if (!$sku) { - Sku::create( - [ - 'title' => 'beta-distlists', - 'name' => 'Distribution lists', - 'description' => 'Access to mail distribution lists', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\Distlists', - 'active' => true, - ] - ); - } - - // Check existence because migration might have added this already - $sku = Sku::where(['title' => 'beta-resources', 'tenant_id' => \config('app.tenant_id')])->first(); - - if (!$sku) { - Sku::create([ - 'title' => 'beta-resources', - 'name' => 'Calendaring resources', - 'description' => 'Access to calendaring resources', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\Resources', - 'active' => true, - ]); - } - - // Check existence because migration might have added this already - $sku = Sku::where(['title' => 'beta-shared-folders', 'tenant_id' => \config('app.tenant_id')])->first(); - - if (!$sku) { - Sku::create([ - 'title' => 'beta-shared-folders', - 'name' => 'Shared folders', - 'description' => 'Access to shared folders', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\SharedFolders', - 'active' => true, - ]); - } - - // Check existence because migration might have added this already - $sku = Sku::where(['title' => 'files', 'tenant_id' => \config('app.tenant_id')])->first(); - - if (!$sku) { - Sku::create([ - 'title' => 'files', - 'name' => 'File storage', - 'description' => 'Access to file storage', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Files', - 'active' => true, - ]); - } - // for tenants that are not the configured tenant id $tenants = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->get(); diff --git a/src/database/seeds/production/SkuSeeder.php b/src/database/seeds/production/SkuSeeder.php --- a/src/database/seeds/production/SkuSeeder.php +++ b/src/database/seeds/production/SkuSeeder.php @@ -199,61 +199,5 @@ ] ); } - - // Check existence because migration might have added this already - if (!Sku::where('title', 'beta-distlists')->first()) { - Sku::create([ - 'title' => 'beta-distlists', - 'name' => 'Distribution lists', - 'description' => 'Access to mail distribution lists', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\Distlists', - 'active' => true, - ]); - } - - // Check existence because migration might have added this already - if (!Sku::where('title', 'beta-resources')->first()) { - Sku::create([ - 'title' => 'beta-resources', - 'name' => 'Calendaring resources', - 'description' => 'Access to calendaring resources', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\Resources', - 'active' => true, - ]); - } - - // Check existence because migration might have added this already - if (!Sku::where('title', 'beta-shared-folders')->first()) { - Sku::create([ - 'title' => 'beta-shared-folders', - 'name' => 'Shared folders', - 'description' => 'Access to shared folders', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Beta\SharedFolders', - 'active' => true, - ]); - } - - // Check existence because migration might have added this already - if (!Sku::where('title', 'files')->first()) { - Sku::create([ - 'title' => 'files', - 'name' => 'File storage', - 'description' => 'Access to file storage', - 'cost' => 0, - 'units_free' => 0, - 'period' => 'monthly', - 'handler_class' => 'App\Handlers\Files', - 'active' => true, - ]); - } } } diff --git a/src/routes/api.php b/src/routes/api.php --- a/src/routes/api.php +++ b/src/routes/api.php @@ -81,16 +81,18 @@ Route::get('domains/{id}/status', [API\V4\DomainsController::class, 'status']); Route::post('domains/{id}/config', [API\V4\DomainsController::class, 'setConfig']); - Route::apiResource('files', API\V4\FilesController::class); - Route::get('files/{fileId}/permissions', [API\V4\FilesController::class, 'getPermissions']); - Route::post('files/{fileId}/permissions', [API\V4\FilesController::class, 'createPermission']); - Route::put('files/{fileId}/permissions/{id}', [API\V4\FilesController::class, 'updatePermission']); - Route::delete('files/{fileId}/permissions/{id}', [API\V4\FilesController::class, 'deletePermission']); - Route::post('files/uploads/{id}', [API\V4\FilesController::class, 'upload']) - ->withoutMiddleware(['auth:api']) - ->middleware(['api']); - Route::get('files/downloads/{id}', [API\V4\FilesController::class, 'download']) - ->withoutMiddleware(['auth:api']); + if (\config('app.with_files')) { + Route::apiResource('files', API\V4\FilesController::class); + Route::get('files/{fileId}/permissions', [API\V4\FilesController::class, 'getPermissions']); + Route::post('files/{fileId}/permissions', [API\V4\FilesController::class, 'createPermission']); + Route::put('files/{fileId}/permissions/{id}', [API\V4\FilesController::class, 'updatePermission']); + Route::delete('files/{fileId}/permissions/{id}', [API\V4\FilesController::class, 'deletePermission']); + Route::post('files/uploads/{id}', [API\V4\FilesController::class, 'upload']) + ->withoutMiddleware(['auth:api']) + ->middleware(['api']); + Route::get('files/downloads/{id}', [API\V4\FilesController::class, 'download']) + ->withoutMiddleware(['auth:api']); + } Route::apiResource('groups', API\V4\GroupsController::class); Route::get('groups/{id}/status', [API\V4\GroupsController::class, 'status']); diff --git a/src/tests/Browser/DegradedAccountTest.php b/src/tests/Browser/DegradedAccountTest.php --- a/src/tests/Browser/DegradedAccountTest.php +++ b/src/tests/Browser/DegradedAccountTest.php @@ -56,7 +56,7 @@ { // Add beta+distlist entitlements $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, ['beta-distlists', 'beta-resources', 'beta-shared-folders']); + $this->addBetaEntitlement($john); $this->browse(function (Browser $browser) { $browser->visit(new Home()) diff --git a/src/tests/Browser/DistlistTest.php b/src/tests/Browser/DistlistTest.php --- a/src/tests/Browser/DistlistTest.php +++ b/src/tests/Browser/DistlistTest.php @@ -73,15 +73,15 @@ ->assertMissing('@links .link-distlists'); }); - // Test that Distribution lists page is not accessible without the 'beta-distlists' entitlement + // Test that Distribution lists page is not accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/distlists') ->assertErrorPage(403); }); - // Create a single group, add beta+distlist entitlements + // Create a single group, add beta entitlement $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-distlists'); + $this->addBetaEntitlement($john); $group = $this->getTestGroup('group-test@kolab.org', ['name' => 'Test Group']); $group->assignToWallet($john->wallets->first()); @@ -111,7 +111,7 @@ */ public function testCreateUpdateDelete(): void { - // Test that the page is not available accessible without the 'beta-distlists' entitlement + // Test that the page is not available accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/distlist/new') ->assertErrorPage(403); @@ -119,7 +119,7 @@ // Add beta+distlist entitlements $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-distlists'); + $this->addBetaEntitlement($john); $this->browse(function (Browser $browser) { // Create a group @@ -233,7 +233,7 @@ public function testStatus(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-distlists'); + $this->addBetaEntitlement($john, 'beta'); $group = $this->getTestGroup('group-test@kolab.org'); $group->assignToWallet($john->wallets->first()); $group->status = Group::STATUS_NEW | Group::STATUS_ACTIVE; @@ -270,7 +270,7 @@ public function testSettings(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-distlists'); + $this->addBetaEntitlement($john); $group = $this->getTestGroup('group-test@kolab.org'); $group->assignToWallet($john->wallets->first()); $group->status = Group::STATUS_NEW | Group::STATUS_ACTIVE; diff --git a/src/tests/Browser/ResourceTest.php b/src/tests/Browser/ResourceTest.php --- a/src/tests/Browser/ResourceTest.php +++ b/src/tests/Browser/ResourceTest.php @@ -71,15 +71,15 @@ ->assertMissing('@links .link-resources'); }); - // Test that Resources lists page is not accessible without the 'beta-resources' entitlement + // Test that Resources lists page is not accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/resources') ->assertErrorPage(403); }); - // Add beta+beta-resources entitlements + // Add beta entitlements $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-resources'); + $this->addBetaEntitlement($john); // Make sure the first resource is active $resource = $this->getTestResource('resource-test1@kolab.org'); $resource->status = Resource::STATUS_NEW | Resource::STATUS_ACTIVE @@ -112,15 +112,15 @@ */ public function testCreateUpdateDelete(): void { - // Test that the page is not available accessible without the 'beta-resources' entitlement + // Test that the page is not available accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/resource/new') ->assertErrorPage(403); }); - // Add beta+beta-resource entitlements + // Add beta entitlements $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-resources'); + $this->addBetaEntitlement($john); $this->browse(function (Browser $browser) { // Create a resource @@ -214,7 +214,7 @@ public function testStatus(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-resources'); + $this->addBetaEntitlement($john); $resource = $this->getTestResource('resource-test2@kolab.org'); $resource->status = Resource::STATUS_NEW | Resource::STATUS_ACTIVE | Resource::STATUS_LDAP_READY; $resource->created_at = \now(); @@ -251,7 +251,7 @@ public function testSettings(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-resources'); + $this->addBetaEntitlement($john); $resource = $this->getTestResource('resource-test2@kolab.org'); $resource->setSetting('invitation_policy', null); diff --git a/src/tests/Browser/SharedFolderTest.php b/src/tests/Browser/SharedFolderTest.php --- a/src/tests/Browser/SharedFolderTest.php +++ b/src/tests/Browser/SharedFolderTest.php @@ -73,15 +73,15 @@ ->assertMissing('@links .link-shared-folders'); }); - // Test that shared folders lists page is not accessible without the 'beta-shared-folders' entitlement + // Test that shared folders lists page is not accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/shared-folders') ->assertErrorPage(403); }); - // Add beta+beta-shared-folders entitlements + // Add beta entitlement $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-shared-folders'); + $this->addBetaEntitlement($john); // Make sure the first folder is active $folder = $this->getTestSharedFolder('folder-event@kolab.org'); $folder->status = SharedFolder::STATUS_NEW | SharedFolder::STATUS_ACTIVE @@ -117,15 +117,15 @@ */ public function testCreateUpdateDelete(): void { - // Test that the page is not available accessible without the 'beta-shared-folders' entitlement + // Test that the page is not available accessible without the 'beta' entitlement $this->browse(function (Browser $browser) { $browser->visit('/shared-folder/new') ->assertErrorPage(403); }); - // Add beta+beta-shared-folders entitlements + // Add beta entitlements $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-shared-folders'); + $this->addBetaEntitlement($john); $this->browse(function (Browser $browser) { // Create a folder @@ -293,7 +293,7 @@ public function testStatus(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-shared-folders'); + $this->addBetaEntitlement($john); $folder = $this->getTestSharedFolder('folder-event@kolab.org'); $folder->status = SharedFolder::STATUS_NEW | SharedFolder::STATUS_ACTIVE | SharedFolder::STATUS_LDAP_READY; $folder->created_at = \now(); @@ -330,7 +330,7 @@ public function testSettings(): void { $john = $this->getTestUser('john@kolab.org'); - $this->addBetaEntitlement($john, 'beta-shared-folders'); + $this->addBetaEntitlement($john); $folder = $this->getTestSharedFolder('folder-event@kolab.org'); $folder->setSetting('acl', null); diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php --- a/src/tests/Browser/UsersTest.php +++ b/src/tests/Browser/UsersTest.php @@ -781,125 +781,4 @@ }); }); } - - /** - * Test beta entitlements - * - * @depends testInfo - */ - public function testBetaEntitlements(): void - { - $this->browse(function (Browser $browser) { - $john = User::where('email', 'john@kolab.org')->first(); - $sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); - $john->assignSku($sku); - - $browser->visit('/user/' . $john->id) - ->on(new UserInfo()) - ->with('@skus', function ($browser) { - $browser->assertElementsCount('tbody tr', 11) - // Meet SKU - ->assertSeeIn('tbody tr:nth-child(6) td.name', 'Voice & Video Conferencing (public beta)') - ->assertSeeIn('tr:nth-child(6) td.price', '0,00 CHF/month') - ->assertNotChecked('tbody tr:nth-child(6) td.selection input') - ->assertEnabled('tbody tr:nth-child(6) td.selection input') - ->assertTip( - 'tbody tr:nth-child(6) td.buttons button', - 'Video conferencing tool' - ) - // Beta SKU - ->assertSeeIn('tbody tr:nth-child(7) td.name', 'Private Beta (invitation only)') - ->assertSeeIn('tbody tr:nth-child(7) td.price', '0,00 CHF/month') - ->assertChecked('tbody tr:nth-child(7) td.selection input') - ->assertEnabled('tbody tr:nth-child(7) td.selection input') - ->assertTip( - 'tbody tr:nth-child(7) td.buttons button', - 'Access to the private beta program subscriptions' - ) - // Distlists SKU - ->assertSeeIn('tbody tr:nth-child(8) td.name', 'Distribution lists') - ->assertSeeIn('tr:nth-child(8) td.price', '0,00 CHF/month') - ->assertNotChecked('tbody tr:nth-child(8) td.selection input') - ->assertEnabled('tbody tr:nth-child(8) td.selection input') - ->assertTip( - 'tbody tr:nth-child(8) td.buttons button', - 'Access to mail distribution lists' - ) - // Resources SKU - ->assertSeeIn('tbody tr:nth-child(9) td.name', 'Calendaring resources') - ->assertSeeIn('tr:nth-child(9) td.price', '0,00 CHF/month') - ->assertNotChecked('tbody tr:nth-child(9) td.selection input') - ->assertEnabled('tbody tr:nth-child(9) td.selection input') - ->assertTip( - 'tbody tr:nth-child(9) td.buttons button', - 'Access to calendaring resources' - ) - // Shared folders SKU - ->scrollTo('tbody tr:nth-child(10)')->pause(250) - ->assertSeeIn('tbody tr:nth-child(10) td.name', 'Shared folders') - ->assertSeeIn('tr:nth-child(10) td.price', '0,00 CHF/month') - ->assertNotChecked('tbody tr:nth-child(10) td.selection input') - ->assertEnabled('tbody tr:nth-child(10) td.selection input') - ->assertTip( - 'tbody tr:nth-child(10) td.buttons button', - 'Access to shared folders' - ) - // Files SKU - ->scrollTo('tbody tr:nth-child(11)')->pause(250) - ->assertSeeIn('tbody tr:nth-child(11) td.name', 'File storage') - ->assertSeeIn('tr:nth-child(11) td.price', '0,00 CHF/month') - ->assertNotChecked('tbody tr:nth-child(11) td.selection input') - ->assertEnabled('tbody tr:nth-child(11) td.selection input') - ->assertTip( - 'tbody tr:nth-child(11) td.buttons button', - 'Access to file storage' - ) - // Check Distlist, Uncheck Beta, expect Distlist unchecked - ->click('#sku-input-beta-distlists') - ->click('#sku-input-beta') - ->assertNotChecked('#sku-input-beta') - ->assertNotChecked('#sku-input-beta-distlists') - // Click Distlists expect an alert - ->click('#sku-input-beta-distlists') - ->assertDialogOpened('Distribution lists requires Private Beta (invitation only).') - ->acceptDialog() - // Enable Beta and Distlist and submit - ->click('#sku-input-beta') - ->click('#sku-input-beta-distlists'); - }) - ->scrollTo('@general button[type=submit]') - ->click('@general button[type=submit]') - ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); - - $expected = [ - 'beta', - 'beta-distlists', - 'groupware', - 'mailbox', - 'storage', 'storage', 'storage', 'storage', 'storage' - ]; - - $this->assertEntitlements($john, $expected); - - $browser->visit('/user/' . $john->id) - ->on(new UserInfo()) - ->waitFor('#sku-input-beta') - ->click('#sku-input-beta') - ->scrollTo('@general button[type=submit]')->pause(500) - ->click('@general button[type=submit]') - ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); - - $expected = [ - 'groupware', - 'mailbox', - 'storage', 'storage', 'storage', 'storage', 'storage' - ]; - - $this->assertEntitlements($john, $expected); - }); - - // TODO: Test that the Distlists SKU is not available for users that aren't a group account owners - // TODO: Test that entitlements change has immediate effect on the available items in dashboard - // i.e. does not require a page reload nor re-login. - } } diff --git a/src/tests/Feature/Controller/Admin/SkusTest.php b/src/tests/Feature/Controller/Admin/SkusTest.php --- a/src/tests/Feature/Controller/Admin/SkusTest.php +++ b/src/tests/Feature/Controller/Admin/SkusTest.php @@ -82,7 +82,7 @@ $json = $response->json(); - $this->assertCount(14, $json); + $this->assertCount(10, $json); $this->assertSame(100, $json[0]['prio']); $this->assertSame($sku->id, $json[0]['id']); diff --git a/src/tests/Feature/Controller/Reseller/SkusTest.php b/src/tests/Feature/Controller/Reseller/SkusTest.php --- a/src/tests/Feature/Controller/Reseller/SkusTest.php +++ b/src/tests/Feature/Controller/Reseller/SkusTest.php @@ -99,7 +99,7 @@ $json = $response->json(); - $this->assertCount(14, $json); + $this->assertCount(10, $json); $this->assertSame(100, $json[0]['prio']); $this->assertSame($sku->id, $json[0]['id']); diff --git a/src/tests/Feature/Controller/SkusTest.php b/src/tests/Feature/Controller/SkusTest.php --- a/src/tests/Feature/Controller/SkusTest.php +++ b/src/tests/Feature/Controller/SkusTest.php @@ -105,7 +105,7 @@ $json = $response->json(); - $this->assertCount(14, $json); + $this->assertCount(10, $json); $this->assertSame(100, $json[0]['prio']); $this->assertSame($sku->id, $json[0]['id']); @@ -215,7 +215,7 @@ $json = $response->json(); - $this->assertCount(11, $json); + $this->assertCount(6, $json); $this->assertSkuElement('beta', $json[6], [ 'prio' => 10, @@ -224,42 +224,6 @@ 'enabled' => false, 'readonly' => false, ]); - - $this->assertSkuElement('beta-distlists', $json[7], [ - 'prio' => 10, - 'type' => 'user', - 'handler' => 'Beta\Distlists', - 'enabled' => false, - 'readonly' => false, - 'required' => ['Beta'], - ]); - - $this->assertSkuElement('beta-resources', $json[8], [ - 'prio' => 10, - 'type' => 'user', - 'handler' => 'Beta\Resources', - 'enabled' => false, - 'readonly' => false, - 'required' => ['Beta'], - ]); - - $this->assertSkuElement('beta-shared-folders', $json[9], [ - 'prio' => 10, - 'type' => 'user', - 'handler' => 'Beta\SharedFolders', - 'enabled' => false, - 'readonly' => false, - 'required' => ['Beta'], - ]); - - $this->assertSkuElement('files', $json[10], [ - 'prio' => 10, - 'type' => 'user', - 'handler' => 'Files', - 'enabled' => false, - 'readonly' => false, - 'required' => ['Beta'], - ]); } /** diff --git a/src/tests/TestCaseTrait.php b/src/tests/TestCaseTrait.php --- a/src/tests/TestCaseTrait.php +++ b/src/tests/TestCaseTrait.php @@ -163,9 +163,6 @@ { $beta_handlers = [ 'App\Handlers\Beta', - 'App\Handlers\Beta\Distlists', - 'App\Handlers\Beta\Resources', - 'App\Handlers\Beta\SharedFolders', ]; $betas = Sku::whereIn('handler_class', $beta_handlers)->pluck('id')->all();