From 220998839bce59989f3289554be11933ea5323b8 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Tue, 31 Oct 2023 13:25:12 +0100 Subject: [PATCH] Merge pull request #15504 from overleaf/msm-fix-import-sp [web] Replace module import breaking Server Pro GitOrigin-RevId: 23f65b06d14019d1878c61abdf71b6b556192dc4 --- .../UserMembership/UserMembershipController.js | 6 ++---- .../UserMembership/UserMembershipControllerTests.js | 11 +++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.js b/services/web/app/src/Features/UserMembership/UserMembershipController.js index 456f14ad13..4c00a66723 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipController.js +++ b/services/web/app/src/Features/UserMembership/UserMembershipController.js @@ -16,15 +16,13 @@ const Errors = require('../Errors/Errors') const EmailHelper = require('../Helpers/EmailHelper') const { csvAttachment } = require('../../infrastructure/Response') const { UserIsManagerError } = require('./UserMembershipErrors') +const { SSOConfig } = require('../../models/SSOConfig') const CSVParser = require('json2csv').Parser -const SSOConfigManager = require('../../../../modules/managed-users/app/src/SSOConfigManager') async function manageGroupMembers(req, res, next) { const { entity, entityConfig } = req - const ssoConfig = await SSOConfigManager.promises.getSSOConfig( - entity.ssoConfig - ) + const ssoConfig = await SSOConfig.findById(entity.ssoConfig).exec() return entity.fetchV1Data(function (error, entity) { if (error != null) { return next(error) diff --git a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js index 0150dcb75f..69840dc262 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js +++ b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.js @@ -69,10 +69,10 @@ describe('UserMembershipController', function () { getSessionUser: sinon.stub().returns(this.user), getLoggedInUserId: sinon.stub().returns(this.user._id), } - this.SSOConfigManager = { - promises: { - getSSOConfig: sinon.stub().resolves({ enabled: true }), - }, + this.SSOConfig = { + findById: sinon + .stub() + .returns({ exec: sinon.stub().resolves({ enabled: true }) }), } this.UserMembershipHandler = { getEntity: sinon.stub().yields(null, this.subscription), @@ -96,8 +96,7 @@ describe('UserMembershipController', function () { '../SplitTests/SplitTestHandler': this.SplitTestHandler, './UserMembershipHandler': this.UserMembershipHandler, '@overleaf/settings': this.Settings, - '../../../../modules/managed-users/app/src/SSOConfigManager': - this.SSOConfigManager, + '../../models/SSOConfig': { SSOConfig: this.SSOConfig }, }, } ))