|
|
|
|
@ -3,7 +3,7 @@ import { expect } from 'chai'; |
|
|
|
|
import { getCredentials, api, request, credentials, group, apiPrivateChannelName } from '../../data/api-data.js'; |
|
|
|
|
import { adminUsername, password } from '../../data/user.js'; |
|
|
|
|
import { createUser, login } from '../../data/users.helper'; |
|
|
|
|
import { updatePermission } from '../../data/permissions.helper'; |
|
|
|
|
import { updatePermission, updateSetting } from '../../data/permissions.helper'; |
|
|
|
|
import { createRoom } from '../../data/rooms.helper'; |
|
|
|
|
import { createIntegration, removeIntegration } from '../../data/integration.helper'; |
|
|
|
|
|
|
|
|
|
@ -43,7 +43,49 @@ describe('[Groups]', function() { |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
describe('/groups.create (encrypted)', () => { |
|
|
|
|
it('should create a new encrypted group', async () => { |
|
|
|
|
await request.post(api('groups.create')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
name: `encrypted-${ apiPrivateChannelName }`, |
|
|
|
|
extraData: { |
|
|
|
|
encrypted: true, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body).to.have.nested.property('group.name', `encrypted-${ apiPrivateChannelName }`); |
|
|
|
|
expect(res.body).to.have.nested.property('group.t', 'p'); |
|
|
|
|
expect(res.body).to.have.nested.property('group.msgs', 0); |
|
|
|
|
expect(res.body).to.have.nested.property('group.encrypted', true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should create the encrypted room by default', async () => { |
|
|
|
|
await updateSetting('E2E_Enabled_Default_PrivateRooms', true); |
|
|
|
|
try { |
|
|
|
|
await request.post(api('groups.create')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
name: `default-encrypted-${ apiPrivateChannelName }`, |
|
|
|
|
}) |
|
|
|
|
.expect('Content-Type', 'application/json') |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', true); |
|
|
|
|
expect(res.body).to.have.nested.property('group.name', `default-encrypted-${ apiPrivateChannelName }`); |
|
|
|
|
expect(res.body).to.have.nested.property('group.t', 'p'); |
|
|
|
|
expect(res.body).to.have.nested.property('group.msgs', 0); |
|
|
|
|
expect(res.body).to.have.nested.property('group.encrypted', true); |
|
|
|
|
}); |
|
|
|
|
} finally { |
|
|
|
|
await updateSetting('E2E_Enabled_Default_PrivateRooms', false); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
describe('[/groups.info]', () => { |
|
|
|
|
let testGroup = {}; |
|
|
|
|
let groupMessage = {}; |
|
|
|
|
@ -177,7 +219,6 @@ describe('[Groups]', function() { |
|
|
|
|
|
|
|
|
|
it('/groups.invite', async () => { |
|
|
|
|
const roomInfo = await getRoomInfo(group._id); |
|
|
|
|
|
|
|
|
|
return request.post(api('groups.invite')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
|