feat: add cmpp inbound gateway listener

This commit is contained in:
hectorzhao
2026-07-07 16:19:14 +08:00
parent ad3b86ba0a
commit cc628d0214
14 changed files with 631 additions and 17 deletions
@@ -8,6 +8,7 @@ function createPrismaMock() {
tenantId: 'tenant-1',
name: '应用A',
status: 'active',
cmppAccount: '100001',
queuePriority: 'normal',
tenant: { id: 'tenant-1', name: '租户A', code: 'TENANT-A' },
messageRecords: [{ status: 'delivered' }, { status: 'undelivered' }],
@@ -17,6 +18,7 @@ function createPrismaMock() {
tenantId: 'tenant-1',
name: '应用A',
status: 'active',
cmppAccount: '100001',
queuePriority: 'normal',
secretHash: 'secret-hash',
tenant: { id: 'tenant-1', name: '租户A', code: 'TENANT-A' },
@@ -164,6 +166,7 @@ describe('SmsConfigService', () => {
await expect(service.getApplicationCmppParams('app-1')).resolves.toEqual(expect.objectContaining({
applicationId: 'app-1',
tenantName: '租户A',
account: '100001',
gatewayHost: '127.0.0.1',
gatewayPort: 17890,
maxConnections: 2,
@@ -172,6 +175,7 @@ describe('SmsConfigService', () => {
it('creates enterprise applications with persisted queue priority', async () => {
const prisma = createPrismaMock();
prisma.smsApplication.findUnique.mockResolvedValueOnce(null);
const service = new SmsConfigService(prisma as never);
await expect(service.createApplication({
@@ -185,6 +189,7 @@ describe('SmsConfigService', () => {
data: expect.objectContaining({
tenantId: 'tenant-1',
name: '优先应用',
cmppAccount: expect.stringMatching(/^\d{6}$/),
queuePriority: 'priority',
ipAllowlist: { create: [{ ipCidr: '10.0.0.1/32' }] },
}),
@@ -195,11 +200,11 @@ describe('SmsConfigService', () => {
const prisma = createPrismaMock();
const service = new SmsConfigService(prisma as never);
expect(() => service.createApplication({
await expect(service.createApplication({
tenantId: 'tenant-1',
name: '异常应用',
queuePriority: 'urgent',
})).toThrow('queuePriority must be normal or priority');
})).rejects.toThrow('queuePriority must be normal or priority');
expect(prisma.smsApplication.create).not.toHaveBeenCalled();
});