feat(#709): add configured Discord interaction binding
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
createDiscordIngressEnvelope,
|
||||
verifyDiscordIngressEnvelope,
|
||||
type DiscordIngressPayload,
|
||||
resolveDiscordInteractionBinding,
|
||||
} from '@mosaicstack/discord-plugin';
|
||||
import { validateDiscordServiceToken } from '../chat/chat.gateway-auth.js';
|
||||
import { DiscordReplayProtector } from './discord-replay-protector.js';
|
||||
@@ -23,6 +24,25 @@ function createPayload(overrides: Partial<DiscordIngressPayload> = {}): DiscordI
|
||||
}
|
||||
|
||||
describe('Discord ingress security', () => {
|
||||
it('binds a differently named configured interaction instance without code changes', () => {
|
||||
const binding = resolveDiscordInteractionBinding(
|
||||
[
|
||||
{
|
||||
instanceId: 'Nova',
|
||||
guildId: 'guild-001',
|
||||
channelId: 'channel-001',
|
||||
pairedUsers: { 'user-001': 'operator' },
|
||||
},
|
||||
],
|
||||
'guild-001',
|
||||
'channel-001',
|
||||
'user-001',
|
||||
'send',
|
||||
);
|
||||
|
||||
expect(binding?.instanceId).toBe('Nova');
|
||||
});
|
||||
|
||||
it('accepts only the configured Discord service identity', () => {
|
||||
expect(validateDiscordServiceToken(SERVICE_TOKEN, SERVICE_TOKEN)).toBe(true);
|
||||
expect(validateDiscordServiceToken('wrong-service-token', SERVICE_TOKEN)).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user