From 2d122323eb47a21dff45003decd88c669fc5643b Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Wed, 20 Nov 2024 11:55:26 +0100 Subject: [PATCH] Merge pull request #21884 from overleaf/msm-remove-group-sso-enabled-flag [web] Cleanup `GROUP_SSO_ENABLED` env variable GitOrigin-RevId: b41ce989348c70c3b4ca59ebf4986edf059534aa --- .../Features/Subscription/plansFeatures.js | 4 +- .../app/src/infrastructure/ExpressLocals.js | 1 - services/web/app/src/models/Subscription.js | 4 +- .../dashboard/group-settings-button.tsx | 5 +- ...l_managed_users_sso_from_subscriptions.mjs | 21 ++ .../managed-group-subscriptions.test.tsx | 265 +++++------------- services/web/types/exposed-settings.ts | 1 - 7 files changed, 91 insertions(+), 210 deletions(-) create mode 100644 services/web/migrations/20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs diff --git a/services/web/app/src/Features/Subscription/plansFeatures.js b/services/web/app/src/Features/Subscription/plansFeatures.js index 617309dd62..d89e621a9a 100644 --- a/services/web/app/src/Features/Subscription/plansFeatures.js +++ b/services/web/app/src/Features/Subscription/plansFeatures.js @@ -1,5 +1,3 @@ -const Settings = require('@overleaf/settings') - const individualPlans = [ { divider: false, @@ -259,7 +257,7 @@ const groupPlans = [ value: 'bool', plans: { group_standard: false, - group_professional: Settings.groupSSO?.enabled === true, + group_professional: true, organization: true, }, }, diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 181cfb913b..975ca7d07c 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -425,7 +425,6 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) { cookieDomain: Settings.cookieDomain, templateLinks: Settings.templateLinks, labsEnabled: Settings.labs && Settings.labs.enable, - groupSSOEnabled: Settings.groupSSO?.enabled, wikiEnabled: Settings.overleaf != null || Settings.proxyLearn, templatesEnabled: Settings.overleaf != null || Settings.templates?.user_id != null, diff --git a/services/web/app/src/models/Subscription.js b/services/web/app/src/models/Subscription.js index f0afd0bb9a..43dc418010 100644 --- a/services/web/app/src/models/Subscription.js +++ b/services/web/app/src/models/Subscription.js @@ -33,8 +33,8 @@ const SubscriptionSchema = new Schema( membersLimit: { type: Number, default: 0 }, customAccount: Boolean, features: { - managedUsers: { type: Boolean, default: null }, - groupSSO: { type: Boolean, default: null }, + managedUsers: { type: Boolean, default: true }, + groupSSO: { type: Boolean, default: true }, }, addOns: Schema.Types.Mixed, overleaf: { diff --git a/services/web/frontend/js/features/subscription/components/dashboard/group-settings-button.tsx b/services/web/frontend/js/features/subscription/components/dashboard/group-settings-button.tsx index 86e477528e..d71a96595e 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/group-settings-button.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/group-settings-button.tsx @@ -1,5 +1,4 @@ import { RowLink } from '@/features/subscription/components/dashboard/row-link' -import getMeta from '@/utils/meta' import { useTranslation } from 'react-i18next' import { ManagedGroupSubscription } from '../../../../../../types/subscription/dashboard/subscription' @@ -10,13 +9,11 @@ export default function GroupSettingsButton({ }) { const { t } = useTranslation() - const { groupSSOEnabled } = getMeta('ol-ExposedSettings') - const subscriptionHasManagedUsers = subscription.features?.managedUsers !== false const subscriptionHasGroupSSO = subscription.features?.groupSSO === true || - (groupSSOEnabled && subscription.features?.groupSSO === null) + subscription.features?.groupSSO === null let groupSettingRowSubText = '' if (subscriptionHasGroupSSO && subscriptionHasManagedUsers) { diff --git a/services/web/migrations/20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs b/services/web/migrations/20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs new file mode 100644 index 0000000000..de6282daac --- /dev/null +++ b/services/web/migrations/20241111133330_remove_null_managed_users_sso_from_subscriptions.mjs @@ -0,0 +1,21 @@ +const tags = ['saas'] + +const migrate = async client => { + const { db } = client + await db.subscriptions.updateMany( + { 'features.managedUsers': { $eq: null } }, + { $set: { 'features.managedUsers': true } } + ) + await db.subscriptions.updateMany( + { 'features.groupSSO': { $eq: null } }, + { $set: { 'features.groupSSO': true } } + ) +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +} diff --git a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx index 685f3296b8..a090e33211 100644 --- a/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx +++ b/services/web/test/frontend/features/subscription/components/dashboard/managed-group-subscriptions.test.tsx @@ -6,7 +6,6 @@ import { cleanUpContext, renderWithSubscriptionDashContext, } from '../../helpers/render-with-subscription-dash-context' -import getMeta from '@/utils/meta' function getManagedGroupSubscriptions( groupSSO: boolean | null, @@ -180,209 +179,77 @@ describe('', function () { .be.null }) - describe('with group SSO off by default', function () { - beforeEach(function () { - Object.assign(getMeta('ol-ExposedSettings'), { - groupSSOEnabled: false, - }) - }) - - it('renders the Manage group settings row when feature is turned on', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions2, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions2[0]._id], - }, - ], - }) - await screen.findAllByText('Manage group settings') - await screen.findAllByText('Configure and manage SSO and Managed Users') - }) - - describe('renders the the correct subText for Manage Group settings row', async function () { - it('with managedUsers.enabled=true and groupSSO.enabled=true', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions2, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions2[0]._id], - }, - ], - }) - await screen.findAllByText('Configure and manage SSO and Managed Users') - }) - - it('with managedUsers.enabled=false and groupSSO.enabled=true', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions3, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions3[0]._id], - }, - ], - }) - await screen.findAllByText('Configure and manage SSO') - }) - - it('with managedUsers.enabled=true and groupSSO.enabled=false', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions4, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions4[0]._id], - }, - ], - }) - await screen.findAllByText('Turn on Managed Users') - }) - - it('with managedUsers.enabled=true and groupSSO.enabled=null', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions5, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions5[0]._id], - }, - ], - }) - await screen.findAllByText('Turn on Managed Users') - }) + it('renders Managed Group / Group SSO settings row when both features are turned on', async function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: managedGroupSubscriptions2, + }, + { + name: 'ol-groupSettingsEnabledFor', + value: [managedGroupSubscriptions2[0]._id], + }, + ], }) + await screen.findAllByText('Manage group settings') + await screen.findAllByText('Configure and manage SSO and Managed Users') }) - describe('with group SSO on by default', function () { - it('renders the Manage group settings row when features are turned on', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions2, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions2[0]._id], - }, - { - name: 'ol-ExposedSettings', - value: { - groupSSOEnabled: true, - }, - }, - ], - }) - await screen.findAllByText('Manage group settings') - await screen.findAllByText('Configure and manage SSO and Managed Users') + it('renders Group SSO settings when the feature is null', async function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: managedGroupSubscriptions5, + }, + { + name: 'ol-groupSettingsEnabledFor', + value: [managedGroupSubscriptions5[0]._id], + }, + ], }) + await screen.findAllByText('Manage group settings') + await screen.findAllByText('Configure and manage SSO and Managed Users') + }) - describe('renders the the correct subText for Manage Group settings row', async function () { - it('with managedUsers.enabled=true and groupSSO.enabled=true', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions2, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions2[0]._id], - }, - { - name: 'ol-ExposedSettings', - value: { - groupSSOEnabled: true, - }, - }, - ], - }) - await screen.findAllByText('Configure and manage SSO and Managed Users') - }) - - it('with managedUsers.enabled=false and groupSSO.enabled=true', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions3, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions3[0]._id], - }, - { - name: 'ol-ExposedSettings', - value: { - groupSSOEnabled: true, - }, - }, - ], - }) - await screen.findAllByText('Configure and manage SSO') - }) - - it('with managedUsers.enabled=true and groupSSO.enabled=false', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions4, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions4[0]._id], - }, - { - name: 'ol-ExposedSettings', - value: { - groupSSOEnabled: true, - }, - }, - ], - }) - await screen.findAllByText('Turn on Managed Users') - }) - - it('with managedUsers.enabled=true and groupSSO.enabled=null', async function () { - renderWithSubscriptionDashContext(, { - metaTags: [ - { - name: 'ol-managedGroupSubscriptions', - value: managedGroupSubscriptions5, - }, - { - name: 'ol-groupSettingsEnabledFor', - value: [managedGroupSubscriptions5[0]._id], - }, - { - name: 'ol-ExposedSettings', - value: { - groupSSOEnabled: true, - }, - }, - ], - }) - await screen.findAllByText('Configure and manage SSO and Managed Users') - }) + it('does not render Group SSO settings when the feature is turned off', async function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: managedGroupSubscriptions4, + }, + { + name: 'ol-groupSettingsEnabledFor', + value: [managedGroupSubscriptions4[0]._id], + }, + ], }) + await screen.findAllByText('Manage group settings') + await screen.findAllByText('Turn on Managed Users') + expect(screen.queryByText('Configure and manage SSO and Managed Users')).to + .not.exist + expect(screen.queryByText('Configure and manage SSO')).to.not.exist + }) + + it('does not render MAnaged Group settings when the feature is turned off', async function () { + renderWithSubscriptionDashContext(, { + metaTags: [ + { + name: 'ol-managedGroupSubscriptions', + value: managedGroupSubscriptions3, + }, + { + name: 'ol-groupSettingsEnabledFor', + value: [managedGroupSubscriptions3[0]._id], + }, + ], + }) + await screen.findAllByText('Manage group settings') + await screen.findAllByText('Configure and manage SSO') + expect(screen.queryByText('Turn on Managed Users')).to.not.exist + expect(screen.queryByText('Configure and manage SSO and Managed Users')).to + .not.exist }) }) diff --git a/services/web/types/exposed-settings.ts b/services/web/types/exposed-settings.ts index b4f52dcdfa..9656441fa9 100644 --- a/services/web/types/exposed-settings.ts +++ b/services/web/types/exposed-settings.ts @@ -47,7 +47,6 @@ export type ExposedSettings = { fileIgnorePattern: string templateLinks?: TemplateLink[] labsEnabled: boolean - groupSSOEnabled?: boolean wikiEnabled?: boolean templatesEnabled?: boolean }