Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Failing after 2s
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
88 lines
2.9 KiB
TypeScript
88 lines
2.9 KiB
TypeScript
import type { ISetting } from '@rocket.chat/core-typings';
|
|
import { expect } from 'chai';
|
|
import { after, before, describe, it } from 'mocha';
|
|
import type { Response } from 'supertest';
|
|
|
|
import { getCredentials, api, request, credentials } from '../../data/api-data';
|
|
import { getSettingValueById, updateSetting } from '../../data/permissions.helper';
|
|
|
|
describe('[SetupWizard]', function () {
|
|
this.retries(0);
|
|
|
|
before((done) => getCredentials(done));
|
|
|
|
describe('[/setupWizard.parameters]', () => {
|
|
it('should return the wizard parameters without authentication', async () => {
|
|
return request
|
|
.get(api('setupWizard.parameters'))
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(200)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', true);
|
|
expect(res.body).to.have.property('serverAlreadyRegistered').that.is.a('boolean');
|
|
expect(res.body).to.have.property('settings').that.is.an('array');
|
|
});
|
|
});
|
|
|
|
it('should only return settings that belong to the wizard', async () => {
|
|
return request
|
|
.get(api('setupWizard.parameters'))
|
|
.expect(200)
|
|
.expect((res: Response) => {
|
|
expect(res.body.settings).to.not.be.empty;
|
|
res.body.settings.forEach((setting: Record<string, unknown>) => {
|
|
expect(setting).to.have.property('wizard');
|
|
expect(setting).to.have.property('_id');
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should return the wizard parameters when authenticated', async () => {
|
|
return request
|
|
.get(api('setupWizard.parameters'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(200)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', true);
|
|
expect(res.body).to.have.property('settings').that.is.an('array');
|
|
});
|
|
});
|
|
|
|
describe('when the setup wizard is already completed', () => {
|
|
let previousState: ISetting['value'];
|
|
|
|
before(async () => {
|
|
previousState = await getSettingValueById('Show_Setup_Wizard');
|
|
await updateSetting('Show_Setup_Wizard', 'completed');
|
|
});
|
|
|
|
after(async () => updateSetting('Show_Setup_Wizard', previousState));
|
|
|
|
it('should not expose the wizard parameters to unauthenticated requests', async () => {
|
|
return request
|
|
.get(api('setupWizard.parameters'))
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.not.have.property('settings');
|
|
expect(res.body).to.not.have.property('serverAlreadyRegistered');
|
|
});
|
|
});
|
|
|
|
it('should not expose the wizard parameters to authenticated requests', async () => {
|
|
return request
|
|
.get(api('setupWizard.parameters'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.not.have.property('settings');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|