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
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
322 lines
10 KiB
TypeScript
322 lines
10 KiB
TypeScript
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 { updatePermission } from '../../data/permissions.helper';
|
|
|
|
describe('[Cloud]', function () {
|
|
this.retries(0);
|
|
|
|
before((done) => getCredentials(done));
|
|
|
|
describe('[/cloud.manualRegister]', () => {
|
|
before(async () => {
|
|
return updatePermission('register-on-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('register-on-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.post(api('cloud.manualRegister'))
|
|
.expect('Content-Type', 'application/json')
|
|
.send({
|
|
cloudBlob: 'test-blob',
|
|
})
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
expect(res.body).to.have.property('message', 'You must be logged in to do this.');
|
|
});
|
|
});
|
|
|
|
it('should fail when cloudBlob property is not provided', async () => {
|
|
return request
|
|
.post(api('cloud.manualRegister'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(400)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('errorType', 'invalid-params');
|
|
expect(res.body).to.have.property('error', "must have required property 'cloudBlob'");
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the register-on-cloud permission', async () => {
|
|
await updatePermission('register-on-cloud', []);
|
|
return request
|
|
.post(api('cloud.manualRegister'))
|
|
.set(credentials)
|
|
.send({
|
|
cloudBlob: 'test-blob',
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('error', 'User does not have the permissions required for this action [error-unauthorized]');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('[/cloud.createRegistrationIntent]', () => {
|
|
before(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.post(api('cloud.createRegistrationIntent'))
|
|
.expect('Content-Type', 'application/json')
|
|
.send({
|
|
email: 'test-mail@example.com',
|
|
resend: true,
|
|
})
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
expect(res.body).to.have.property('message', 'You must be logged in to do this.');
|
|
});
|
|
});
|
|
|
|
it('should fail when resend property is not provided', async () => {
|
|
return request
|
|
.post(api('cloud.createRegistrationIntent'))
|
|
.set(credentials)
|
|
.send({
|
|
email: 'test-mail@example.com',
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(400)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('errorType', 'invalid-params');
|
|
expect(res.body).to.have.property('error', "must have required property 'resend'");
|
|
});
|
|
});
|
|
|
|
it('should fail when email property is not provided', async () => {
|
|
return request
|
|
.post(api('cloud.createRegistrationIntent'))
|
|
.set(credentials)
|
|
.send({
|
|
resend: true,
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(400)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('errorType', 'invalid-params');
|
|
expect(res.body).to.have.property('error', "must have required property 'email'");
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', []);
|
|
return request
|
|
.post(api('cloud.createRegistrationIntent'))
|
|
.set(credentials)
|
|
.send({
|
|
email: 'test-mail@example.com',
|
|
resend: true,
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('error', 'User does not have the permissions required for this action [error-unauthorized]');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('[/cloud.confirmationPoll]', () => {
|
|
before(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.get(api('cloud.confirmationPoll'))
|
|
.query({
|
|
deviceCode: 'test-code',
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
expect(res.body).to.have.property('message', 'You must be logged in to do this.');
|
|
});
|
|
});
|
|
|
|
it('should fail when deviceCode property is not provided', async () => {
|
|
return request
|
|
.get(api('cloud.confirmationPoll'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(400)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('errorType', 'error-invalid-params');
|
|
expect(res.body).to.have.property('error', "must have required property 'deviceCode'");
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', []);
|
|
return request
|
|
.get(api('cloud.confirmationPoll'))
|
|
.set(credentials)
|
|
.query({
|
|
deviceCode: 'test-code',
|
|
})
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
expect(res.body).to.have.property('error', 'User does not have the permissions required for this action [error-unauthorized]');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('[/cloud.registrationStatus]', () => {
|
|
before(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.get(api('cloud.registrationStatus'))
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
expect(res.body).to.have.property('message', 'You must be logged in to do this.');
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', []);
|
|
return request
|
|
.get(api('cloud.registrationStatus'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
});
|
|
});
|
|
|
|
it('should return registration status when user has the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', ['admin']);
|
|
return request
|
|
.get(api('cloud.registrationStatus'))
|
|
.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('registrationStatus');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('[/cloud.workspaceRegisterData]', () => {
|
|
before(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.get(api('cloud.workspaceRegisterData'))
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', []);
|
|
return request
|
|
.get(api('cloud.workspaceRegisterData'))
|
|
.set(credentials)
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
});
|
|
});
|
|
|
|
it('should return a base64 encoded registration payload when user has the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', ['admin']);
|
|
return request
|
|
.get(api('cloud.workspaceRegisterData'))
|
|
.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('registerData').that.is.a('string');
|
|
|
|
const decoded = JSON.parse(Buffer.from(res.body.registerData, 'base64').toString());
|
|
expect(decoded).to.have.property('uniqueId');
|
|
expect(decoded).to.have.property('workspaceId');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('[/cloud.connectWorkspace]', () => {
|
|
before(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
after(async () => {
|
|
return updatePermission('manage-cloud', ['admin']);
|
|
});
|
|
|
|
it('should fail if user is not authenticated', async () => {
|
|
return request
|
|
.post(api('cloud.connectWorkspace'))
|
|
.send({ token: 'invalid-token' })
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(401)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('status', 'error');
|
|
});
|
|
});
|
|
|
|
it('should fail when user does not have the manage-cloud permission', async () => {
|
|
await updatePermission('manage-cloud', []);
|
|
return request
|
|
.post(api('cloud.connectWorkspace'))
|
|
.set(credentials)
|
|
.send({ token: 'invalid-token' })
|
|
.expect('Content-Type', 'application/json')
|
|
.expect(403)
|
|
.expect((res: Response) => {
|
|
expect(res.body).to.have.property('success', false);
|
|
});
|
|
});
|
|
});
|
|
});
|