four new modules
This commit is contained in:
@@ -91,6 +91,20 @@ describe('Checking changenick module', () => {
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should prevent admin impersonation', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'changenick',
|
||||
nick: 'admin',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should not update if there is no change', async () => {
|
||||
const resp = await importedModule.run({
|
||||
|
||||
@@ -121,6 +121,23 @@ describe('Checking chat module', () => {
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should reject too long of customId', async () => {
|
||||
const newPayload = { ...mockPayload };
|
||||
newPayload.customId = '1234567890';
|
||||
|
||||
const newSocket = { ...mocks.plebSocket };
|
||||
newSocket.color = '000000';
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: newSocket,
|
||||
payload: newPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should initialize hooks', async () => {
|
||||
expect(() => importedModule.initHooks(mocks.server)).not.to.throw();
|
||||
});
|
||||
@@ -195,4 +212,15 @@ describe('Checking chat module', () => {
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should cleanup old active messages', async () => {
|
||||
importedModule.ACTIVE_MESSAGES.push({
|
||||
customId: '1234',
|
||||
userid: 1234,
|
||||
sent: 0,
|
||||
toDelete: false,
|
||||
});
|
||||
|
||||
expect(() => importedModule.cleanActiveMessages()).not.to.throw();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/mod/disablecaptcha.js';
|
||||
let importedModule;
|
||||
|
||||
const mockPayload = {
|
||||
cmd: 'disablecaptcha',
|
||||
}
|
||||
|
||||
const mockChannelPayload = {
|
||||
cmd: 'disablecaptcha',
|
||||
channel: 'test',
|
||||
}
|
||||
|
||||
describe('Checking disablecaptcha module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should be named', async () => {
|
||||
expect(importedModule.info.name).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be categorized', async () => {
|
||||
expect(importedModule.info.category).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be described', async () => {
|
||||
expect(importedModule.info.description).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be documented', async () => {
|
||||
expect(importedModule.info.usage).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be invokable', async () => {
|
||||
expect(importedModule.run).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should initialize', async () => {
|
||||
mocks.core.captchas = undefined;
|
||||
const resp = importedModule.init(mocks.core);
|
||||
|
||||
expect(mocks.core.captchas).to.be.an('object');
|
||||
});
|
||||
|
||||
// module main function
|
||||
it('should be invokable only by a mod', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should accept a channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChannelPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept no channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should fail on missing channel data', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
});
|
||||
+131
-20
@@ -191,25 +191,30 @@ describe('Checking dumb module', () => {
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should shadow block invite attempts', async () => {
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
it('should shadow block chat attempts, checking for allies', async () => {
|
||||
mocks.core.muzzledHashes['testHash'] = {
|
||||
dumb: true,
|
||||
allies: [1234],
|
||||
};
|
||||
mocks.plebSocket.hcProtocol = 1;
|
||||
const newSocket = Object.assign({}, mocks.plebSocket);
|
||||
newSocket.hash = 'cantcatchme';
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
const resp = importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
socket: newSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: [],
|
||||
text: 'test',
|
||||
channel: 'cake',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should shadow block invite attempts with ratelimiting', async () => {
|
||||
it('should ratelimit invites', async () => {
|
||||
const oldRL = mocks.server.police.frisk;
|
||||
mocks.server.police.frisk = () => true;
|
||||
|
||||
@@ -221,9 +226,9 @@ describe('Checking dumb module', () => {
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: [],
|
||||
channel: 'cake',
|
||||
cmd: 'invite',
|
||||
userid: 12,
|
||||
channel: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -232,7 +237,7 @@ describe('Checking dumb module', () => {
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should verify userid params on shadow block invite attempts', async () => {
|
||||
it('should validate v2 clients userid param', async () => {
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 2;
|
||||
|
||||
@@ -241,17 +246,16 @@ describe('Checking dumb module', () => {
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
userid: '1234',
|
||||
text: [],
|
||||
channel: 'cake',
|
||||
cmd: 'invite',
|
||||
userid: 'test',
|
||||
channel: 1,
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should verify channel params on shadow block invite attempts', async () => {
|
||||
it('should validate v2 clients channel param', async () => {
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 2;
|
||||
|
||||
@@ -260,16 +264,123 @@ describe('Checking dumb module', () => {
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
userid: 1234,
|
||||
text: [],
|
||||
channel: false,
|
||||
cmd: 'invite',
|
||||
userid: 12,
|
||||
channel: 1,
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should give warning if user is missing', async () => {
|
||||
const origFindSockets = mocks.server.findSockets;
|
||||
mocks.server.findSockets = () => false;
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 2;
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'invite',
|
||||
userid: 12,
|
||||
channel: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.server.findSockets = origFindSockets;
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should handle v2 output', async () => {
|
||||
const origFindSockets = mocks.server.findSockets;
|
||||
mocks.server.findSockets = () => [mocks.plebSocket];
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 2;
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'invite',
|
||||
userid: 12,
|
||||
channel: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.server.findSockets = origFindSockets;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should validate v1 clients channel', async () => {
|
||||
const origPlebSocket = {...mocks.plebSocket};
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 1;
|
||||
mocks.plebSocket.channel = undefined;
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'invite',
|
||||
nick: 'test',
|
||||
channel: 1,
|
||||
},
|
||||
});
|
||||
|
||||
mocks.plebSocket = origPlebSocket;
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should validate v1 clients nick param', async () => {
|
||||
const origPlebSocket = {...mocks.plebSocket};
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 1;
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'invite',
|
||||
nick: 0,
|
||||
channel: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.plebSocket = origPlebSocket;
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should handle v1 output', async () => {
|
||||
const origPlebSocket = {...mocks.plebSocket};
|
||||
mocks.core.muzzledHashes['testHash'] = true;
|
||||
mocks.plebSocket.hcProtocol = 1;
|
||||
|
||||
const resp = importedModule.inviteCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'invite',
|
||||
nick: 'test',
|
||||
channel: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.plebSocket = origPlebSocket;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should accept an allies param', async () => {
|
||||
mockPayload.allies = [1234, 5678];
|
||||
const resp = await importedModule.run({
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/mod/enablecaptcha.js';
|
||||
let importedModule;
|
||||
|
||||
const targetChannel = 'test';
|
||||
|
||||
const mockPayload = {
|
||||
cmd: 'enablecaptcha',
|
||||
}
|
||||
|
||||
const mockChannelPayload = {
|
||||
cmd: 'enablecaptcha',
|
||||
channel: targetChannel,
|
||||
}
|
||||
|
||||
const mockBadChatPayload = {
|
||||
cmd: 'chat',
|
||||
text: {},
|
||||
}
|
||||
|
||||
const mockChatPayload = {
|
||||
cmd: 'chat',
|
||||
text: 'asdf',
|
||||
}
|
||||
|
||||
const mockJoinPayload = {
|
||||
cmd: 'join',
|
||||
nick: 'test#test',
|
||||
channel: 'test',
|
||||
}
|
||||
|
||||
describe('Checking enablecaptcha module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should be named', async () => {
|
||||
expect(importedModule.info.name).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be categorized', async () => {
|
||||
expect(importedModule.info.category).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be described', async () => {
|
||||
expect(importedModule.info.description).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be documented', async () => {
|
||||
expect(importedModule.info.usage).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be invokable', async () => {
|
||||
expect(importedModule.run).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should initialize', async () => {
|
||||
mocks.core.captchas = undefined;
|
||||
const resp = importedModule.init(mocks.core);
|
||||
|
||||
expect(mocks.core.captchas).to.be.an('object');
|
||||
});
|
||||
|
||||
// module main function
|
||||
it('should be invokable only by a mod', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should accept a channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChannelPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept no channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should fail on missing channel data', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should fail if already enabled', async () => {
|
||||
const origCaptchas = mocks.core.captchas;
|
||||
mocks.core.captchas = { [mocks.authedSocket.channel]: true };
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.core.captchas = origCaptchas;
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should initialize hooks', async () => {
|
||||
expect(() => importedModule.initHooks(mocks.server)).not.to.throw();
|
||||
});
|
||||
|
||||
it('should reject chat if not text', async () => {
|
||||
const resp = await importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockBadChatPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should return if channel is not enabled', async () => {
|
||||
const resp = await importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChatPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should disconnect on failed captcha', async () => {
|
||||
mocks.authedSocket.captcha = {};
|
||||
mocks.authedSocket.captcha.awaiting = true;
|
||||
|
||||
const resp = await importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChatPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should join with correct phrase', async () => {
|
||||
mocks.authedSocket.captcha = {};
|
||||
mocks.authedSocket.captcha.awaiting = true;
|
||||
mocks.authedSocket.captcha.solution = mockChatPayload.text;
|
||||
|
||||
const resp = await importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChatPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should handle legacy clients', async () => {
|
||||
mocks.authedSocket.captcha = {};
|
||||
mocks.authedSocket.captcha.awaiting = true;
|
||||
mocks.authedSocket.captcha.solution = mockChatPayload.text;
|
||||
|
||||
const origProtocol = mocks.authedSocket.hcProtocol;
|
||||
mocks.authedSocket.hcProtocol = 1;
|
||||
|
||||
const resp = await importedModule.chatCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChatPayload,
|
||||
});
|
||||
|
||||
mocks.authedSocket.hcProtocol = origProtocol;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should hook join commands', async () => {
|
||||
mocks.core.captchas = {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockJoinPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -139,6 +139,25 @@ describe('Checking join module', () => {
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should prevent admin impersonation', async () => {
|
||||
const newSocket = Object.assign({}, mocks.authedSocket);
|
||||
newSocket.channel = undefined;
|
||||
newSocket.hcProtocol = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: newSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
nick: 'admin#test',
|
||||
channel: 'cake',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should prevent two of the same name in the same channel', async () => {
|
||||
const newSocket = Object.assign({}, mocks.authedSocket);
|
||||
newSocket.channel = undefined;
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/mod/lockroom.js';
|
||||
let importedModule;
|
||||
|
||||
const targetChannel = 'test';
|
||||
|
||||
const mockPayload = {
|
||||
cmd: 'lockroom',
|
||||
}
|
||||
|
||||
const mockChannelPayload = {
|
||||
cmd: 'lockroom',
|
||||
channel: targetChannel,
|
||||
}
|
||||
|
||||
const mockBadChatPayload = {
|
||||
cmd: 'chat',
|
||||
text: {},
|
||||
}
|
||||
|
||||
const mockChatPayload = {
|
||||
cmd: 'chat',
|
||||
text: 'asdf',
|
||||
}
|
||||
|
||||
const mockJoinPayload = {
|
||||
cmd: 'join',
|
||||
nick: 'test#test',
|
||||
channel: 'test',
|
||||
}
|
||||
|
||||
const timeout = (ms) => {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
describe('Checking lockroom module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should be named', async () => {
|
||||
expect(importedModule.info.name).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be categorized', async () => {
|
||||
expect(importedModule.info.category).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be described', async () => {
|
||||
expect(importedModule.info.description).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be documented', async () => {
|
||||
expect(importedModule.info.usage).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be invokable', async () => {
|
||||
expect(importedModule.run).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should initialize', async () => {
|
||||
mocks.core.locked = undefined;
|
||||
const resp = importedModule.init(mocks.core);
|
||||
|
||||
expect(mocks.core.locked).to.be.an('object');
|
||||
});
|
||||
|
||||
// module main function
|
||||
it('should be invokable only by a mod', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should accept a channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChannelPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept no channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should fail on missing channel data', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should fail if already enabled', async () => {
|
||||
mocks.core.locked = { test: true };
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChannelPayload,
|
||||
});
|
||||
|
||||
mocks.core.locked = {};
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should initialize hooks', async () => {
|
||||
expect(() => importedModule.initHooks(mocks.server)).not.to.throw();
|
||||
});
|
||||
|
||||
// change nick hook checks
|
||||
it('should prevent name changes in purgatory channel', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = 'purgatory';
|
||||
|
||||
const resp = await importedModule.changeNickCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'changenick',
|
||||
nick: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should ignore name changes in other channels', async () => {
|
||||
const resp = await importedModule.changeNickCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'changenick',
|
||||
nick: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
// whisper hook checks
|
||||
it('should prevent whispers in purgatory channel', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = 'purgatory';
|
||||
|
||||
const resp = await importedModule.whisperCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'whisper',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should ignore whispers in other channels', async () => {
|
||||
const resp = await importedModule.whisperCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'whisper',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
// chat hook checks
|
||||
it('should prevent chats in purgatory channel', async () => {
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
plebSocket.channel = 'purgatory';
|
||||
|
||||
const resp = await importedModule.chatCheck({
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should allow mods to speak though', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = 'purgatory';
|
||||
|
||||
const resp = await importedModule.chatCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should ignore chats in other channels', async () => {
|
||||
const resp = await importedModule.chatCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
// invite hook checks
|
||||
it('should prevent invites in purgatory channel', async () => {
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
plebSocket.channel = 'purgatory';
|
||||
|
||||
const resp = await importedModule.inviteCheck({
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should ignore invites in other channels', async () => {
|
||||
const resp = await importedModule.inviteCheck({
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'chat',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
// join hook checks
|
||||
it('should ignore join if no lock record', async () => {
|
||||
mocks.core.locked = {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'test',
|
||||
nick: 'test',
|
||||
pass: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should ignore join if not locked or purgatory', async () => {
|
||||
mocks.core.locked = { test: false };
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'test',
|
||||
nick: 'test',
|
||||
pass: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
|
||||
it('should allow v2 into purgatory', async () => {
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
plebSocket.channel = 'used';
|
||||
mocks.core.locked = {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'purgatory',
|
||||
nick: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should allow v1 into purgatory', async () => {
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
plebSocket.channel = undefined;
|
||||
plebSocket.hcProtocol = undefined;
|
||||
mocks.core.locked = {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'purgatory',
|
||||
nick: 'thisnameistoolongandwillberejected',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should wait for the timeout to run', async () => {
|
||||
const mockServer = { ...mocks.server };
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
|
||||
plebSocket.channel = undefined;
|
||||
plebSocket.hcProtocol = undefined;
|
||||
mocks.core.locked = {};
|
||||
|
||||
mockServer.reply = () => {};
|
||||
|
||||
await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mockServer,
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'purgatory',
|
||||
nick: 'test',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should do channel checking', async () => {
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
plebSocket.channel = undefined;
|
||||
plebSocket.hcProtocol = undefined;
|
||||
plebSocket.banned = true;
|
||||
mocks.core.locked = {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'purgatory',
|
||||
nick: 'test',
|
||||
pass: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should use dante if not needed', async () => {
|
||||
const mockServer = { ...mocks.server };
|
||||
const plebSocket = { ...mocks.plebSocket };
|
||||
|
||||
plebSocket.channel = undefined;
|
||||
plebSocket.hcProtocol = undefined;
|
||||
mocks.core.locked = { lockedChan: true };
|
||||
|
||||
mockServer.reply = () => {};
|
||||
|
||||
const resp = await importedModule.joinCheck({
|
||||
core: mocks.core,
|
||||
server: mockServer,
|
||||
socket: plebSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
channel: 'lockedChan',
|
||||
nick: 'test',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
const mocks = {
|
||||
core: {
|
||||
sessionKey: 'test',
|
||||
|
||||
appConfig: {
|
||||
data: {
|
||||
globalMods: [],
|
||||
@@ -15,18 +16,23 @@ const mocks = {
|
||||
},
|
||||
write: async () => '',
|
||||
},
|
||||
|
||||
muzzledHashes: [],
|
||||
|
||||
stats: {
|
||||
increment: () => 1,
|
||||
decrement: () => 1,
|
||||
get: () => 1,
|
||||
set: () => 1,
|
||||
},
|
||||
|
||||
dynamicImports: {
|
||||
reloadDirCache: () => '',
|
||||
},
|
||||
|
||||
commands: {
|
||||
reloadCommands: () => '',
|
||||
handleCommand: () => '',
|
||||
commands: [],
|
||||
categoriesList: ['test'],
|
||||
all: () => [{
|
||||
@@ -56,10 +62,12 @@ const mocks = {
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
configManager: {
|
||||
save: () => true,
|
||||
},
|
||||
},
|
||||
|
||||
server : {
|
||||
police: {
|
||||
addresses: [],
|
||||
@@ -85,6 +93,7 @@ const mocks = {
|
||||
}],
|
||||
getSocketHash: () => 'test',
|
||||
},
|
||||
|
||||
plebSocket: {
|
||||
level: 100,
|
||||
address: '127.0.0.1',
|
||||
@@ -97,6 +106,7 @@ const mocks = {
|
||||
uType: 'user',
|
||||
userid: 1234,
|
||||
},
|
||||
|
||||
authedSocket: {
|
||||
level: 9999999,
|
||||
address: '127.0.0.1',
|
||||
|
||||
@@ -68,4 +68,60 @@ describe('Checking speak module', () => {
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept payload.ip as a string', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'speak',
|
||||
ip: '127.0.0.1',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept payload.hash as a string', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'speak',
|
||||
hash: 'pretendthisisahash',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should unmuzzle all if payload.ip is *', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'speak',
|
||||
ip: '*',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should unmuzzle all if payload.hash is *', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: {
|
||||
cmd: 'speak',
|
||||
hash: '*',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/utility/_Text.js';
|
||||
let importedModule;
|
||||
|
||||
describe('Checking _Text module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should return null if not text', () => {
|
||||
const resp = importedModule.parseText([]);
|
||||
|
||||
expect(resp).to.be.null;
|
||||
});
|
||||
});
|
||||
+2
-2
@@ -42,7 +42,7 @@ describe('Checking UAC module', () => {
|
||||
|
||||
it('should return admin level labels', async () => {
|
||||
const newConfig = Object.assign({}, mocks.core.appConfig.data);
|
||||
newConfig.adminTrip = 'Tt8H7clbL9';
|
||||
newConfig.adminTrip = 'Tt8H7c';
|
||||
const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake');
|
||||
expect(resp).to.be.an('object');
|
||||
});
|
||||
@@ -50,7 +50,7 @@ describe('Checking UAC module', () => {
|
||||
it('should return mod level labels', async () => {
|
||||
const newConfig = Object.assign({}, mocks.core.appConfig.data);
|
||||
newConfig.globalMods = [{
|
||||
trip: 'Tt8H7clbL9',
|
||||
trip: 'Tt8H7c',
|
||||
}];
|
||||
const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake');
|
||||
expect(resp).to.be.an('object');
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/mod/unlockroom.js';
|
||||
let importedModule;
|
||||
|
||||
const mockPayload = {
|
||||
cmd: 'unlockroom',
|
||||
}
|
||||
|
||||
const mockChannelPayload = {
|
||||
cmd: 'unlockroom',
|
||||
channel: 'test',
|
||||
}
|
||||
|
||||
describe('Checking unlockroom module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should be named', async () => {
|
||||
expect(importedModule.info.name).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be categorized', async () => {
|
||||
expect(importedModule.info.category).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be described', async () => {
|
||||
expect(importedModule.info.description).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be documented', async () => {
|
||||
expect(importedModule.info.usage).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be invokable', async () => {
|
||||
expect(importedModule.run).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should initialize', async () => {
|
||||
mocks.core.locked = undefined;
|
||||
const resp = importedModule.init(mocks.core);
|
||||
|
||||
expect(mocks.core.locked).to.be.an('object');
|
||||
});
|
||||
|
||||
// module main function
|
||||
it('should be invokable only by a mod', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should accept a channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockChannelPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should accept no channel param', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should fail on missing channel data', async () => {
|
||||
const origChannel = mocks.authedSocket.channel;
|
||||
mocks.authedSocket.channel = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.authedSocket.channel = origChannel;
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should unlock if locked', async () => {
|
||||
mocks.core.locked = { [mocks.authedSocket.channel]: true };
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,233 @@
|
||||
import { expect } from 'chai';
|
||||
import mocks from './mockImports.js';
|
||||
|
||||
const modulePath = '../commands/core/updateMessage.js';
|
||||
let importedModule;
|
||||
|
||||
const mockPayload = {
|
||||
cmd: 'updateMessage',
|
||||
}
|
||||
|
||||
const mockChannelPayload = {
|
||||
cmd: 'updateMessage',
|
||||
channel: 'test',
|
||||
}
|
||||
|
||||
describe('Checking unlockroom module', () => {
|
||||
// module meta data
|
||||
it('should be importable', async () => {
|
||||
importedModule = await import(modulePath);
|
||||
expect(importedModule).to.not.be.a('string');
|
||||
});
|
||||
|
||||
it('should be named', async () => {
|
||||
expect(importedModule.info.name).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be categorized', async () => {
|
||||
expect(importedModule.info.category).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be described', async () => {
|
||||
expect(importedModule.info.description).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be documented', async () => {
|
||||
expect(importedModule.info.usage).to.be.a('string');
|
||||
});
|
||||
|
||||
it('should be invokable', async () => {
|
||||
expect(importedModule.run).to.be.a('function');
|
||||
});
|
||||
|
||||
// module main function
|
||||
it('should default the mode param if missing', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
customId: '1234',
|
||||
text: 'test',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should reject if mode is invalid', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
customId: '1234',
|
||||
text: 'test',
|
||||
mode: 'poop',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should reject if customId is missing', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'test',
|
||||
mode: 'overwrite',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should reject if customId is not text', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'test',
|
||||
customId: {},
|
||||
mode: 'overwrite',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should reject if customId is not too long', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'test',
|
||||
customId: `A`.repeat(importedModule.MAX_MESSAGE_ID_LENGTH * 2),
|
||||
mode: 'overwrite',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should reject if text is not text', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: {},
|
||||
customId: `A`,
|
||||
mode: 'overwrite',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should change text to null if empty', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: '',
|
||||
customId: `A`,
|
||||
mode: 'overwrite',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should otherwise reject empty text', async () => {
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: '',
|
||||
customId: `A`,
|
||||
mode: 'prepend',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.false;
|
||||
});
|
||||
|
||||
it('should delete active message records', async () => {
|
||||
const chatModule = await import('../commands/core/chat.js');
|
||||
|
||||
chatModule.ACTIVE_MESSAGES.push({
|
||||
customId: 'asdf',
|
||||
userid: 1234,
|
||||
sent: 0,
|
||||
toDelete: false,
|
||||
});
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'a',
|
||||
customId: 'asdf',
|
||||
mode: 'complete',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should mark if sent by mod', async () => {
|
||||
const newSocket = { ...mocks.authedSocket };
|
||||
newSocket.level = 999999;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: newSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'a',
|
||||
customId: 'asdf',
|
||||
mode: 'append',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should mark if sent by admin', async () => {
|
||||
const newSocket = { ...mocks.authedSocket };
|
||||
newSocket.level = 9999999;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
server: mocks.server,
|
||||
socket: newSocket,
|
||||
payload: {
|
||||
cmd: 'updateMessage',
|
||||
text: 'a',
|
||||
customId: 'asdf',
|
||||
mode: 'append',
|
||||
},
|
||||
});
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user