-
Notifications
You must be signed in to change notification settings - Fork 13.8k
fix: Setup wizard forced back into registration on upgrade when Show_Setup_Wizard is env-overridden #41254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: Setup wizard forced back into registration on upgrade when Show_Setup_Wizard is env-overridden #41254
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3927b20
fix: respect Show_Setup_Wizard env override on version-change boots
KevLehman f94c02b
fix: rely on persisted env value source instead of runtime env check
KevLehman ca3a5db
refactor: simplify override stamp checks and deep-compare setting values
KevLehman 41a7727
Update apps/meteor/server/startup/cloudRegistration.ts
KevLehman f4452a6
fix ts
KevLehman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes the setup wizard being forced back into the registration step on the first start after an upgrade when `OVERWRITE_SETTING_Show_Setup_Wizard=completed` is set, which affected air-gapped workspaces running offline licenses without cloud registration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
apps/meteor/tests/unit/server/startup/cloudRegistration.tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { expect } from 'chai'; | ||
| import { beforeEach, describe, it } from 'mocha'; | ||
| import proxyquire from 'proxyquire'; | ||
| import sinon from 'sinon'; | ||
|
|
||
| const models = { | ||
| Settings: { | ||
| getValueById: sinon.stub(), | ||
| findOneById: sinon.stub(), | ||
| updateValueById: sinon.stub(), | ||
| }, | ||
| }; | ||
|
|
||
| const { ensureCloudWorkspaceRegistered } = proxyquire.noCallThru().load('../../../../server/startup/cloudRegistration', { | ||
| '@rocket.chat/models': models, | ||
| }); | ||
|
|
||
| describe('ensureCloudWorkspaceRegistered', () => { | ||
| const stubSettings = (values: Record<string, string | undefined>, showSetupWizard: Record<string, unknown> | null) => { | ||
| models.Settings.getValueById.callsFake(async (id: string) => values[id]); | ||
| models.Settings.findOneById.resolves(showSetupWizard); | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| models.Settings.getValueById.reset(); | ||
| models.Settings.findOneById.reset(); | ||
| models.Settings.updateValueById.reset(); | ||
| }); | ||
|
|
||
| it('should not touch the setting when its value was pinned via env override and is unchanged', async () => { | ||
| stubSettings({}, { value: 'completed', valueSource: 'processEnvValue', processEnvValue: 'completed' }); | ||
|
|
||
| await ensureCloudWorkspaceRegistered(); | ||
|
|
||
| expect(models.Settings.updateValueById.called).to.be.false; | ||
| }); | ||
|
|
||
| it('should flip the setting when the value diverged from the env override', async () => { | ||
| stubSettings({}, { value: 'completed', valueSource: 'processEnvValue', processEnvValue: 'pending' }); | ||
|
|
||
| await ensureCloudWorkspaceRegistered(); | ||
|
|
||
| expect(models.Settings.updateValueById.calledOnceWith('Show_Setup_Wizard', 'in_progress')).to.be.true; | ||
| }); | ||
|
|
||
| it('should not touch the setting when the workspace is already registered', async () => { | ||
| stubSettings( | ||
| { | ||
| Cloud_Workspace_Client_Id: 'client-id', | ||
| Cloud_Workspace_Client_Secret: 'client-secret', | ||
| }, | ||
| { value: 'completed', valueSource: 'packageValue' }, | ||
| ); | ||
|
|
||
| await ensureCloudWorkspaceRegistered(); | ||
|
|
||
| expect(models.Settings.updateValueById.called).to.be.false; | ||
| }); | ||
|
|
||
| it('should not touch the setting when the setup wizard is not completed', async () => { | ||
| stubSettings({}, { value: 'in_progress', valueSource: 'packageValue' }); | ||
|
|
||
| await ensureCloudWorkspaceRegistered(); | ||
|
|
||
| expect(models.Settings.updateValueById.called).to.be.false; | ||
| }); | ||
|
|
||
| it('should flip the setup wizard to in_progress when unregistered, completed and not env-pinned', async () => { | ||
| stubSettings({}, { value: 'completed', valueSource: 'packageValue' }); | ||
|
|
||
| await ensureCloudWorkspaceRegistered(); | ||
|
|
||
| expect(models.Settings.updateValueById.calledOnceWith('Show_Setup_Wizard', 'in_progress')).to.be.true; | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.