feat: complete cmpp gateway delivery recovery workflows
This commit is contained in:
@@ -9,6 +9,8 @@ function createPrismaMock() {
|
||||
name: '应用A',
|
||||
status: 'active',
|
||||
cmppAccount: '100001',
|
||||
cmppMaxConnections: 2,
|
||||
cmppWindowSize: 32,
|
||||
queuePriority: 'normal',
|
||||
tenant: { id: 'tenant-1', name: '租户A', code: 'TENANT-A' },
|
||||
messageRecords: [{ status: 'delivered' }, { status: 'undelivered' }],
|
||||
@@ -19,6 +21,8 @@ function createPrismaMock() {
|
||||
name: '应用A',
|
||||
status: 'active',
|
||||
cmppAccount: '100001',
|
||||
cmppMaxConnections: 2,
|
||||
cmppWindowSize: 32,
|
||||
queuePriority: 'normal',
|
||||
secretHash: 'secret-hash',
|
||||
tenant: { id: 'tenant-1', name: '租户A', code: 'TENANT-A' },
|
||||
@@ -170,6 +174,7 @@ describe('SmsConfigService', () => {
|
||||
gatewayHost: '127.0.0.1',
|
||||
gatewayPort: 17890,
|
||||
maxConnections: 2,
|
||||
windowSize: 32,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -181,6 +186,9 @@ describe('SmsConfigService', () => {
|
||||
await expect(service.createApplication({
|
||||
tenantId: 'tenant-1',
|
||||
name: '优先应用',
|
||||
cmppAccount: '123456',
|
||||
cmppMaxConnections: 3,
|
||||
cmppWindowSize: 32,
|
||||
queuePriority: 'priority',
|
||||
ipAllowlist: ['10.0.0.1/32'],
|
||||
})).resolves.toEqual(expect.objectContaining({ id: 'app-new' }));
|
||||
@@ -189,7 +197,9 @@ describe('SmsConfigService', () => {
|
||||
data: expect.objectContaining({
|
||||
tenantId: 'tenant-1',
|
||||
name: '优先应用',
|
||||
cmppAccount: expect.stringMatching(/^\d{6}$/),
|
||||
cmppAccount: '123456',
|
||||
cmppMaxConnections: 3,
|
||||
cmppWindowSize: 32,
|
||||
queuePriority: 'priority',
|
||||
ipAllowlist: { create: [{ ipCidr: '10.0.0.1/32' }] },
|
||||
}),
|
||||
@@ -209,6 +219,23 @@ describe('SmsConfigService', () => {
|
||||
expect(prisma.smsApplication.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('rejects duplicate or invalid CMPP application accounts', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
await expect(service.createApplication({
|
||||
tenantId: 'tenant-1',
|
||||
name: '异常应用',
|
||||
cmppAccount: 'abc',
|
||||
})).rejects.toThrow('cmppAccount must be a 6-digit number');
|
||||
|
||||
await expect(service.createApplication({
|
||||
tenantId: 'tenant-1',
|
||||
name: '重复应用',
|
||||
cmppAccount: '100001',
|
||||
})).rejects.toThrow('cmppAccount already exists');
|
||||
});
|
||||
|
||||
it('updates enterprise application profile and allowlist through a transaction', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const tx = {
|
||||
|
||||
Reference in New Issue
Block a user