Merge pull request #21884 from overleaf/msm-remove-group-sso-enabled-flag

[web] Cleanup `GROUP_SSO_ENABLED` env variable

GitOrigin-RevId: b41ce989348c70c3b4ca59ebf4986edf059534aa
This commit is contained in:
Miguel Serrano
2024-11-20 11:55:26 +01:00
committed by Copybot
parent 7743c861a4
commit 2d122323eb
7 changed files with 91 additions and 210 deletions

View File

@@ -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,
},
},

View File

@@ -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,

View File

@@ -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: {

View File

@@ -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) {

View File

@@ -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,
}

View File

@@ -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('<ManagedGroupSubscriptions />', 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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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(<ManagedGroupSubscriptions />, {
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
})
})

View File

@@ -47,7 +47,6 @@ export type ExposedSettings = {
fileIgnorePattern: string
templateLinks?: TemplateLink[]
labsEnabled: boolean
groupSSOEnabled?: boolean
wikiEnabled?: boolean
templatesEnabled?: boolean
}